use of it.unimi.dsi.fastutil.ints.IntList in project presto by prestodb.
the class PartitioningExchanger method accept.
@Override
public synchronized void accept(Page page) {
// reset the assignment lists
for (IntList partitionAssignment : partitionAssignments) {
partitionAssignment.clear();
}
// assign each row to a partition
for (int position = 0; position < page.getPositionCount(); position++) {
int partition = partitionGenerator.getPartition(position, page);
partitionAssignments[partition].add(position);
}
// build a page for each partition
Block[] sourceBlocks = page.getBlocks();
Block[] outputBlocks = new Block[sourceBlocks.length];
for (int partition = 0; partition < buffers.size(); partition++) {
List<Integer> positions = partitionAssignments[partition];
if (!positions.isEmpty()) {
for (int i = 0; i < sourceBlocks.length; i++) {
outputBlocks[i] = sourceBlocks[i].copyPositions(positions);
}
Page pageSplit = new Page(positions.size(), outputBlocks);
memoryTracker.accept(pageSplit.getRetainedSizeInBytes());
buffers.get(partition).accept(new PageReference(pageSplit, 1, () -> memoryTracker.accept(-pageSplit.getRetainedSizeInBytes())));
}
}
}
Aggregations