use of com.tencent.angel.graph.data.Node in project angel by Tencent.
the class InitNeighbor method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
InitNeighborPartParam param = (InitNeighborPartParam) partParam;
ServerLongAnyRow row = (ServerLongAnyRow) (psContext.getMatrixStorageManager().getRow(param.getPartKey(), 0));
long[] keys = param.getKeys();
long[][] neighborArrays = param.getNeighborArrays();
int[][] edgeTypes = param.getEdgeTypeArrays();
int[][] neighborTypes = param.getDstTypeArrays();
row.startWrite();
try {
for (int i = 0; i < keys.length; i++) {
Node node = (Node) row.get(keys[i]);
if (node == null) {
node = new Node();
row.set(keys[i], node);
}
node.setNeighbors(neighborArrays[i]);
if (edgeTypes != null)
node.setEdgeTypes(edgeTypes[i]);
if (neighborTypes != null)
node.setTypes(neighborTypes[i]);
}
} finally {
row.endWrite();
}
}
use of com.tencent.angel.graph.data.Node in project angel by Tencent.
the class SampleNeighborPartResult method bufferLen.
@Override
public int bufferLen() {
int len = 4 + 4 + 4 + ByteBufSerdeUtils.serializedBooleanLen(sampleTypes);
for (int i = 0; i < keys.length; i++) {
Node node = (Node) row.get(keys[i]);
if (node == null) {
len += 4;
continue;
}
long[] neighbor = node.getNeighbors();
if (neighbor == null || neighbor.length == 0) {
len += 4;
continue;
}
int size = numSample;
if (numSample <= 0 || numSample >= neighbor.length) {
size = neighbor.length;
}
len += 4;
if (sampleTypes) {
for (int j = 0; j < size; j++) {
len += 8 + 4;
}
} else {
for (int j = 0; j < size; j++) {
len += 8;
}
}
}
return len;
}
use of com.tencent.angel.graph.data.Node 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.graph.data.Node 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;
}
Aggregations