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;
}
}
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;
}
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;
}
}
Aggregations