Search in sources :

Example 6 with PartitionGetParam

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

the class UnaryAggrParam 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 UnaryPartitionAggrParam(matrixId, part, rowId));
    }
    return partParams;
}
Also used : ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)

Example 7 with PartitionGetParam

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

the class SampleNeighbor method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    SampleNeighborParam param = (SampleNeighborParam) getParam();
    long[] keys = param.getKeys();
    Int2ObjectArrayMap<PartitionGetResult> partIdToResult = new Int2ObjectArrayMap<>();
    for (PartitionGetResult result : partResults) {
        partIdToResult.put(((SampleNeighborPartResult) result).getPartId(), result);
    }
    for (PartitionGetParam partParam : param.getParams()) {
        SampleNeighborPartParam param0 = (SampleNeighborPartParam) partParam;
        int start = param0.getStartIndex();
        int end = param0.getEndIndex();
        SampleNeighborPartResult result = (SampleNeighborPartResult) partIdToResult.get(param0.getPartKey().getPartitionId());
        int[] indptr = result.getIndptr();
        long[] neighbors = result.getNeighbors();
        int[] sampleTypes = result.getTypes();
        assert indptr.length == (end - start) + 1;
        for (int i = start; i < end; i++) {
            int keyIndex = index.get(keys[i]);
            for (int j = indptr[i - start]; j < indptr[i - start + 1]; j++) {
                long n = neighbors[j];
                if (!index.containsKey(n)) {
                    index.put(n, index.size());
                }
                srcs.add(keyIndex);
                dsts.add(index.get(n));
            }
            if (param.getSampleTypes()) {
                for (int j = indptr[i - start]; j < indptr[i - start + 1]; j++) {
                    types.add(sampleTypes[j]);
                }
            }
        }
    }
    return new ScalarAggrResult(0);
}
Also used : Int2ObjectArrayMap(it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap) ScalarAggrResult(com.tencent.angel.ml.matrix.psf.aggr.enhance.ScalarAggrResult) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 8 with PartitionGetParam

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

the class GetColsParam method split.

@Override
public List<PartitionGetParam> split() {
    List<PartitionKey> pkeys = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    List<PartitionGetParam> params = new ArrayList<>();
    int start = 0, end = 0;
    for (PartitionKey pkey : pkeys) {
        long startCol = pkey.getStartCol();
        long endCol = pkey.getEndCol();
        if (start < cols.length && cols[start] >= startCol) {
            while (end < cols.length && cols[end] < endCol) end++;
            long[] part = new long[end - start];
            System.arraycopy(cols, start, part, 0, end - start);
            params.add(new PartitionGetColsParam(matrixId, pkey, rows, part, func));
            start = end;
        }
    }
    return params;
}
Also used : ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)

Example 9 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> partParams = new ArrayList<>(partitionIds.length);
    Map<Integer, PartitionKey> partsMap = new HashMap<>();
    for (PartitionKey pkey : parts) {
        partsMap.put(pkey.getPartitionId(), pkey);
    }
    for (int i = 0; i < partitionIds.length; i++) {
        partParams.add(new PartitionGetParam(matrixId, partsMap.get(partitionIds[i])));
    }
    return partParams;
}
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 10 with PartitionGetParam

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

the class ReadTagParam method split.

@Override
public List<PartitionGetParam> split() {
    MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
    PartitionKey[] parts = meta.getPartitionKeys();
    KeyPart[] nodeIdsParts = RouterUtils.split(meta, rowId, nodeIds, false);
    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