Package edu.cmu.graphchi.util

Examples of edu.cmu.graphchi.util.IntegerBuffer


                                    // different buffers.
                                    for(int i=_threadId; i < sourceVertexIds.length; i+=numThreads) {
                                        if (buffers[i].size() >= BUFFER_MAX || closed) {
                                            // Drain asynchronously
                                            outstanding.incrementAndGet();
                                            final IntegerBuffer toDrain = buffers[i];
                                            final int drainIdx = i;

                                            synchronized (buffers[i]) {
                                                buffers[i] = new IntegerBuffer(BUFFER_CAPACITY);
                                            }
                                            parallelExecutor.submit(new Runnable() { public void run() {
                                                try {
                                                    int[] d = toDrain.toIntArray();
                                                    Arrays.sort(d);
                                                    DiscreteDistribution dist = new DiscreteDistribution(d);
                                                    mergeWith(drainIdx, dist);
                                                } catch (Exception err ) {
                                                    err.printStackTrace();
View Full Code Here


        distrLocks = new Object[sources.length];
        distributions = new DiscreteDistribution[sources.length];
        for(int i=0; i < sources.length; i++) {
            distrLocks[i] = new Object();
            sourceVertexIds[i] = sources[i];
            buffers[i] = new IntegerBuffer(BUFFER_CAPACITY);
            distributions[i] = DiscreteDistribution.createAvoidanceDistribution(new int[]{sources[i]}); // Add the vertex itself to avoids
        }
        logger.info("Done...");

        timer.schedule(new TimerTask() {
View Full Code Here


    protected void drainBuffer(int sourceIdx) {
        synchronized (buffers[sourceIdx]) {
            int[] arr = buffers[sourceIdx].toIntArray();
            buffers[sourceIdx] = new IntegerBuffer(BUFFER_CAPACITY);
            Arrays.sort(arr);
            DiscreteDistribution dist = new DiscreteDistribution(arr);
            mergeWith(sourceIdx, dist);
        }
    }
View Full Code Here

                    ConcurrentHashMap<Integer, IntegerBuffer> bmap = buffers.get(firstKey);
                    if (bmap == null) {
                        bmap = new ConcurrentHashMap<Integer, IntegerBuffer>();
                        buffers.put(firstKey, bmap);
                    }
                    bmap.put(secondKey, new IntegerBuffer(BUFFER_CAPACITY));
                }
            } else {
                synchronized(lock) {
                    // We're just waiting for the other thread to release the lock, so that we can
                    // get the buffer without crashing later.  Another thread actually added it,
View Full Code Here

            int firstKey = getFirstKey(w, atVertex);
            int secondKey = getSecondKey(w, atVertex);
            int value = getValue(w, atVertex);

            ensureExists(firstKey, secondKey);
            IntegerBuffer buffer = buffers.get(firstKey).get(secondKey);
            synchronized (buffer) {
                buffer.add(value);
            }
        }

        long tt = (System.currentTimeMillis() - t1);
        if (tt > 1000) {
View Full Code Here

    protected abstract int getSecondKey(long walk, int atVertex);

    protected abstract int getValue(long walk, int atVertex);

    protected void drainBuffer(int firstKey, int secondKey) {
        IntegerBuffer buffer = buffers.get(firstKey).get(secondKey);
        int[] arr;
        synchronized (buffer) {
            arr = buffer.toIntArray();
            buffers.get(firstKey).put(secondKey, new IntegerBuffer(BUFFER_CAPACITY));
        }
        Arrays.sort(arr);
        DiscreteDistribution dist = new DiscreteDistribution(arr);
        mergeWith(firstKey, secondKey, dist);
    }
View Full Code Here

                                    if ((firstKey + secondKey) % numThreads != id) {
                                        continue;
                                    }
                                    // Drain asynchronously
                                    outstanding.incrementAndGet();
                                    final IntegerBuffer toDrain = map.get(secondKey);
                                    final int first = firstKey;
                                    final int second = secondKey;

                                    synchronized (toDrain) {
                                        map.put(secondKey, new IntegerBuffer(BUFFER_CAPACITY));
                                    }
                                    parallelExecutor.submit(new Runnable() { public void run() {
                                        try {
                                            int[] d = toDrain.toIntArray();
                                            Arrays.sort(d);
                                            DiscreteDistribution dist = new DiscreteDistribution(d);
                                            mergeWith(first, second, dist);
                                        } catch (Exception err ) {
                                            err.printStackTrace();
View Full Code Here

TOP

Related Classes of edu.cmu.graphchi.util.IntegerBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.