Search in sources :

Example 1 with PartitionUpdateParam

use of com.tencent.angel.ml.matrix.psf.update.enhance.PartitionUpdateParam in project angel by Tencent.

the class CommonParam method split.

@Override
public List<PartitionUpdateParam> split() {
    List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    int size = parts.size();
    List<PartitionUpdateParam> partParams = new ArrayList<PartitionUpdateParam>(size);
    for (PartitionKey part : parts) {
        int[] ints = Utils.intListToArray(intArray);
        long[] longs = Utils.longListToArray(longArray);
        float[] floats = Utils.floatListToArray(floatArray);
        double[] doubles = Utils.doubleListToArray(doubleArray);
        PSFPartitionUpdateParam partParam = new PSFPartitionUpdateParam(matrixId, part, ints, longs, floats, doubles);
        partParams.add(partParam);
    }
    return partParams;
}
Also used : PartitionUpdateParam(com.tencent.angel.ml.matrix.psf.update.enhance.PartitionUpdateParam) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey)

Example 2 with PartitionUpdateParam

use of com.tencent.angel.ml.matrix.psf.update.enhance.PartitionUpdateParam in project angel by Tencent.

the class MatrixClientAdapter 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();
    List<PartitionUpdateParam> partParams = param.split();
    int size = partParams.size();
    UpdaterRequest request = new UpdaterRequest(param);
    UpdaterResponseCache cache = new UpdaterResponseCache(size);
    for (int i = 0; i < size; i++) {
        cache.addResult(matrixClient.update(updateFunc, partParams.get(i)));
    }
    requestToResponseMap.put(request, cache);
    return cache.getMergedResult();
}
Also used : MatrixTransportClient(com.tencent.angel.psagent.matrix.transport.MatrixTransportClient) PartitionUpdateParam(com.tencent.angel.ml.matrix.psf.update.enhance.PartitionUpdateParam) PartitionUpdateParam(com.tencent.angel.ml.matrix.psf.update.enhance.PartitionUpdateParam) UpdateParam(com.tencent.angel.ml.matrix.psf.update.enhance.UpdateParam)

Aggregations

PartitionUpdateParam (com.tencent.angel.ml.matrix.psf.update.enhance.PartitionUpdateParam)2 PartitionKey (com.tencent.angel.PartitionKey)1 UpdateParam (com.tencent.angel.ml.matrix.psf.update.enhance.UpdateParam)1 MatrixTransportClient (com.tencent.angel.psagent.matrix.transport.MatrixTransportClient)1 ArrayList (java.util.ArrayList)1