use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.
the class LongElementMapStorage method deserialize.
@Override
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
// Valid element number
int elementNum = buf.readInt();
data = new Long2ObjectOpenHashMap<>(elementNum);
// Deserialize the data
for (int i = 0; i < elementNum; i++) {
IElement element = newElement();
data.put(buf.readLong(), element);
element.deserialize(buf);
}
}
use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.
the class LongElementMapStorage method deserialize.
@Override
public void deserialize(DataInputStream input) throws IOException {
super.deserialize(input);
// Valid element number
int elementNum = input.readInt();
data = new Long2ObjectOpenHashMap<>(elementNum);
// Deserialize the data
for (int i = 0; i < elementNum; i++) {
IElement element = newElement();
data.put(input.readLong(), element);
element.deserialize(input);
}
}
use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.
the class GetAliasTableWithTrunc method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
int resultSize = 0;
for (PartitionGetResult result : partResults) {
resultSize += ((PartGeneralGetResult) result).getNodeIds().length;
}
Long2ObjectOpenHashMap<Tuple3<long[], float[], int[]>> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(resultSize);
for (PartitionGetResult result : partResults) {
PartGeneralGetResult partResult = (PartGeneralGetResult) result;
long[] nodeIds = partResult.getNodeIds();
IElement[] data = partResult.getData();
for (int i = 0; i < nodeIds.length; i++) {
if (data[i] != null) {
long[] neighbors = ((AliasElement) data[i]).getNeighborIds();
float[] accept = ((AliasElement) data[i]).getAccept();
int[] alias = ((AliasElement) data[i]).getAlias();
if (neighbors.length > 0 && accept.length > 0 && alias.length > 0) {
nodeIdToNeighbors.put(nodeIds[i], new Tuple3<>(neighbors, accept, alias));
} else {
nodeIdToNeighbors.put(nodeIds[i], emp);
}
} else {
nodeIdToNeighbors.put(nodeIds[i], emp);
}
}
}
return new PullAliasResult(nodeIdToNeighbors);
}
use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.
the class InitNodes 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[] featuress = split.getValues();
row.startWrite();
try {
for (int i = 0; i < nodeIds.length; i++) {
row.set(nodeIds[i], featuress[i]);
}
} finally {
row.endWrite();
}
}
use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.
the class InitLabels 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.setLabels(((Labels) neighbors[i]).getWeights());
}
} finally {
row.endWrite();
}
}
Aggregations