use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.
the class InitLongNeighborByteAttr method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
PartInitNeighborAttrParam param = (PartInitNeighborAttrParam) 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<NeighborsAttrsElement>> iter = param.getNodeId2Neighbors().long2ObjectEntrySet().iterator();
row.startWrite();
try {
while (iter.hasNext()) {
Long2ObjectMap.Entry<NeighborsAttrsElement> entry = iter.next();
NeighborsAttrsElement elem = entry.getValue();
if (elem == null) {
row.set(entry.getLongKey(), null);
} else {
// compress the neighbor IDs
try {
byte[] compressed = Snappy.compress(elem.getNeighborIds());
NeighborsAttrsCompressedElement compressedElement = new NeighborsAttrsCompressedElement(compressed, elem.getAttrs());
row.set(entry.getLongKey(), compressedElement);
} catch (IOException e) {
LOG.error("save neighbor table error!", e);
row.set(entry.getLongKey(), null);
}
}
}
} finally {
row.endWrite();
}
}
use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.
the class InitNeighbor method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
PartInitNeighborParam param = (PartInitNeighborParam) 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<long[]>> iter = param.getNodeIdToNeighborIndices().long2ObjectEntrySet().iterator();
row.startWrite();
try {
while (iter.hasNext()) {
Long2ObjectMap.Entry<long[]> entry = iter.next();
row.set(entry.getLongKey(), new LongArrayElement(entry.getValue()));
}
} finally {
row.endWrite();
}
}
use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.
the class GetNumNeighborEdgesFunc method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
PartGetNumNeighborEdgesParam param = (PartGetNumNeighborEdgesParam) partParam;
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
ServerPartition part = matrix.getPartition(partParam.getPartKey().getPartitionId());
ServerLongLongRow row = (ServerLongLongRow) (((RowBasedPartition) part).getRow(0));
long[] nodeIds = param.getNodeIds();
long[] numEdges = new long[nodeIds.length];
for (int i = 0; i < nodeIds.length; i++) {
numEdges[i] = row.get(nodeIds[i]);
}
return new PartGetNumNeighborEdgesResult(part.getPartitionKey().getPartitionId(), numEdges);
}
use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.
the class OptMMUpdateFunc method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
RowBasedPartition part = (RowBasedPartition) psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
assert part != null;
MMUpdateParam.MMPartitionUpdateParam vs2 = (MMUpdateParam.MMPartitionUpdateParam) partParam;
update(part, vs2.getRowIds()[0], vs2.getScalars());
}
use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.
the class GraphMatrixUtils method getPSAnyKeyRow.
public static ServerAnyAnyRow getPSAnyKeyRow(PSContext psContext, PartitionGetParam partParam) {
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
ServerPartition part = matrix.getPartition(partParam.getPartKey().getPartitionId());
return (ServerAnyAnyRow) (((RowBasedPartition) part).getRow(0));
}
Aggregations