use of com.tencent.angel.psagent.matrix.transport.adapter.UserRequest 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.psagent.matrix.transport.adapter.UserRequest 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.psagent.matrix.transport.adapter.UserRequest in project angel by Tencent.
the class GetUDFHandler method handle.
@Override
public void handle(FutureResult finalResult, UserRequest userRequest, ResponseCache responseCache) {
GetPSFRequest getPSFRequest = (GetPSFRequest) userRequest;
MapResponseCache cache = (MapResponseCache) responseCache;
// Adaptor to Get PSF merge
ConcurrentHashMap<Request, Response> responses = cache.getResponses();
int responseNum = responses.size();
List<PartitionGetResult> partGetResults = new ArrayList<>(responseNum);
for (Response response : responses.values()) {
partGetResults.add(((GetUDFResponse) response.getData()).getPartResult());
}
// Merge the sub-results
try {
finalResult.set(getPSFRequest.getGetFunc().merge(partGetResults));
} catch (Exception x) {
LOG.error("merge row failed ", x);
finalResult.setExecuteException(new ExecutionException(x));
}
}
use of com.tencent.angel.psagent.matrix.transport.adapter.UserRequest in project angel by Tencent.
the class IndexGetRowHandler method handle.
@Override
public void handle(FutureResult finalResult, UserRequest userRequest, ResponseCache responseCache) {
IndexGetRowRequest indexGetRowRequest = (IndexGetRowRequest) userRequest;
MapResponseCache cache = (MapResponseCache) responseCache;
ConcurrentHashMap<Request, Response> responses = cache.getResponses();
// Merge
Vector result = merge(indexGetRowRequest, responses);
// Set matrix/row meta
result.setMatrixId(indexGetRowRequest.getMatrixId());
result.setRowId(indexGetRowRequest.getRowId());
// Set final result
finalResult.set(result);
}
Aggregations