use of com.tencent.angel.ps.impl.matrix.ServerRow in project angel by Tencent.
the class BinaryAggrFunc method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partKey) {
ServerPartition part = psContext.getMatrixStorageManager().getPart(partKey.getMatrixId(), partKey.getPartKey().getPartitionId());
int rowId1 = ((BinaryAggrParam.BinaryPartitionAggrParam) partKey).getRowId1();
int rowId2 = ((BinaryAggrParam.BinaryPartitionAggrParam) partKey).getRowId2();
if (Utils.withinPart(partKey.getPartKey(), new int[] { rowId1, rowId2 })) {
if (part != null) {
ServerRow row1 = part.getRow(rowId1);
ServerRow row2 = part.getRow(rowId2);
if (row1 != null && row2 != null) {
double result = processRows(row1, row2);
return new ScalarPartitionAggrResult(result);
}
}
}
return null;
}
use of com.tencent.angel.ps.impl.matrix.ServerRow in project angel by Tencent.
the class UnaryAggrFunc method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partKey) {
ServerPartition part = psContext.getMatrixStorageManager().getPart(partKey.getMatrixId(), partKey.getPartKey().getPartitionId());
if (part != null) {
int rowId = ((UnaryAggrParam.UnaryPartitionAggrParam) partKey).getRowId();
if (Utils.withinPart(part.getPartitionKey(), new int[] { rowId })) {
ServerRow row = part.getRow(rowId);
double result = processRow(row);
return new ScalarPartitionAggrResult(result);
}
}
return null;
}
use of com.tencent.angel.ps.impl.matrix.ServerRow in project angel by Tencent.
the class Utils method pick.
public static ArrayList<Map.Entry<ServerRow, ArrayList<Integer>>> pick(ServerRow[] serverRows, Long[] rows, Long[] cols, Double[] values) {
assert (rows.length == cols.length && rows.length == values.length);
ArrayList<Map.Entry<ServerRow, ArrayList<Integer>>> result = new ArrayList<>();
for (ServerRow row : serverRows) {
long rowId = row.getRowId();
long startCol = row.getStartCol();
long endCol = row.getEndCol();
ArrayList<Integer> indics = new ArrayList<Integer>();
for (int i = 0; i <= rows.length; i++) {
if (rowId == rows[i] && cols[i] >= startCol && cols[i] < endCol) {
indics.add(i);
}
}
Map.Entry<ServerRow, ArrayList<Integer>> pair = new java.util.AbstractMap.SimpleEntry<>(row, indics);
result.add(pair);
}
return result;
}
use of com.tencent.angel.ps.impl.matrix.ServerRow in project angel by Tencent.
the class CompressUpdateFunc method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
if (part != null) {
CompressUpdateParam.CompressPartitionUpdateParam cp = (CompressUpdateParam.CompressPartitionUpdateParam) partParam;
ServerRow row = part.getRow(cp.getRowId());
if (row != null) {
update(row, cp.getArraySlice());
}
}
}
use of com.tencent.angel.ps.impl.matrix.ServerRow in project angel by Tencent.
the class MFUpdateFunc method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
if (part != null) {
MFUpdateParam.MFPartitionUpdateParam mf = (MFUpdateParam.MFPartitionUpdateParam) partParam;
int[] rowIds = mf.getRowIds();
if (Utils.withinPart(partParam.getPartKey(), rowIds)) {
ServerRow[] rows = new ServerRow[rowIds.length];
for (int i = 0; i < rowIds.length; i++) {
rows[i] = part.getRow(rowIds[i]);
}
update(rows, mf.getFunc());
}
}
}
Aggregations