Search in sources :

Example 26 with PartitionKey

use of com.tencent.angel.PartitionKey in project angel by Tencent.

the class ValuesCombineUtils method mergeSparseFloatCompVector.

public static CompSparseFloatVector mergeSparseFloatCompVector(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();
    SparseFloatVector[] splitVecs = new SparseFloatVector[size];
    for (int i = 0; i < size; i++) {
        if (param.getPartKeyToIndexesMap().containsKey(partKeys.get(i))) {
            splitVecs[i] = new SparseFloatVector((int) meta.getColNum(), param.getPartKeyToIndexesMap().get(partKeys.get(i)), ((IndexPartGetFloatResult) partKeyToResultMap.get(partKeys.get(i))).getValues());
        }
    }
    return new CompSparseFloatVector(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 27 with PartitionKey

use of com.tencent.angel.PartitionKey in project angel by Tencent.

the class ValuesCombineUtils method mergeSparseDoubleCompVector.

public static CompSparseLongKeyDoubleVector mergeSparseDoubleCompVector(LongIndexGetParam 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();
    SparseLongKeyDoubleVector[] splitVecs = new SparseLongKeyDoubleVector[size];
    for (int i = 0; i < size; i++) {
        if (param.getPartKeyToIndexesMap().containsKey(partKeys.get(i))) {
            splitVecs[i] = new SparseLongKeyDoubleVector(meta.getColNum(), param.getPartKeyToIndexesMap().get(partKeys.get(i)), ((LongIndexGetResult) partKeyToResultMap.get(partKeys.get(i))).getValues());
        }
    }
    CompSparseLongKeyDoubleVector vector = new CompSparseLongKeyDoubleVector(meta.getId(), param.getRowId(), meta.getColNum(), partKeys.toArray(new PartitionKey[0]), splitVecs);
    return vector;
}
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 28 with PartitionKey

use of com.tencent.angel.PartitionKey in project angel by Tencent.

the class ValuesCombineUtils method mergeSparseFloatVector.

public static SparseFloatVector mergeSparseFloatVector(IndexGetParam param, List<PartitionGetResult> partResults) {
    SparseFloatVector vector = new SparseFloatVector((int) PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.getMatrixId()).getColNum(), param.size());
    for (PartitionGetResult part : partResults) {
        PartitionKey partKey = ((IndexPartGetFloatResult) part).getPartKey();
        int[] indexes = param.getPartKeyToIndexesMap().get(partKey);
        float[] values = ((IndexPartGetFloatResult) part).getValues();
        for (int i = 0; i < indexes.length; i++) {
            vector.set(indexes[i], values[i]);
        }
    }
    vector.setMatrixId(param.getMatrixId());
    vector.setRowId(param.getRowId());
    return vector;
}
Also used : PartitionKey(com.tencent.angel.PartitionKey) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 29 with PartitionKey

use of com.tencent.angel.PartitionKey in project angel by Tencent.

the class ValuesCombineUtils method mergeSparseIntVector.

public static SparseIntVector mergeSparseIntVector(IndexGetParam param, List<PartitionGetResult> partResults) {
    SparseIntVector vector = new SparseIntVector((int) PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.getMatrixId()).getColNum(), param.size());
    for (PartitionGetResult part : partResults) {
        PartitionKey partKey = ((IndexPartGetIntResult) part).getPartKey();
        int[] indexes = param.getPartKeyToIndexesMap().get(partKey);
        int[] values = ((IndexPartGetIntResult) part).getValues();
        for (int i = 0; i < indexes.length; i++) {
            vector.set(indexes[i], values[i]);
        }
    }
    vector.setMatrixId(param.getMatrixId());
    vector.setRowId(param.getRowId());
    return vector;
}
Also used : PartitionKey(com.tencent.angel.PartitionKey) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 30 with PartitionKey

use of com.tencent.angel.PartitionKey in project angel by Tencent.

the class ValuesCombineUtils method mergeSparseDoubleVector.

public static SparseDoubleVector mergeSparseDoubleVector(IndexGetParam param, List<PartitionGetResult> partResults) {
    SparseDoubleVector vector = new SparseDoubleVector((int) PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.getMatrixId()).getColNum(), param.size());
    for (PartitionGetResult part : partResults) {
        PartitionKey partKey = ((IndexPartGetDoubleResult) part).getPartKey();
        int[] indexes = param.getPartKeyToIndexesMap().get(partKey);
        double[] values = ((IndexPartGetDoubleResult) part).getValues();
        for (int i = 0; i < indexes.length; i++) {
            vector.set(indexes[i], values[i]);
        }
    }
    vector.setMatrixId(param.getMatrixId());
    vector.setRowId(param.getRowId());
    return vector;
}
Also used : PartitionKey(com.tencent.angel.PartitionKey) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Aggregations

PartitionKey (com.tencent.angel.PartitionKey)80 ArrayList (java.util.ArrayList)17 ByteBuf (io.netty.buffer.ByteBuf)12 Test (org.junit.Test)9 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)8 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)7 PartitionGetParam (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)7 PartitionLocation (com.tencent.angel.ml.matrix.PartitionLocation)4 ServerRow (com.tencent.angel.ps.impl.matrix.ServerRow)4 ParameterServerId (com.tencent.angel.ps.ParameterServerId)3 RecoverPartKey (com.tencent.angel.ps.recovery.ha.RecoverPartKey)3 FutureResult (com.tencent.angel.psagent.matrix.transport.FutureResult)3 Map (java.util.Map)3 Location (com.tencent.angel.common.location.Location)2 TVector (com.tencent.angel.ml.math.TVector)2 RowType (com.tencent.angel.ml.matrix.RowType)2 PSLocation (com.tencent.angel.ml.matrix.transport.PSLocation)2 MatrixStorageManager (com.tencent.angel.ps.impl.MatrixStorageManager)2 ClockCache (com.tencent.angel.psagent.clock.ClockCache)2 Worker (com.tencent.angel.worker.Worker)2