Search in sources :

Example 56 with PartitionGetResult

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

the class GetCloseness method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    Long2DoubleOpenHashMap closenesses = new Long2DoubleOpenHashMap();
    for (PartitionGetResult r : partResults) {
        GetClosenessPartResult rr = (GetClosenessPartResult) r;
        closenesses.putAll(rr.getClosenesses());
    }
    return new GetClosenessResult(closenesses);
}
Also used : Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 57 with PartitionGetResult

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

the class FullPull method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    int endRow = -1;
    int endCol = -1;
    for (PartitionGetResult partResult : partResults) {
        FullPartitionAggrResult result = (FullPartitionAggrResult) partResult;
        int[] partInfo = result.getPartInfo();
        assert (partInfo.length == 4);
        if (endRow < partInfo[1])
            endRow = partInfo[1];
        if (endCol < partInfo[3])
            endCol = partInfo[3];
    }
    double[][] result = new double[endRow][endCol];
    for (PartitionGetResult partResult : partResults) {
        FullPartitionAggrResult aggrResult = (FullPartitionAggrResult) partResult;
        double[][] pResult = aggrResult.getResult();
        int[] partInfo = aggrResult.getPartInfo();
        int thisStartRow = partInfo[0];
        int thisEndRow = partInfo[1];
        int thisStartCol = partInfo[2];
        int thisEndCol = partInfo[3];
        int thisColSize = thisEndCol - thisStartCol;
        for (int i = 0; i < pResult.length; i++) {
            System.arraycopy(pResult[i], 0, result[thisStartRow + i], thisStartCol, thisColSize);
        }
    }
    return new FullAggrResult(result);
}
Also used : FullAggrResult(com.tencent.angel.ml.matrix.psf.aggr.enhance.FullAggrResult) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult) FullPartitionAggrResult(com.tencent.angel.ml.matrix.psf.aggr.enhance.FullPartitionAggrResult)

Example 58 with PartitionGetResult

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

the class PullWithCols method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    ArrayList<Long> cols = new ArrayList<>();
    ArrayList<Double> result = new ArrayList<>();
    for (PartitionGetResult part : partResults) {
        ArrayPartitionAggrResult partResult = (ArrayPartitionAggrResult) part;
        long[] keys = partResult.getCols();
        double[] values = partResult.getResult();
        assert (keys.length == values.length);
        for (int i = 0; i < keys.length; i++) {
            cols.add(keys[i]);
            result.add(values[i]);
        }
    }
    return new ArrayAggrResult(Utils.longListToArray(cols), Utils.doubleListToArray(result));
}
Also used : ArrayPartitionAggrResult(com.tencent.angel.ml.matrix.psf.aggr.enhance.ArrayPartitionAggrResult) ArrayAggrResult(com.tencent.angel.ml.matrix.psf.aggr.enhance.ArrayAggrResult) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 59 with PartitionGetResult

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

the class ValuesCombineUtils method mergeSparseDoubleCompVector.

public static CompSparseDoubleVector mergeSparseDoubleCompVector(IndexGetParam param, List<PartitionGetResult> partResults) {
    Map<PartitionKey, PartitionGetResult> partKeyToResultMap = mapPartKeyToResult(partResults);
    List<PartitionKey> partKeys = getSortedPartKeys(param.matrixId, param.getRowId());
    MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.matrixId);
    int size = partKeys.size();
    SparseDoubleVector[] splitVecs = new SparseDoubleVector[size];
    for (int i = 0; i < size; i++) {
        if (param.getPartKeyToIndexesMap().containsKey(partKeys.get(i))) {
            splitVecs[i] = new SparseDoubleVector((int) meta.getColNum(), param.getPartKeyToIndexesMap().get(partKeys.get(i)), ((IndexPartGetDoubleResult) partKeyToResultMap.get(partKeys.get(i))).getValues());
        }
    }
    return new CompSparseDoubleVector(meta.getId(), param.getRowId(), (int) meta.getColNum(), partKeys.toArray(new PartitionKey[0]), splitVecs);
}
Also used : MatrixMeta(com.tencent.angel.ml.matrix.MatrixMeta) PartitionKey(com.tencent.angel.PartitionKey) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 60 with PartitionGetResult

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

the class ValuesCombineUtils method mergeSparseIntCompVector.

public static CompSparseIntVector mergeSparseIntCompVector(IndexGetParam param, List<PartitionGetResult> partResults) {
    Map<PartitionKey, PartitionGetResult> partKeyToResultMap = mapPartKeyToResult(partResults);
    List<PartitionKey> partKeys = getSortedPartKeys(param.matrixId, param.getRowId());
    MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.matrixId);
    int size = partKeys.size();
    SparseIntVector[] splitVecs = new SparseIntVector[size];
    for (int i = 0; i < size; i++) {
        if (param.getPartKeyToIndexesMap().containsKey(partKeys.get(i))) {
            splitVecs[i] = new SparseIntVector((int) meta.getColNum(), param.getPartKeyToIndexesMap().get(partKeys.get(i)), ((IndexPartGetIntResult) partKeyToResultMap.get(partKeys.get(i))).getValues());
        }
    }
    return new CompSparseIntVector(meta.getId(), param.getRowId(), (int) meta.getColNum(), partKeys.toArray(new PartitionKey[0]), splitVecs);
}
Also used : MatrixMeta(com.tencent.angel.ml.matrix.MatrixMeta) PartitionKey(com.tencent.angel.PartitionKey) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

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