use of com.tencent.angel.ps.impl.matrix.ServerPartition in project angel by Tencent.
the class PS2PSPusherImpl method recover.
@Override
public FutureResult<Response> recover(final RecoverPartKey partKey) {
FutureResult<Response> result = new FutureResult<>();
workerPool.execute(() -> {
ServerPartition part = context.getMatrixStorageManager().getPart(partKey.partKey.getMatrixId(), partKey.partKey.getPartitionId());
if (part == null) {
result.set(new Response(ResponseType.UNKNOWN_ERROR, "Can not find partition " + partKey.partKey.getMatrixId() + ":" + partKey.partKey.getPartitionId()));
return;
}
try {
part.waitAndSetReadOnly();
result.set(psClient.recoverPart(partKey.psLoc.psId, partKey.psLoc.loc, part).get());
} catch (Throwable e) {
result.set(new Response(ResponseType.NETWORK_ERROR, e.getMessage()));
LOG.error("handle recover event " + partKey + " failed ", e);
} finally {
part.setState(PartitionState.READ_AND_WRITE);
LOG.info("ps " + context.getPSAttemptId() + " set partition " + part.getPartitionKey() + " to " + part.getState());
}
});
return result;
}
use of com.tencent.angel.ps.impl.matrix.ServerPartition in project angel by Tencent.
the class ArrayAggrFunc method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partKey) {
ServerPartition part = psContext.getMatrixStorageManager().getPart(partKey.getMatrixId(), partKey.getPartKey().getPartitionId());
if (part != null) {
int rowId = ((ArrayAggrParam.ArrayPartitionAggrParam) partKey).getRowId();
if (Utils.withinPart(part.getPartitionKey(), new int[] { rowId })) {
ServerRow row = part.getRow(rowId);
long[] colsParam = ((ArrayAggrParam.ArrayPartitionAggrParam) partKey).getCols();
List<Map.Entry<Long, Double>> result = processRow(row, colsParam);
long[] cols = new long[result.size()];
double[] values = new double[result.size()];
for (int i = 0; i < result.size(); i++) {
cols[i] = result.get(i).getKey();
values[i] = result.get(i).getValue();
}
return new ArrayPartitionAggrResult(cols, values);
}
}
return null;
}
use of com.tencent.angel.ps.impl.matrix.ServerPartition in project angel by Tencent.
the class MultiAggrFunc method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partKey) {
ServerPartition part = psContext.getMatrixStorageManager().getPart(partKey.getMatrixId(), partKey.getPartKey().getPartitionId());
int[] rowIds = ((MultiAggrParam.MultiPartitionAggrParam) partKey).getRowIds();
double[] result = null;
if (Utils.withinPart(partKey.getPartKey(), rowIds)) {
if (part != null) {
ServerRow[] rows = new ServerRow[rowIds.length];
for (int i = 0; i < rowIds.length; i++) {
rows[i] = part.getRow(rowIds[i]);
}
result = processRows(rows);
}
}
return new ArrayPartitionAggrResult(result);
}
use of com.tencent.angel.ps.impl.matrix.ServerPartition in project angel by Tencent.
the class FullUpdateFunc method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
if (part != null) {
FullUpdateParam.FullPartitionUpdateParam ff = (FullUpdateParam.FullPartitionUpdateParam) partParam;
update(part, partParam.getPartKey(), ff.getValues());
}
}
use of com.tencent.angel.ps.impl.matrix.ServerPartition in project angel by Tencent.
the class MUpdateFunc method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
if (part != null) {
MUpdateParam.MPartitionUpdateParam m = (MUpdateParam.MPartitionUpdateParam) partParam;
int[] rowIds = m.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);
}
}
}
Aggregations