use of com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement in project angel by Tencent.
the class InitDynamicNbrs 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[] neighbors = split.getValues();
row.startWrite();
try {
for (int i = 0; i < nodeIds.length; i++) {
LongArrayElement data = (LongArrayElement) neighbors[i];
DynamicNeighborElement ele = (DynamicNeighborElement) row.get(nodeIds[i]);
if (ele == null) {
ele = new DynamicNeighborElement();
ele.add(data.getData());
row.set(nodeIds[i], ele);
} else {
ele.add(data.getData());
}
}
} finally {
row.endWrite();
}
}
use of com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement in project angel by Tencent.
the class GetSort method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
RowBasedPartition part = (RowBasedPartition) matrix.getPartition(partParam.getPartKey().getPartitionId());
ServerLongAnyRow row = (ServerLongAnyRow) part.getRow(0);
ObjectIterator<Long2ObjectMap.Entry<IElement>> it = row.getStorage().iterator();
row.startWrite();
try {
while (it.hasNext()) {
Long2ObjectMap.Entry<IElement> next = it.next();
DynamicNeighborElement ele = (DynamicNeighborElement) next.getValue();
if (ele != null) {
ele.trans();
}
}
} finally {
row.endWrite();
}
}
use of com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement in project angel by Tencent.
the class GetNeighbor method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
int resultSize = 0;
for (PartitionGetResult result : partResults) {
resultSize += ((PartGeneralGetResult) result).getNodeIds().length;
}
Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(resultSize);
for (PartitionGetResult result : partResults) {
PartGeneralGetResult partResult = (PartGeneralGetResult) result;
long[] nodeIds = partResult.getNodeIds();
IElement[] neighbors = partResult.getData();
for (int i = 0; i < nodeIds.length; i++) {
if (neighbors[i] != null) {
byte[] nbrs = ((DynamicNeighborElement) neighbors[i]).getData();
nodeIdToNeighbors.put(nodeIds[i], ScalaKryoInstantiator.defaultPool().fromBytes(nbrs, long[].class));
} else {
nodeIdToNeighbors.put(nodeIds[i], Constents.emptyLongs);
}
}
}
return new GetLongsResult(nodeIdToNeighbors);
}
Aggregations