use of it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap in project angel by Tencent.
the class GetNodeAttrs method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
for (PartitionGetResult result : partResults) {
partIdToResultMap.put(((PartGetNodeAttrsResult) result).getPartId(), result);
}
GetNodeAttrsParam param = (GetNodeAttrsParam) getParam();
long[] nodeIds = param.getNodeIds();
List<PartitionGetParam> partParams = param.getPartParams();
Long2ObjectOpenHashMap<float[]> nodeIdToAttrs = new Long2ObjectOpenHashMap<>(nodeIds.length);
for (PartitionGetParam partParam : partParams) {
int start = ((PartGetNodeAttrsParam) partParam).getStartIndex();
int end = ((PartGetNodeAttrsParam) partParam).getEndIndex();
PartGetNodeAttrsResult partResult = (PartGetNodeAttrsResult) (partIdToResultMap.get(partParam.getPartKey().getPartitionId()));
float[][] results = partResult.getNodeIdToAttrs();
for (int i = start; i < end; i++) {
nodeIdToAttrs.put(nodeIds[i], results[i - start]);
}
}
return new GetNodeAttrsResult(nodeIdToAttrs);
}
use of it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap in project angel by Tencent.
the class SampleNeighbor method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
for (PartitionGetResult result : partResults) {
partIdToResultMap.put(((PartSampleNeighborResult) result).getPartId(), result);
}
SampleNeighborParam param = (SampleNeighborParam) getParam();
long[] nodeIds = param.getNodeIds();
List<PartitionGetParam> partParams = param.getPartParams();
Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(nodeIds.length);
for (PartitionGetParam partParam : partParams) {
int start = ((PartSampleNeighborParam) partParam).getStartIndex();
int end = ((PartSampleNeighborParam) partParam).getEndIndex();
PartSampleNeighborResult partResult = (PartSampleNeighborResult) (partIdToResultMap.get(partParam.getPartKey().getPartitionId()));
long[][] results = partResult.getNodeIdToNeighbors();
for (int i = start; i < end; i++) {
nodeIdToNeighbors.put(nodeIds[i], results[i - start]);
}
}
return new SampleNeighborResult(nodeIdToNeighbors);
}
use of it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap in project angel by Tencent.
the class SampleNeighbor method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
for (PartitionGetResult result : partResults) {
partIdToResultMap.put(((PartSampleNeighborResult) result).getPartId(), result);
}
SampleNeighborParam param = (SampleNeighborParam) getParam();
long[] nodeIds = param.getNodeIds();
List<PartitionGetParam> partParams = param.getPartParams();
Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(nodeIds.length);
for (PartitionGetParam partParam : partParams) {
int start = ((PartSampleNeighborParam) partParam).getStartIndex();
int end = ((PartSampleNeighborParam) partParam).getEndIndex();
PartSampleNeighborResult partResult = (PartSampleNeighborResult) (partIdToResultMap.get(partParam.getPartKey().getPartitionId()));
long[][] results = partResult.getNodeIdToNeighbors();
for (int i = start; i < end; i++) {
nodeIdToNeighbors.put(nodeIds[i], results[i - start]);
}
}
return new SampleNeighborResult(nodeIdToNeighbors);
}
Aggregations