Search in sources :

Example 11 with PartitionGetParam

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

the class GetNodesParam method split.

@Override
public List<PartitionGetParam> split() {
    List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    List<PartitionGetParam> params = new ArrayList<>();
    Map<Integer, PartitionKey> pkeys = new HashMap<>();
    for (PartitionKey pkey : parts) {
        pkeys.put(pkey.getPartitionId(), pkey);
    }
    for (int i = 0; i < partitionIds.length; i++) {
        params.add(new PartitionGetParam(matrixId, pkeys.get(partitionIds[i])));
    }
    return params;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)

Example 12 with PartitionGetParam

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

the class GetNodeFeats method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
    for (PartitionGetResult result : partResults) {
        partIdToResultMap.put(((PartGetNodeFeatsResult) result).getPartId(), result);
    }
    GetNodeFeatsParam param = (GetNodeFeatsParam) getParam();
    long[] nodeIds = param.getNodeIds();
    List<PartitionGetParam> partParams = param.getPartParams();
    Long2ObjectOpenHashMap<IntFloatVector> results = new Long2ObjectOpenHashMap<>(nodeIds.length);
    int size = partResults.size();
    for (int i = 0; i < size; i++) {
        PartGetNodeFeatsParam partParam = (PartGetNodeFeatsParam) partParams.get(i);
        PartGetNodeFeatsResult partResult = (PartGetNodeFeatsResult) partIdToResultMap.get(partParam.getPartKey().getPartitionId());
        int start = partParam.getStartIndex();
        int end = partParam.getEndIndex();
        IntFloatVector[] feats = partResult.getFeats();
        for (int j = start; j < end; j++) {
            if (feats[j - start] != null) {
                results.put(nodeIds[j], feats[j - start]);
            }
        }
    }
    return new GetNodeFeatsResult(results);
}
Also used : Int2ObjectArrayMap(it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 13 with PartitionGetParam

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

the class SampleParam method split.

@Override
public List<PartitionGetParam> split() {
    // Get matrix meta
    MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
    PartitionKey[] parts = meta.getPartitionKeys();
    // Split
    KeyPart[] nodeIdsParts = RouterUtils.split(meta, 0, nodeIds, false);
    // Generate Part psf get param
    List<PartitionGetParam> partParams = new ArrayList<>(parts.length);
    assert parts.length == nodeIdsParts.length;
    for (int i = 0; i < parts.length; i++) {
        if (nodeIdsParts[i] != null && nodeIdsParts[i].size() > 0) {
            partParams.add(new PartSampleParam(matrixId, parts[i], nodeIdsParts[i], sampleType));
        }
    }
    return partParams;
}
Also used : MatrixMeta(com.tencent.angel.ml.matrix.MatrixMeta) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)

Example 14 with PartitionGetParam

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

the class DotParam method split.

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

Example 15 with PartitionGetParam

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

the class LongKeysGetParam method split.

@Override
public List<PartitionGetParam> split() {
    // Get matrix meta
    MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
    PartitionKey[] parts = meta.getPartitionKeys();
    // Split
    KeyPart[] nodeIdsParts = RouterUtils.split(meta, 0, nodeIds, false);
    // Generate Part psf get param
    List<PartitionGetParam> partParams = new ArrayList<>(parts.length);
    assert parts.length == nodeIdsParts.length;
    for (int i = 0; i < parts.length; i++) {
        if (nodeIdsParts[i] != null && nodeIdsParts[i].size() > 0) {
            partParams.add(new GeneralPartGetParam(matrixId, parts[i], nodeIdsParts[i]));
        }
    }
    return partParams;
}
Also used : GeneralPartGetParam(com.tencent.angel.ml.matrix.psf.get.base.GeneralPartGetParam) MatrixMeta(com.tencent.angel.ml.matrix.MatrixMeta) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart) 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