Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ArrayList instead of LinkedList in SortOperator #12783

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -129,16 +129,16 @@ private TransferableBlock produceSortedBlock() {
return TransferableBlockUtils.getEndOfStreamTransferableBlock();
}
} else {
LinkedList<Object[]> rows = new LinkedList<>();
while (_priorityQueue.size() > _offset) {
Object[] row = _priorityQueue.poll();
rows.addFirst(row);
}
if (rows.size() == 0) {
int resultSize = _priorityQueue.size() - _offset;
if (resultSize <= 0) {
return TransferableBlockUtils.getEndOfStreamTransferableBlock();
} else {
return new TransferableBlock(rows, _dataSchema, DataBlock.Type.ROW);
}
Object[][] rowsArr = new Object[resultSize][];
for (int i = resultSize - 1; i >= 0; i--) {
Object[] row = _priorityQueue.poll();
rowsArr[i] = row;
}
return new TransferableBlock(Arrays.asList(rowsArr), _dataSchema, DataBlock.Type.ROW);
}
}

Expand Down
Loading