use of com.tencent.angel.ps.server.data.response.GetUDFResponse in project angel by Tencent.
the class PSFGetHandler method handle.
@Override
public ResponseData handle(RequestHeader header, RequestData data) throws Exception {
GetUDFRequest request = (GetUDFRequest) data;
Class<? extends GetFunc> funcClass = (Class<? extends GetFunc>) Class.forName(request.getGetFuncClass());
Constructor<? extends GetFunc> constructor = funcClass.getConstructor();
constructor.setAccessible(true);
GetFunc func = constructor.newInstance();
// LOG.info("Get PSF func = " + func.getClass().getName());
func.setPsContext(context);
PartitionGetResult partResult = func.partitionGet(request.getPartParam());
return new GetUDFResponse(partResult);
}
use of com.tencent.angel.ps.server.data.response.GetUDFResponse 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.ps.server.data.response.GetUDFResponse in project angel by Tencent.
the class GetUDFHandler method parseResponse.
@Override
public ResponseData parseResponse(ByteBuf in) {
GetUDFResponse response = new GetUDFResponse();
response.deserialize(in);
return response;
}
Aggregations