Search in sources :

Example 31 with PartitionGetParam

use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam 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)

Example 32 with PartitionGetParam

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

the class BinaryAggrParam method split.

@Override
public List<PartitionGetParam> split() {
    List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    int size = parts.size();
    List<PartitionGetParam> partParams = new ArrayList<PartitionGetParam>(size);
    for (PartitionKey part : parts) {
        partParams.add(new BinaryPartitionAggrParam(matrixId, part, rowId1, rowId2));
    }
    return partParams;
}
Also used : ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)

Example 33 with PartitionGetParam

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

the class GetColumnParam method split.

@Override
public List<PartitionGetParam> split() {
    List<PartitionKey> pkeys = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    List<PartitionGetParam> partParams = new ArrayList<PartitionGetParam>(pkeys.size());
    for (PartitionKey entry : pkeys) {
        partParams.add(new PartitionGetRowsParam(matrixId, entry, columns));
    }
    return partParams;
}
Also used : PartitionGetRowsParam(com.tencent.angel.ml.matrix.psf.get.getrows.PartitionGetRowsParam) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)

Example 34 with PartitionGetParam

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

the class LikelihoodParam method split.

@Override
public List<PartitionGetParam> split() {
    List<PartitionGetParam> params = new ArrayList<>();
    List<PartitionKey> pkeys = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    for (PartitionKey pkey : pkeys) {
        params.add(new LikelihoodPartParam(matrixId, pkey, beta));
    }
    return params;
}
Also used : ArrayList(java.util.ArrayList) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam) PartitionKey(com.tencent.angel.PartitionKey)

Example 35 with PartitionGetParam

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

the class HistAggrParam method split.

@Override
public List<PartitionGetParam> split() {
    List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    int size = parts.size();
    List<PartitionGetParam> partParams = new ArrayList<PartitionGetParam>(size);
    for (PartitionKey part : parts) {
        partParams.add(new HistPartitionAggrParam(matrixId, part, rowId, splitNum, minChildWeight, regAlpha, regLambda));
    }
    return partParams;
}
Also used : ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)

Aggregations

PartitionGetParam (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)35 PartitionKey (com.tencent.angel.PartitionKey)28 ArrayList (java.util.ArrayList)28 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)13 KeyPart (com.tencent.angel.psagent.matrix.transport.router.KeyPart)9 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)6 Int2ObjectArrayMap (it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap)6 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)5 GeneralPartGetParam (com.tencent.angel.ml.matrix.psf.get.base.GeneralPartGetParam)4 HashMap (java.util.HashMap)3 KeyValuePart (com.tencent.angel.psagent.matrix.transport.router.KeyValuePart)2 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)1 ScalarAggrResult (com.tencent.angel.ml.matrix.psf.aggr.enhance.ScalarAggrResult)1 GetParam (com.tencent.angel.ml.matrix.psf.get.base.GetParam)1 GetResult (com.tencent.angel.ml.matrix.psf.get.base.GetResult)1 PartitionGetRowsParam (com.tencent.angel.ml.matrix.psf.get.getrows.PartitionGetRowsParam)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