use of com.tencent.angel.graph.client.getnodefeats2.PartGetNodeFeatsResult in project angel by Tencent.
the class SampleNodeFeats method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
SampleNodeFeatsPartParam param = (SampleNodeFeatsPartParam) partParam;
ServerLongAnyRow row = (ServerLongAnyRow) psContext.getMatrixStorageManager().getRow(param.getPartKey(), 0);
int size = Math.min(row.size(), param.getSize());
IntFloatVector[] feats = new IntFloatVector[size];
Random rand = new Random(System.currentTimeMillis());
// sample continuously beginning from a random index
int bound = row.size() - size;
int skip = bound > 0 ? rand.nextInt(bound) : 0;
ObjectIterator<Long2ObjectMap.Entry<IElement>> it = row.getStorage().iterator();
it.skip(skip);
for (int i = 0; i < size; i++) {
feats[i] = ((Node) it.next().getValue()).getFeats();
}
return new PartGetNodeFeatsResult(param.getPartKey().getPartitionId(), feats);
}
Aggregations