Search in sources :

Example 1 with GetResult

use of com.tencent.angel.ml.matrix.psf.get.base.GetResult in project angel by Tencent.

the class UserRequestAdapter method get.

/**
 * Get a row from ps use a udf.
 *
 * @param func get row udf
 * @return GetResult the result of the udf
 * @throws ExecutionException exception thrown when attempting to retrieve the result of a task
 * that aborted by throwing an exception
 * @throws InterruptedException interrupted while wait the result
 */
public FutureResult<GetResult> get(GetFunc func) throws InterruptedException, ExecutionException {
    MatrixTransportClient matrixClient = PSAgentContext.get().getMatrixTransportClient();
    GetParam param = func.getParam();
    // Split param use matrix partitons
    List<PartitionGetParam> partParams = param.split();
    int size = partParams.size();
    GetPSFRequest request = new GetPSFRequest(func);
    int requestId = request.getRequestId();
    FutureResult<GetResult> result = new FutureResult<>();
    ResponseCache cache = new MapResponseCache(size);
    requests.put(requestId, request);
    requestIdToResponseCache.put(requestId, cache);
    requestIdToResultMap.put(requestId, result);
    for (int i = 0; i < size; i++) {
        sendGetUDFRequest(matrixClient, requestId, partParams.get(i).getMatrixId(), partParams.get(i).getPartKey().getPartitionId(), func, partParams.get(i));
    }
    return result;
}
Also used : MatrixTransportClient(com.tencent.angel.psagent.matrix.transport.MatrixTransportClient) GetResult(com.tencent.angel.ml.matrix.psf.get.base.GetResult) FutureResult(com.tencent.angel.psagent.matrix.transport.FutureResult) GetParam(com.tencent.angel.ml.matrix.psf.get.base.GetParam) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam) MapResponseCache(com.tencent.angel.psagent.matrix.transport.response.MapResponseCache) ResponseCache(com.tencent.angel.psagent.matrix.transport.response.ResponseCache) MapResponseCache(com.tencent.angel.psagent.matrix.transport.response.MapResponseCache)

Aggregations

GetParam (com.tencent.angel.ml.matrix.psf.get.base.GetParam)1 GetResult (com.tencent.angel.ml.matrix.psf.get.base.GetResult)1 PartitionGetParam (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)1 FutureResult (com.tencent.angel.psagent.matrix.transport.FutureResult)1 MatrixTransportClient (com.tencent.angel.psagent.matrix.transport.MatrixTransportClient)1 MapResponseCache (com.tencent.angel.psagent.matrix.transport.response.MapResponseCache)1 ResponseCache (com.tencent.angel.psagent.matrix.transport.response.ResponseCache)1