use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.
the class MatrixUtils method getRow.
public static ServerRow getRow(MatrixStorageManager storageManager, int matrixId, int partId, int rowId) {
ServerMatrix matrix = storageManager.getMatrix(matrixId);
if (matrix == null) {
throw new ObjectNotFoundException("Can not find matrix " + matrixId);
}
ServerPartition part = matrix.getPartition(partId);
if (part == null) {
throw new ObjectNotFoundException("Can not find partition " + partId + " of matrix " + matrixId);
}
if (!(part instanceof RowBasedPartition)) {
throw new UnsupportedOperationException("Get row only support for RowBasedPartition");
}
ServerRow row = ((RowBasedPartition) part).getRow(rowId);
if (row == null) {
throw new ObjectNotFoundException("Can not find row " + rowId + " of matrix " + matrixId + " in partition " + partId);
}
return row;
}
use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.
the class Add method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
PartIncrementRowsParam param = (PartIncrementRowsParam) partParam;
List<RowUpdateSplit> updates = param.getUpdates();
for (RowUpdateSplit update : updates) {
ServerRow row = psContext.getMatrixStorageManager().getRow(param.getPartKey(), update.getRowId());
row.startWrite();
try {
Vector vector = getVector(param.getMatrixId(), update.getRowId(), param.getPartKey());
vector.iadd(update.getVector());
} finally {
row.endWrite();
}
}
}
use of com.tencent.angel.ps.storage.vector.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.storage.vector.ServerRow in project angel by Tencent.
the class LikelihoodFunc method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
PartitionKey pkey = partParam.getPartKey();
pkey = psContext.getMatrixMetaManager().getMatrixMeta(pkey.getMatrixId()).getPartitionMeta(pkey.getPartitionId()).getPartitionKey();
int ws = pkey.getStartRow();
int es = pkey.getEndRow();
if (partParam instanceof LikelihoodParam.LikelihoodPartParam) {
LikelihoodParam.LikelihoodPartParam param = (LikelihoodParam.LikelihoodPartParam) partParam;
float beta = param.getBeta();
double lgammaBeta = Gamma.logGamma(beta);
double ll = 0;
for (int w = ws; w < es; w++) {
ServerRow row = psContext.getMatrixStorageManager().getRow(pkey, w);
try {
row.startRead();
ll += likelihood((ServerIntIntRow) row, beta, lgammaBeta);
} finally {
row.endRead();
}
}
return new ScalarPartitionAggrResult(ll);
} else {
throw new AngelException("Should be LikelihoodParam.LikelihoodPartParam");
}
}
use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.
the class ResetFunc method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
RowBasedPartition part = (RowBasedPartition) psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
if (part != null) {
int startRow = part.getPartitionKey().getStartRow();
int endRow = part.getPartitionKey().getEndRow();
for (int i = startRow; i < endRow; i++) {
ServerRow row = part.getRow(i);
if (row == null) {
continue;
}
row.reset();
// reset(row);
}
}
}
Aggregations