Search in sources :

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

Example 2 with Int2ObjectArrayMap

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);
}
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) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 3 with Int2ObjectArrayMap

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);
}
Also used : Long2LongOpenHashMap(it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap) Int2ObjectArrayMap(it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap)

Example 4 with Int2ObjectArrayMap

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);
}
Also used : Long2IntOpenHashMap(it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap) Int2ObjectArrayMap(it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap)

Example 5 with Int2ObjectArrayMap

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);
}
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