use of com.tencent.angel.graph.model.general.get.PartGeneralGetResult 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.graph.model.general.get.PartGeneralGetResult in project angel by Tencent.
the class GetNodeAttrs method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
int resultSize = 0;
for (PartitionGetResult result : partResults) {
resultSize += ((PartGeneralGetResult) result).getNodeIds().length;
}
Long2ObjectOpenHashMap<float[]> nodeIdToAttrs = new Long2ObjectOpenHashMap<>(resultSize);
for (PartitionGetResult result : partResults) {
PartGeneralGetResult partResult = (PartGeneralGetResult) result;
long[] nodeIds = partResult.getNodeIds();
IElement[] attrs = partResult.getData();
for (int i = 0; i < nodeIds.length; i++) {
if (attrs[i] != null) {
nodeIdToAttrs.put(nodeIds[i], ((FloatArrayElement) attrs[i]).getData());
} else {
nodeIdToAttrs.put(nodeIds[i], emptyFloats);
}
}
}
return new GetFloatsResult(nodeIdToAttrs);
}
use of com.tencent.angel.graph.model.general.get.PartGeneralGetResult in project angel by Tencent.
the class GeneralGetUtils method partitionGet.
public static PartitionGetResult partitionGet(PSContext psContext, PartitionGetParam partParam) {
GeneralPartGetParam param = (GeneralPartGetParam) partParam;
KeyPart keyPart = param.getIndicesPart();
// Long type node id
long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
// Get data
IElement[] data = new IElement[nodeIds.length];
for (int i = 0; i < nodeIds.length; i++) {
data[i] = row.get(nodeIds[i]);
}
MatrixMeta meta = psContext.getMatrixMetaManager().getMatrixMeta(param.getMatrixId());
try {
return new PartGeneralGetResult(meta.getValueClass(), nodeIds, data);
} catch (ClassNotFoundException e) {
throw new AngelException("Can not get value class ");
}
}
use of com.tencent.angel.graph.model.general.get.PartGeneralGetResult 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.graph.model.general.get.PartGeneralGetResult 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);
}
Aggregations