Search in sources :

Example 1 with PartitionGetParamWithIds

use of com.tencent.angel.graph.client.node2vec.params.PartitionGetParamWithIds in project angel by Tencent.

the class PullNeighbor method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    PartitionGetParamWithIds pparam = (PartitionGetParamWithIds) partParam;
    long[] keyIds = pparam.getKeyIds();
    ServerLongAnyRow row = (ServerLongAnyRow) psContext.getMatrixStorageManager().getRow(pparam.getPartKey(), 0);
    Long2ObjectOpenHashMap<long[]> partResult = new Long2ObjectOpenHashMap<long[]>(keyIds.length);
    boolean isTrunc = PathQueue.isIsTrunc();
    if (PathQueue.getKeepProba() < 1.0 - 1e-6 && PathQueue.getKeepProba() > 1e-6) {
        double selectThred = PathQueue.getThreshold() / (1 - PathQueue.getKeepProba());
        for (long keyId : keyIds) {
            LongArrayElement longArrayElement = (LongArrayElement) row.get(keyId);
            long[] neighs = longArrayElement.getData();
            if (isTrunc && neighs.length > selectThred) {
                partResult.put(keyId, Arrays.copyOf(neighs, (int) selectThred));
            } else {
                partResult.put(keyId, neighs);
            }
        }
    } else {
        for (long keyId : keyIds) {
            LongArrayElement longArrayElement = (LongArrayElement) row.get(keyId);
            long[] neighs = longArrayElement.getData();
            partResult.put(keyId, neighs);
        }
    }
    return new PullNeighborPartitionResult(partResult);
}
Also used : PartitionGetParamWithIds(com.tencent.angel.graph.client.node2vec.params.PartitionGetParamWithIds) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) LongArrayElement(com.tencent.angel.ps.storage.vector.element.LongArrayElement) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow)

Aggregations

PartitionGetParamWithIds (com.tencent.angel.graph.client.node2vec.params.PartitionGetParamWithIds)1 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)1 LongArrayElement (com.tencent.angel.ps.storage.vector.element.LongArrayElement)1 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1