Search in sources :

Example 6 with WalkPath

use of com.tencent.angel.graph.client.node2vec.data.WalkPath in project angel by Tencent.

the class PathQueue method popBatchPath.

public static Long2ObjectOpenHashMap<long[]> popBatchPath(int psPartId, int batchSize) {
    ReentrantLock queueLock = psPartId2Lock.get(psPartId);
    queueLock.lock();
    Long2ObjectOpenHashMap<long[]> result;
    try {
        Queue<WalkPath> queue = psPartId2Queue.get(psPartId);
        int count = 0;
        result = new Long2ObjectOpenHashMap<>(batchSize);
        while (!queue.isEmpty() && count < batchSize) {
            WalkPath wPath = queue.poll();
            result.put(wPath.getHead(), wPath.getPath());
            count++;
        }
    } finally {
        queueLock.unlock();
    }
    return result;
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) WalkPath(com.tencent.angel.graph.client.node2vec.data.WalkPath)

Example 7 with WalkPath

use of com.tencent.angel.graph.client.node2vec.data.WalkPath in project angel by Tencent.

the class PathQueue method popBatchPath.

public static void popBatchPath(int psPartId, int batchSize, Long2ObjectOpenHashMap<long[]> result) {
    ReentrantLock queueLock = psPartId2Lock.get(psPartId);
    queueLock.lock();
    try {
        Queue<WalkPath> queue = psPartId2Queue.get(psPartId);
        int count = 0;
        while (!queue.isEmpty() && count < batchSize) {
            WalkPath wPath = queue.poll();
            result.put(wPath.getHead(), wPath.getPath());
            count++;
        }
    } finally {
        queueLock.unlock();
    }
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) WalkPath(com.tencent.angel.graph.client.node2vec.data.WalkPath)

Aggregations

WalkPath (com.tencent.angel.graph.client.node2vec.data.WalkPath)7 ReentrantLock (java.util.concurrent.locks.ReentrantLock)6 PartitionKey (com.tencent.angel.PartitionKey)1 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)1 IElement (com.tencent.angel.ps.storage.vector.element.IElement)1 LongArrayElement (com.tencent.angel.ps.storage.vector.element.LongArrayElement)1 Int2IntOpenHashMap (it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap)1 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)1 Long2LongOpenHashMap (it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap)1 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)1 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Random (java.util.Random)1