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) {
SampleNeighborParam param = (SampleNeighborParam) getParam();
long[] keys = param.getKeys();
Int2ObjectArrayMap<PartitionGetResult> partIdToResult = new Int2ObjectArrayMap<>();
for (PartitionGetResult result : partResults) {
partIdToResult.put(((SampleNeighborPartResult) result).getPartId(), result);
}
for (PartitionGetParam partParam : param.getParams()) {
SampleNeighborPartParam param0 = (SampleNeighborPartParam) partParam;
int start = param0.getStartIndex();
int end = param0.getEndIndex();
SampleNeighborPartResult result = (SampleNeighborPartResult) partIdToResult.get(param0.getPartKey().getPartitionId());
int[] indptr = result.getIndptr();
long[] neighbors = result.getNeighbors();
int[] sampleTypes = result.getTypes();
assert indptr.length == (end - start) + 1;
for (int i = start; i < end; i++) {
int keyIndex = index.get(keys[i]);
for (int j = indptr[i - start]; j < indptr[i - start + 1]; j++) {
long n = neighbors[j];
if (!index.containsKey(n)) {
index.put(n, index.size());
}
srcs.add(keyIndex);
dsts.add(index.get(n));
}
if (param.getSampleTypes()) {
for (int j = indptr[i - start]; j < indptr[i - start + 1]; j++) {
types.add(sampleTypes[j]);
}
}
}
}
return new ScalarAggrResult(0);
}
use of it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap in project angel by Tencent.
the class GetNodeFeats method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
for (PartitionGetResult result : partResults) {
partIdToResultMap.put(((PartGetNodeFeatsResult) result).getPartId(), result);
}
GetNodeFeatsParam param = (GetNodeFeatsParam) getParam();
long[] nodeIds = param.getNodeIds();
List<PartitionGetParam> partParams = param.getPartParams();
Long2ObjectOpenHashMap<IntFloatVector> results = new Long2ObjectOpenHashMap<>(nodeIds.length);
int size = partResults.size();
for (int i = 0; i < size; i++) {
PartGetNodeFeatsParam partParam = (PartGetNodeFeatsParam) partParams.get(i);
PartGetNodeFeatsResult partResult = (PartGetNodeFeatsResult) partIdToResultMap.get(partParam.getPartKey().getPartitionId());
int start = partParam.getStartIndex();
int end = partParam.getEndIndex();
IntFloatVector[] feats = partResult.getFeats();
for (int j = start; j < end; j++) {
if (feats[j - start] != null) {
results.put(nodeIds[j], feats[j - start]);
}
}
}
return new GetNodeFeatsResult(results);
}
use of it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap in project angel by Tencent.
the class GetNumNeighborEdgesFunc method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
for (PartitionGetResult result : partResults) {
partIdToResultMap.put(((PartGetNumNeighborEdgesResult) result).getPartId(), result);
}
GetNumNeighborEdgesParam param = (GetNumNeighborEdgesParam) getParam();
long[] nodeIds = param.getNodeIds();
List<PartitionGetParam> partParams = param.getPartParams();
Long2LongOpenHashMap nodeIdToNumEdges = new Long2LongOpenHashMap(nodeIds.length);
for (PartitionGetParam partParam : partParams) {
int start = ((PartGetNumNeighborEdgesParam) partParam).getStartIndex();
int end = ((PartGetNumNeighborEdgesParam) partParam).getEndIndex();
PartGetNumNeighborEdgesResult partResult = (PartGetNumNeighborEdgesResult) (partIdToResultMap.get(partParam.getPartKey().getPartitionId()));
long[] results = partResult.getNodeIdToNumEdges();
for (int i = start; i < end; i++) {
nodeIdToNumEdges.put(nodeIds[i], results[i - start]);
}
}
return new GetNumNeighborEdgesResult(nodeIdToNumEdges);
}
use of it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap in project angel by Tencent.
the class GetOutDegreeFunc method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
for (PartitionGetResult result : partResults) {
partIdToResultMap.put(((PartGetOutDegreeResult) result).getPartId(), result);
}
GetOutDegreeParam param = (GetOutDegreeParam) getParam();
long[] nodeIds = param.getNodeIds();
List<PartitionGetParam> partParams = param.getPartParams();
Long2IntOpenHashMap nodeIdToDegree = new Long2IntOpenHashMap(nodeIds.length);
for (PartitionGetParam partParam : partParams) {
int start = ((PartGetOutDegreeParam) partParam).getStartIndex();
int end = ((PartGetOutDegreeParam) partParam).getEndIndex();
PartGetOutDegreeResult partResult = (PartGetOutDegreeResult) (partIdToResultMap.get(partParam.getPartKey().getPartitionId()));
int[] results = partResult.getNodeIdToOutDegree();
for (int i = start; i < end; i++) {
nodeIdToDegree.put(nodeIds[i], results[i - start]);
}
}
return new GetOutDegreeResult(nodeIdToDegree);
}
use of it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap in project angel by Tencent.
the class GetNeighborAliasTable method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
for (PartitionGetResult result : partResults) {
partIdToResultMap.put(((PartGetNeighborAliasTableResult) result).getPartId(), result);
}
GetNeighborAliasTableParam param = (GetNeighborAliasTableParam) getParam();
long[] nodeIds = param.getNodeIds();
List<PartitionGetParam> partParams = param.getPartParams();
Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(nodeIds.length);
for (PartitionGetParam partParam : partParams) {
int start = ((PartGetNeighborAliasTableParam) partParam).getStartIndex();
int end = ((PartGetNeighborAliasTableParam) partParam).getEndIndex();
PartGetNeighborAliasTableResult partResult = (PartGetNeighborAliasTableResult) (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 GetNeighborAliasTableResult(nodeIdToNeighbors);
}
Aggregations