Search in sources :

Example 1 with GetUDFResponse

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);
}
Also used : GetFunc(com.tencent.angel.ml.matrix.psf.get.base.GetFunc) GetUDFRequest(com.tencent.angel.ps.server.data.request.GetUDFRequest) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult) GetUDFResponse(com.tencent.angel.ps.server.data.response.GetUDFResponse)

Example 2 with GetUDFResponse

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));
    }
}
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)

Example 3 with GetUDFResponse

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;
}
Also used : GetUDFResponse(com.tencent.angel.ps.server.data.response.GetUDFResponse)

Aggregations

GetUDFResponse (com.tencent.angel.ps.server.data.response.GetUDFResponse)3 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)2 GetFunc (com.tencent.angel.ml.matrix.psf.get.base.GetFunc)1 GetUDFRequest (com.tencent.angel.ps.server.data.request.GetUDFRequest)1 Request (com.tencent.angel.ps.server.data.request.Request)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