Search in sources :

Example 51 with PartitionGetResult

use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.

the class NumNodes method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    long numNodes = 0;
    for (PartitionGetResult result : partResults) {
        if (result instanceof ScalarPartitionAggrResult) {
            long value = (long) ((ScalarPartitionAggrResult) result).result;
            numNodes += value;
        }
    }
    return new NumNodesResult(numNodes);
}
Also used : ScalarPartitionAggrResult(com.tencent.angel.ml.matrix.psf.aggr.enhance.ScalarPartitionAggrResult) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 52 with PartitionGetResult

use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.

the class GetClosenessAndCardinality method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    Long2ObjectOpenHashMap<Tuple3<Double, Long, Long>> closenesses = new Long2ObjectOpenHashMap<>();
    for (PartitionGetResult r : partResults) {
        GetClosenessAndCardinalityPartResult rr = (GetClosenessAndCardinalityPartResult) r;
        closenesses.putAll(rr.getClosenesses());
    }
    return new GetClosenessAndCardinalityResult(closenesses);
}
Also used : Tuple3(scala.Tuple3) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 53 with PartitionGetResult

use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.

the class GetLabels method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    int size = 0;
    for (PartitionGetResult result : partResults) {
        size += ((GetLabelsPartResult) result).size();
    }
    long dim = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId).getColNum();
    LongFloatVector vector = VFactory.sparseLongKeyFloatVector(dim, size);
    for (PartitionGetResult result : partResults) {
        GetLabelsPartResult r = (GetLabelsPartResult) result;
        long[] keys = r.getKeys();
        float[] vals = r.getValues();
        assert (keys.length == vals.length);
        for (int i = 0; i < keys.length; i++) {
            vector.set(keys[i], vals[i]);
        }
    }
    return new GetLabelsResult(vector);
}
Also used : LongFloatVector(com.tencent.angel.ml.math2.vector.LongFloatVector) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 54 with PartitionGetResult

use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult 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)

Example 55 with PartitionGetResult

use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.

the class GetByteNeighbor 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[] data = partResult.getData();
        for (int i = 0; i < nodeIds.length; i++) {
            if (data[i] != null) {
                byte[] serializedNeighbors = ((ByteArrayElement) data[i]).getData();
                if (serializedNeighbors.length > 0) {
                    nodeIdToNeighbors.put(nodeIds[i], ScalaKryoInstantiator.defaultPool().fromBytes(serializedNeighbors, long[].class));
                } else {
                    nodeIdToNeighbors.put(nodeIds[i], emptyLongs);
                }
            } else {
                nodeIdToNeighbors.put(nodeIds[i], emptyLongs);
            }
        }
    }
    return new GetLongsResult(nodeIdToNeighbors);
}
Also used : IElement(com.tencent.angel.ps.storage.vector.element.IElement) PartGeneralGetResult(com.tencent.angel.graph.model.general.get.PartGeneralGetResult) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) ByteArrayElement(com.tencent.angel.ps.storage.vector.element.ByteArrayElement) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult) GetLongsResult(com.tencent.angel.graph.common.psf.result.GetLongsResult)

Aggregations

PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)60 PartitionKey (com.tencent.angel.PartitionKey)24 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)18 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)12 PartitionGetParam (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)6 IElement (com.tencent.angel.ps.storage.vector.element.IElement)6 Int2ObjectArrayMap (it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap)6 GetLongsResult (com.tencent.angel.graph.common.psf.result.GetLongsResult)5 PartGeneralGetResult (com.tencent.angel.graph.model.general.get.PartGeneralGetResult)5 AngelException (com.tencent.angel.exception.AngelException)2 GetFunc (com.tencent.angel.ml.matrix.psf.get.base.GetFunc)2 GetRowResult (com.tencent.angel.ml.matrix.psf.get.getrow.GetRowResult)2 IndexPartGetLongResult (com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult)2 GetUDFRequest (com.tencent.angel.ps.server.data.request.GetUDFRequest)2 Request (com.tencent.angel.ps.server.data.request.Request)2 GetUDFResponse (com.tencent.angel.ps.server.data.response.GetUDFResponse)2 RowBasedPartition (com.tencent.angel.ps.storage.partition.RowBasedPartition)2 UserRequest (com.tencent.angel.psagent.matrix.transport.adapter.UserRequest)2 Tuple3 (scala.Tuple3)2 HyperLogLogPlus (com.clearspring.analytics.stream.cardinality.HyperLogLogPlus)1