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;
}
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;
}
Aggregations