Search in sources :

Example 1 with LongIndexComparator

use of com.tencent.angel.graph.utils.LongIndexComparator in project angel by Tencent.

the class InitNodeFeatsParam method split.

@Override
public List<PartitionUpdateParam> split() {
    LongIndexComparator comparator = new LongIndexComparator(keys);
    int size = endIndex - startIndex;
    int[] index = new int[size];
    for (int i = 0; i < size; i++) {
        index[i] = i + startIndex;
    }
    IntArrays.quickSort(index, comparator);
    List<PartitionUpdateParam> params = new ArrayList<>();
    List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    if (!RowUpdateSplitUtils.isInRange(keys, index, parts)) {
        throw new AngelException("node id is not in range [" + parts.get(0).getStartCol() + ", " + parts.get(parts.size() - 1).getEndCol());
    }
    int nodeIndex = startIndex;
    int partIndex = 0;
    while (nodeIndex < endIndex || partIndex < parts.size()) {
        int length = 0;
        long endOffset = parts.get(partIndex).getEndCol();
        while (nodeIndex < endIndex && keys[index[nodeIndex - startIndex]] < endOffset) {
            nodeIndex++;
            length++;
        }
        if (length > 0) {
            params.add(new InitNodeFeatsPartParam(matrixId, parts.get(partIndex), keys, feats, index, nodeIndex - length - startIndex, nodeIndex - startIndex));
        }
        partIndex++;
    }
    return params;
}
Also used : AngelException(com.tencent.angel.exception.AngelException) PartitionUpdateParam(com.tencent.angel.ml.matrix.psf.update.base.PartitionUpdateParam) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) LongIndexComparator(com.tencent.angel.graph.utils.LongIndexComparator)

Example 2 with LongIndexComparator

use of com.tencent.angel.graph.utils.LongIndexComparator in project angel by Tencent.

the class InitNeighborParam method split.

@Override
public List<PartitionUpdateParam> split() {
    LongIndexComparator comparator = new LongIndexComparator(keys);
    int size = end - start;
    int[] index = new int[size];
    for (int i = 0; i < size; i++) index[i] = i + start;
    IntArrays.quickSort(index, comparator);
    List<PartitionUpdateParam> params = new ArrayList<>();
    List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    if (!RowUpdateSplitUtils.isInRange(keys, index, parts)) {
        throw new AngelException("node id is not in range [" + parts.get(0).getStartCol() + ", " + parts.get(parts.size() - 1).getEndCol());
    }
    int nodeIndex = start;
    int partIndex = 0;
    while (nodeIndex < end || partIndex < parts.size()) {
        int length = 0;
        long endOffset = parts.get(partIndex).getEndCol();
        while (nodeIndex < end && keys[index[nodeIndex - start]] < endOffset) {
            nodeIndex++;
            length++;
        }
        if (length > 0)
            params.add(new InitNeighborPartParam(matrixId, parts.get(partIndex), keys, index, indptr, neighbors, edgeTypes, dstTypes, nodeIndex - length - start, nodeIndex - start));
        partIndex++;
    }
    return params;
}
Also used : AngelException(com.tencent.angel.exception.AngelException) PartitionUpdateParam(com.tencent.angel.ml.matrix.psf.update.base.PartitionUpdateParam) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) LongIndexComparator(com.tencent.angel.graph.utils.LongIndexComparator)

Aggregations

PartitionKey (com.tencent.angel.PartitionKey)2 AngelException (com.tencent.angel.exception.AngelException)2 LongIndexComparator (com.tencent.angel.graph.utils.LongIndexComparator)2 PartitionUpdateParam (com.tencent.angel.ml.matrix.psf.update.base.PartitionUpdateParam)2 ArrayList (java.util.ArrayList)2