Search in sources :

Example 6 with PartitionUpdateParam

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

Example 7 with PartitionUpdateParam

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

the class QuantifyDoubleParam method split.

@Override
public List<PartitionUpdateParam> split() {
    List<PartitionKey> partList = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId, rowId);
    int size = partList.size();
    List<PartitionUpdateParam> partParams = new ArrayList<>(size);
    for (PartitionKey part : partList) {
        if (rowId < part.getStartRow() || rowId >= part.getEndRow()) {
            throw new RuntimeException("Wrong rowId!");
        }
        partParams.add(new QuantifyDoublePartUParam(matrixId, part, rowId, (int) part.getStartCol(), (int) part.getEndCol(), array, numBits));
    }
    return partParams;
}
Also used : PartitionUpdateParam(com.tencent.angel.ml.matrix.psf.update.base.PartitionUpdateParam) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey)

Example 8 with PartitionUpdateParam

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

the class InitParam method split.

@Override
public List<PartitionUpdateParam> split() {
    List<PartitionKey> pkeys = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    IntOpenHashSet serverIds = new IntOpenHashSet();
    List<PartitionUpdateParam> params = new ArrayList<>();
    for (PartitionKey pkey : pkeys) {
        int serverId = PSAgentContext.get().getMatrixMetaManager().getMasterPS(pkey).getIndex();
        if (!serverIds.contains(serverId)) {
            serverIds.add(serverId);
            params.add(new InitPartitionParam(matrixId, pkey, numPartitions, maxIndex, maxLength, negative, order, partDim, window));
        }
    }
    return params;
}
Also used : IntOpenHashSet(it.unimi.dsi.fastutil.ints.IntOpenHashSet) PartitionUpdateParam(com.tencent.angel.ml.matrix.psf.update.base.PartitionUpdateParam) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey)

Example 9 with PartitionUpdateParam

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

the class AdjustParam method split.

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

Example 10 with PartitionUpdateParam

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

the class InitHyperLogLogParam method split.

@Override
public List<PartitionUpdateParam> split() {
    MatrixMeta matrixMeta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
    PartitionKey[] parts = matrixMeta.getPartitionKeys();
    KeyPart[] keyParts = RouterUtils.split(matrixMeta, 0, nodes);
    List<PartitionUpdateParam> params = new ArrayList<>(parts.length);
    for (int i = 0; i < parts.length; i++) {
        if (keyParts[i] != null && keyParts[i].size() > 0) {
            params.add(new InitHyperLogLogPartParam(matrixId, parts[i], keyParts[i], p, sp, seed));
        }
    }
    return params;
}
Also used : MatrixMeta(com.tencent.angel.ml.matrix.MatrixMeta) PartitionUpdateParam(com.tencent.angel.ml.matrix.psf.update.base.PartitionUpdateParam) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart)

Aggregations

PartitionUpdateParam (com.tencent.angel.ml.matrix.psf.update.base.PartitionUpdateParam)23 PartitionKey (com.tencent.angel.PartitionKey)22 ArrayList (java.util.ArrayList)21 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)6 KeyValuePart (com.tencent.angel.psagent.matrix.transport.router.KeyValuePart)5 AngelException (com.tencent.angel.exception.AngelException)4 GeneralPartUpdateParam (com.tencent.angel.ml.matrix.psf.update.base.GeneralPartUpdateParam)4 LongIndexComparator (com.tencent.angel.graph.utils.LongIndexComparator)2 Vector (com.tencent.angel.ml.math2.vector.Vector)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 KeyPart (com.tencent.angel.psagent.matrix.transport.router.KeyPart)1 IntOpenHashSet (it.unimi.dsi.fastutil.ints.IntOpenHashSet)1