use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow 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);
}
use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class SampleNeighbor method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
SampleNeighborPartParam param = (SampleNeighborPartParam) partParam;
ServerLongAnyRow row = (ServerLongAnyRow) psContext.getMatrixStorageManager().getRow(param.getPartKey(), 0);
return new SampleNeighborPartResult(param.getPartKey().getPartitionId(), row, param.getKeys(), param.getNumSample(), param.getSampleTypes());
}
use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class NnzEdge method processRow.
@Override
public double processRow(ServerRow row) {
LongElementStorage storage = ((ServerLongAnyRow) row).getStorage();
ObjectIterator<Long2ObjectMap.Entry<IElement>> it = storage.iterator();
long size = 0;
while (it.hasNext()) {
Node node = (Node) (it.next().getValue());
if (node.getNeighbors() != null) {
size += node.getNeighbors().length;
}
}
return size;
}
use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class NnzNeighbor method processRow.
@Override
public double processRow(ServerRow row) {
LongElementStorage storage = ((ServerLongAnyRow) row).getStorage();
ObjectIterator<Long2ObjectMap.Entry<IElement>> it = storage.iterator();
int size = 0;
while (it.hasNext()) {
Node node = (Node) (it.next().getValue());
if (node.getNeighbors() != null) {
size++;
}
}
return size;
}
use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class InitEdgeFeats method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
GeneralPartUpdateParam initParam = (GeneralPartUpdateParam) partParam;
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, initParam);
// Get nodes and features
ILongKeyAnyValuePartOp split = (ILongKeyAnyValuePartOp) initParam.getKeyValuePart();
long[] nodeIds = split.getKeys();
IElement[] edgeFeatures = split.getValues();
row.startWrite();
try {
for (int i = 0; i < nodeIds.length; i++) {
GraphNode graphNode = (GraphNode) row.get(nodeIds[i]);
if (graphNode == null) {
graphNode = new GraphNode();
row.set(nodeIds[i], graphNode);
}
graphNode.setNeighbors(((LongEdgeFeats) edgeFeatures[i]).getNodeIds());
graphNode.setEdgeFeatures(((LongEdgeFeats) edgeFeatures[i]).getFeats());
}
} finally {
row.endWrite();
}
}
Aggregations