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()) {
GraphNode node = (GraphNode) (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()) {
GraphNode node = (GraphNode) (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 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 SampleNodeFeat method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
PartSampleNodeFeatParam sampleParam = (PartSampleNodeFeatParam) partParam;
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, partParam);
int count = Math.min(row.size(), sampleParam.getCount());
IntFloatVector[] feats = SampleUtils.sampleNodeFeatByCount(row, count, System.currentTimeMillis());
return new PartSampleNodeFeatResult(sampleParam.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());
}
Aggregations