Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
askwang committed Oct 11, 2024
1 parent 54104c1 commit 2ac0e7b
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;

import static org.apache.paimon.catalog.Catalog.SYSTEM_TABLE_SPLITTER;

Expand Down Expand Up @@ -185,21 +185,23 @@ public RecordReader<InternalRow> createReader(Split split) {
fileStoreTable.schema().logicalPartitionType());

// sorted by partition and bucket
Map<Pair<String, Integer>, BucketEntry> pairBucketsMap =
new TreeMap<>(
Comparator.comparing((Pair<String, Integer> o) -> o.getLeft())
.thenComparing(Pair::getRight));
buckets.forEach(
entry ->
pairBucketsMap.put(
Pair.of(
Arrays.toString(converter.convert(entry.partition())),
entry.bucket()),
entry));
List<Pair<String, BucketEntry>> bucketList =
buckets.stream()
.map(
entry ->
Pair.of(
Arrays.toString(
converter.convert(entry.partition())),
entry))
.sorted(
Comparator.comparing(
(Pair<String, BucketEntry> p) -> p.getLeft())
.thenComparing(p -> p.getRight().bucket()))
.collect(Collectors.toList());

List<InternalRow> results = new ArrayList<>(buckets.size());
for (Map.Entry<Pair<String, Integer>, BucketEntry> pair : pairBucketsMap.entrySet()) {
results.add(toRow(pair.getKey().getLeft(), pair.getValue()));
for (Pair<String, BucketEntry> pair : bucketList) {
results.add(toRow(pair.getLeft(), pair.getRight()));
}

Iterator<InternalRow> iterator = results.iterator();
Expand Down

0 comments on commit 2ac0e7b

Please sign in to comment.