use of com.tencent.angel.ps.server.data.response.Response in project angel by Tencent.
the class GetRowsHandler method merge.
private Vector[] merge(int matrixId, int[] rowIds, Collection<Response> responses) {
Map<Integer, List<ServerRow>> rowIdToserverRows = new HashMap<>(rowIds.length);
int valueNum = responses.size();
for (Response response : responses) {
ServerRow[] serverRows = ((GetRowsSplitResponse) (response.getData())).getRowsSplit();
for (int j = 0; j < serverRows.length; j++) {
int rowId = serverRows[j].getRowId();
List<ServerRow> rowSplits = rowIdToserverRows.get(rowId);
if (rowSplits == null) {
rowSplits = new ArrayList<>(valueNum);
rowIdToserverRows.put(rowId, rowSplits);
}
rowSplits.add(serverRows[j]);
}
}
Vector[] vectors = new Vector[rowIds.length];
for (int i = 0; i < rowIds.length; i++) {
vectors[i] = MergeUtils.combineServerRowSplits(rowIdToserverRows.get(rowIds[i]), matrixId, rowIds[i]);
vectors[i].setMatrixId(matrixId);
vectors[i].setRowId(rowIds[i]);
}
return vectors;
}
use of com.tencent.angel.ps.server.data.response.Response in project angel by Tencent.
the class UpdateUDFHandler method handle.
@Override
public void handle(FutureResult finalResult, UserRequest userRequest, ResponseCache responseCache) {
MapResponseCache cache = (MapResponseCache) responseCache;
// Check update result
Map<Request, Response> responses = cache.getResponses();
boolean success = true;
String detail = "";
for (Response response : responses.values()) {
success = success && (response.getResponseType() == ResponseType.SUCCESS);
if (!success) {
detail = response.getDetail();
break;
}
}
// Set the final result
if (success) {
finalResult.set(new VoidResult(com.tencent.angel.psagent.matrix.ResponseType.SUCCESS));
} else {
finalResult.set(new VoidResult(com.tencent.angel.psagent.matrix.ResponseType.FAILED, detail));
}
}
use of com.tencent.angel.ps.server.data.response.Response in project angel by Tencent.
the class GetRowHandler method handle.
@Override
public void handle(FutureResult finalResult, UserRequest userRequest, ResponseCache responseCache) {
GetRowRequest getRowRequest = (GetRowRequest) userRequest;
MapResponseCache cache = (MapResponseCache) responseCache;
// Merge the sub-response
List<ServerRow> serverRows = new ArrayList<>(cache.expectedResponseNum);
for (Response response : cache.getResponses().values()) {
serverRows.add(((GetRowSplitResponse) (response.getData())).getRowSplit());
}
Vector vector = MergeUtils.combineServerRowSplits(serverRows, getRowRequest.getMatrixId(), getRowRequest.getRowId());
// Set matrix/row information
vector.setMatrixId(getRowRequest.getMatrixId());
vector.setRowId(getRowRequest.getRowId());
// Set result
finalResult.set(vector);
}
use of com.tencent.angel.ps.server.data.response.Response in project angel by Tencent.
the class IndexGetRowsHandler method handle.
@Override
public void handle(FutureResult finalResult, UserRequest userRequest, ResponseCache responseCache) {
IndexGetRowsRequest indexGetRowsRequest = (IndexGetRowsRequest) userRequest;
MapResponseCache cache = (MapResponseCache) responseCache;
ConcurrentHashMap<Request, Response> responses = cache.getResponses();
// Merge
Vector[] result = merge(indexGetRowsRequest, responses);
// Set final result
finalResult.set(result);
}
use of com.tencent.angel.ps.server.data.response.Response in project angel by Tencent.
the class UpdateHandler method handle.
@Override
public void handle(FutureResult finalResult, UserRequest userRequest, ResponseCache responseCache) {
MapResponseCache cache = (MapResponseCache) responseCache;
// Check update result
boolean success = true;
String detail = "";
for (Response response : cache.getResponses().values()) {
success = success && (response.getResponseType() == ResponseType.SUCCESS);
if (!success) {
detail = response.getDetail();
break;
}
}
// Set the final result
if (success) {
finalResult.set(new VoidResult(com.tencent.angel.psagent.matrix.ResponseType.SUCCESS));
} else {
finalResult.set(new VoidResult(com.tencent.angel.psagent.matrix.ResponseType.FAILED, detail));
}
}
Aggregations