Search in sources :

Example 1 with UpdateParam

use of com.tencent.angel.ml.matrix.psf.update.base.UpdateParam in project angel by Tencent.

the class UserRequestAdapter method update.

/**
 * Update matrix use a udf.
 *
 * @param updateFunc update udf function
 * @return Future<VoidResult> update future result
 */
public Future<VoidResult> update(UpdateFunc updateFunc) {
    MatrixTransportClient matrixClient = PSAgentContext.get().getMatrixTransportClient();
    UpdateParam param = updateFunc.getParam();
    // Split the param use matrix partitions
    List<PartitionUpdateParam> partParams = param.split();
    int size = partParams.size();
    UpdatePSFRequest request = new UpdatePSFRequest(updateFunc);
    ResponseCache cache = new MapResponseCache(size);
    FutureResult<VoidResult> result = new FutureResult<>();
    int requestId = request.getRequestId();
    requests.put(requestId, request);
    requestIdToResponseCache.put(requestId, cache);
    requestIdToResultMap.put(requestId, result);
    // Send request to PSS
    for (int i = 0; i < size; i++) {
        sendUpdateUDFRequest(matrixClient, requestId, partParams.get(i).getMatrixId(), partParams.get(i).getPartKey().getPartitionId(), updateFunc, partParams.get(i));
    }
    return result;
}
Also used : MatrixTransportClient(com.tencent.angel.psagent.matrix.transport.MatrixTransportClient) VoidResult(com.tencent.angel.ml.matrix.psf.update.base.VoidResult) FutureResult(com.tencent.angel.psagent.matrix.transport.FutureResult) PartitionUpdateParam(com.tencent.angel.ml.matrix.psf.update.base.PartitionUpdateParam) PartitionUpdateParam(com.tencent.angel.ml.matrix.psf.update.base.PartitionUpdateParam) UpdateParam(com.tencent.angel.ml.matrix.psf.update.base.UpdateParam) 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

PartitionUpdateParam (com.tencent.angel.ml.matrix.psf.update.base.PartitionUpdateParam)1 UpdateParam (com.tencent.angel.ml.matrix.psf.update.base.UpdateParam)1 VoidResult (com.tencent.angel.ml.matrix.psf.update.base.VoidResult)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