Search in sources :

Example 1 with PartitionGetRowsParam

use of com.tencent.angel.ml.matrix.psf.get.getrows.PartitionGetRowsParam in project angel by Tencent.

the class GetColumnFunc 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();
        List<Integer> reqCols = param.getRowIndexes();
        int start = reqCols.get(0);
        int end = reqCols.get(1);
        MatrixStorageManager manager = psContext.getMatrixStorageManager();
        Map<Integer, Int2IntOpenHashMap> cks = new HashMap();
        for (int col = start; col < end; col++) cks.put(col, new Int2IntOpenHashMap());
        int rowOffset = pkey.getStartRow();
        int rowLength = pkey.getEndRow();
        for (int r = rowOffset; r < rowLength; r++) {
            ServerRow row = manager.getRow(pkey, r);
            if (row instanceof ServerIntIntRow) {
                for (int col = start; col < end; col++) {
                    Int2IntOpenHashMap map = cks.get(col);
                    int k = ((ServerIntIntRow) row).get(col);
                    if (k > 0)
                        map.put(row.getRowId(), k);
                }
            }
        }
        return new PartColumnResult(cks);
    } else {
        return null;
    }
}
Also used : Int2IntOpenHashMap(it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap) HashMap(java.util.HashMap) PartitionGetRowsParam(com.tencent.angel.ml.matrix.psf.get.getrows.PartitionGetRowsParam) MatrixStorageManager(com.tencent.angel.ps.storage.MatrixStorageManager) PartitionKey(com.tencent.angel.PartitionKey) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow) ServerIntIntRow(com.tencent.angel.ps.storage.vector.ServerIntIntRow) Int2IntOpenHashMap(it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap)

Example 2 with PartitionGetRowsParam

use of com.tencent.angel.ml.matrix.psf.get.getrows.PartitionGetRowsParam 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 3 with PartitionGetRowsParam

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

Aggregations

PartitionKey (com.tencent.angel.PartitionKey)3 PartitionGetRowsParam (com.tencent.angel.ml.matrix.psf.get.getrows.PartitionGetRowsParam)3 MatrixStorageManager (com.tencent.angel.ps.storage.MatrixStorageManager)2 ServerRow (com.tencent.angel.ps.storage.vector.ServerRow)2 ArrayList (java.util.ArrayList)2 PartitionGetParam (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)1 ServerIntIntRow (com.tencent.angel.ps.storage.vector.ServerIntIntRow)1 Int2IntOpenHashMap (it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap)1 HashMap (java.util.HashMap)1