Package edu.cmu.graphchi.walks.distributions

Source Code of edu.cmu.graphchi.walks.distributions.IntDrunkardCompanion

package edu.cmu.graphchi.walks.distributions;

import edu.cmu.graphchi.walks.IntWalkManager;
import edu.cmu.graphchi.walks.WalkArray;
import edu.cmu.graphchi.walks.IntWalkArray;

import java.rmi.RemoteException;

public class IntDrunkardCompanion extends DrunkardCompanion {
    private IntWalkManager manager;

    public IntDrunkardCompanion( final int numThreads, final long maxMemoryBytes)
            throws RemoteException {
        super(numThreads, maxMemoryBytes);
        // TODO: may be better to pass this in...
        manager = new IntWalkManager(0, 0);
    }

    @Override
    protected void _processWalks(WalkArray walkArray, int[] atVertices) {
        int[] walks = ((IntWalkArray)walkArray).getArray();
        long t1 = System.currentTimeMillis();
        for(int i=0; i < walks.length; i++) {
            int w = walks[i];
            int atVertex = atVertices[i];
            int sourceIdx = manager.sourceIdx(w);

            if (atVertex == sourceVertexIds[sourceIdx]) {
                continue;
            }

            synchronized (buffers[sourceIdx]) {
                buffers[sourceIdx].add(atVertex);
            }
        }

        long tt = (System.currentTimeMillis() - t1);
        if (tt > 1000) {
            logger.info("Processing " + walks.length + " took " + tt + " ms.");
        }
    }
}
TOP

Related Classes of edu.cmu.graphchi.walks.distributions.IntDrunkardCompanion

TOP
Copyright © 2018 www.massapi.com. 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.