Search in sources :

Example 96 with PartitionKey

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

the class CompIntIntVectorSplitter method split.

@Override
public Map<PartitionKey, RowUpdateSplit> split(Vector vector, List<PartitionKey> parts) {
    IntIntVector[] vecParts = ((CompIntIntVector) vector).getPartitions();
    assert vecParts.length == parts.size();
    Map<PartitionKey, RowUpdateSplit> updateSplitMap = new HashMap<>(parts.size());
    for (int i = 0; i < vecParts.length; i++) {
        updateSplitMap.put(parts.get(i), new CompIntIntRowUpdateSplit(vector.getRowId(), vecParts[i], (int) (parts.get(i).getEndCol() - parts.get(i).getStartCol())));
    }
    return updateSplitMap;
}
Also used : CompIntIntRowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.CompIntIntRowUpdateSplit) HashMap(java.util.HashMap) IntIntVector(com.tencent.angel.ml.math2.vector.IntIntVector) CompIntIntVector(com.tencent.angel.ml.math2.vector.CompIntIntVector) PartitionKey(com.tencent.angel.PartitionKey) RowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.RowUpdateSplit) CompIntIntRowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.CompIntIntRowUpdateSplit) CompIntIntVector(com.tencent.angel.ml.math2.vector.CompIntIntVector)

Example 97 with PartitionKey

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

the class CompLongIntVectorSplitter method split.

@Override
public Map<PartitionKey, RowUpdateSplit> split(Vector vector, List<PartitionKey> parts) {
    LongIntVector[] vecParts = ((CompLongIntVector) vector).getPartitions();
    assert vecParts.length == parts.size();
    Map<PartitionKey, RowUpdateSplit> updateSplitMap = new HashMap<>(parts.size());
    for (int i = 0; i < vecParts.length; i++) {
        updateSplitMap.put(parts.get(i), new CompLongIntRowUpdateSplit(vector.getRowId(), vecParts[i]));
    }
    return updateSplitMap;
}
Also used : LongIntVector(com.tencent.angel.ml.math2.vector.LongIntVector) CompLongIntVector(com.tencent.angel.ml.math2.vector.CompLongIntVector) HashMap(java.util.HashMap) PartitionKey(com.tencent.angel.PartitionKey) RowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.RowUpdateSplit) CompLongIntRowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.CompLongIntRowUpdateSplit) CompLongIntVector(com.tencent.angel.ml.math2.vector.CompLongIntVector) CompLongIntRowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.CompLongIntRowUpdateSplit)

Example 98 with PartitionKey

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

the class GetColumnParam method split.

@Override
public List<PartitionGetParam> split() {
    List<PartitionKey> pkeys = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    List<PartitionGetParam> partParams = new ArrayList<PartitionGetParam>(pkeys.size());
    for (PartitionKey entry : pkeys) {
        partParams.add(new PartitionGetRowsParam(matrixId, entry, columns));
    }
    return partParams;
}
Also used : PartitionGetRowsParam(com.tencent.angel.ml.matrix.psf.get.getrows.PartitionGetRowsParam) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)

Example 99 with PartitionKey

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

the class GetPartFunc method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    if (partParam instanceof PartitionGetRowsParam) {
        PartitionGetRowsParam param = (PartitionGetRowsParam) partParam;
        PartitionKey pkey = param.getPartKey();
        pkey = psContext.getMatrixMetaManager().getMatrixMeta(pkey.getMatrixId()).getPartitionMeta(pkey.getPartitionId()).getPartitionKey();
        int ws = pkey.getStartRow();
        int es = pkey.getEndRow();
        List<Integer> reqRows = param.getRowIndexes();
        MatrixStorageManager manager = psContext.getMatrixStorageManager();
        List<ServerRow> rows = new ArrayList<>();
        for (int w : reqRows) rows.add(manager.getRow(pkey, w));
        PartCSRResult csr = new PartCSRResult(rows);
        return csr;
    } else {
        return null;
    }
}
Also used : PartitionGetRowsParam(com.tencent.angel.ml.matrix.psf.get.getrows.PartitionGetRowsParam) MatrixStorageManager(com.tencent.angel.ps.storage.MatrixStorageManager) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow)

Example 100 with PartitionKey

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

the class LikelihoodParam method split.

@Override
public List<PartitionGetParam> split() {
    List<PartitionGetParam> params = new ArrayList<>();
    List<PartitionKey> pkeys = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    for (PartitionKey pkey : pkeys) {
        params.add(new LikelihoodPartParam(matrixId, pkey, beta));
    }
    return params;
}
Also used : ArrayList(java.util.ArrayList) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam) PartitionKey(com.tencent.angel.PartitionKey)

Aggregations

PartitionKey (com.tencent.angel.PartitionKey)170 ArrayList (java.util.ArrayList)58 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)40 PartitionGetParam (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)28 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)24 PartitionUpdateParam (com.tencent.angel.ml.matrix.psf.update.base.PartitionUpdateParam)22 HashMap (java.util.HashMap)20 ByteBuf (io.netty.buffer.ByteBuf)14 KeyPart (com.tencent.angel.psagent.matrix.transport.router.KeyPart)12 FutureResult (com.tencent.angel.psagent.matrix.transport.FutureResult)10 RowUpdateSplit (com.tencent.angel.psagent.matrix.oplog.cache.RowUpdateSplit)9 MatrixTransportClient (com.tencent.angel.psagent.matrix.transport.MatrixTransportClient)9 KeyValuePart (com.tencent.angel.psagent.matrix.transport.router.KeyValuePart)9 Test (org.junit.Test)9 MapResponseCache (com.tencent.angel.psagent.matrix.transport.response.MapResponseCache)7 ResponseCache (com.tencent.angel.psagent.matrix.transport.response.ResponseCache)7 Map (java.util.Map)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6 AngelException (com.tencent.angel.exception.AngelException)5 CompStreamKeyValuePart (com.tencent.angel.psagent.matrix.transport.router.CompStreamKeyValuePart)5