Search in sources :

Example 1 with GetPSFRequest

use of com.tencent.angel.psagent.matrix.transport.adapter.GetPSFRequest 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));
    }
}
Also used : Response(com.tencent.angel.ps.server.data.response.Response) GetUDFResponse(com.tencent.angel.ps.server.data.response.GetUDFResponse) Request(com.tencent.angel.ps.server.data.request.Request) GetPSFRequest(com.tencent.angel.psagent.matrix.transport.adapter.GetPSFRequest) UserRequest(com.tencent.angel.psagent.matrix.transport.adapter.UserRequest) ArrayList(java.util.ArrayList) GetPSFRequest(com.tencent.angel.psagent.matrix.transport.adapter.GetPSFRequest) ExecutionException(java.util.concurrent.ExecutionException) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)1 Request (com.tencent.angel.ps.server.data.request.Request)1 GetUDFResponse (com.tencent.angel.ps.server.data.response.GetUDFResponse)1 Response (com.tencent.angel.ps.server.data.response.Response)1 GetPSFRequest (com.tencent.angel.psagent.matrix.transport.adapter.GetPSFRequest)1 UserRequest (com.tencent.angel.psagent.matrix.transport.adapter.UserRequest)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1