Search in sources :

Example 1 with Entry

use of it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry in project angel by Tencent.

the class SampleUtils method sampleNodeFeatByCount.

public static IntFloatVector[] sampleNodeFeatByCount(ServerRow row, int count, long seed) {
    Random r = new Random(seed);
    IntFloatVector[] feats = new IntFloatVector[count];
    int bound = row.size() - count;
    int skip = bound > 0 ? r.nextInt(bound) : 0;
    ObjectIterator<Entry<IElement>> it = (((ServerLongAnyRow) row).getStorage()).iterator();
    it.skip(skip);
    for (int i = 0; i < count; i++) {
        feats[i] = ((GraphNode) it.next().getValue()).getFeats();
    }
    return feats;
}
Also used : Entry(it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry) Random(java.util.Random) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector)

Example 2 with Entry

use of it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry in project angel by Tencent.

the class GetNodes method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam param) {
    ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
    ObjectIterator<Entry<IElement>> it = row.iterator();
    LongArrayList nodes = new LongArrayList();
    Boolean isHash = ((PartGetNodesParam) param).getHash();
    long start = isHash ? 0 : param.getPartKey().getStartCol();
    while (it.hasNext()) {
        Long2ObjectMap.Entry entry = it.next();
        GraphNode node = (GraphNode) entry.getValue();
        if (node.getFeats() != null && node.getNeighbors() == null) {
            nodes.add(entry.getLongKey() + start);
        }
    }
    return new IndexPartGetLongResult(param.getPartKey(), nodes.toLongArray());
}
Also used : IndexPartGetLongResult(com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult) Entry(it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry) LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) Entry(it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry) Long2ObjectMap(it.unimi.dsi.fastutil.longs.Long2ObjectMap) GraphNode(com.tencent.angel.graph.data.GraphNode) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow)

Aggregations

ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)2 Entry (it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry)2 GraphNode (com.tencent.angel.graph.data.GraphNode)1 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)1 IndexPartGetLongResult (com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult)1 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)1 LongArrayList (it.unimi.dsi.fastutil.longs.LongArrayList)1 Random (java.util.Random)1