use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.
the class IntArrayElementStorage method deserialize.
@Override
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
// Array len
int len = buf.readInt();
data = new IElement[len];
// Valid element number
int elementNum = buf.readInt();
for (int i = 0; i < elementNum; i++) {
IElement element = newElement();
data[buf.readInt()] = element;
element.deserialize(buf);
}
}
use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.
the class GeneralInit 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++) {
row.set(nodeIds[i], neighbors[i]);
}
} finally {
row.endWrite();
}
}
use of com.tencent.angel.ps.storage.vector.element.IElement 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);
}
use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.
the class GetLongNeighbor 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) {
nodeIdToNeighbors.put(nodeIds[i], ((LongArrayElement) neighbors[i]).getData());
} else {
nodeIdToNeighbors.put(nodeIds[i], Constents.emptyLongs);
}
}
}
return new GetLongsResult(nodeIdToNeighbors);
}
use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.
the class InitEdgeTypes method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
GeneralPartUpdateParam param = (GeneralPartUpdateParam) partParam;
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
ILongKeyAnyValuePartOp keyValuePart = (ILongKeyAnyValuePartOp) param.getKeyValuePart();
long[] nodeIds = keyValuePart.getKeys();
IElement[] neighbors = keyValuePart.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.setEdgeTypes(((EdgeType) neighbors[i]).getTypes());
}
} finally {
row.endWrite();
}
}
Aggregations