Search in sources :

Example 6 with Int2ObjectArrayMap

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);
}
Also used : Int2ObjectArrayMap(it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 7 with Int2ObjectArrayMap

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);
}
Also used : Int2ObjectArrayMap(it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 8 with Int2ObjectArrayMap

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);
}
Also used : Int2ObjectArrayMap(it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Aggregations

Int2ObjectArrayMap (it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap)8 PartitionGetParam (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)6 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)6 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)5 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)1 ScalarAggrResult (com.tencent.angel.ml.matrix.psf.aggr.enhance.ScalarAggrResult)1 Long2IntOpenHashMap (it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap)1 Long2LongOpenHashMap (it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap)1