Skip to content

Commit

Permalink
[CALCITE-6763] Optimize logic to select the tiles with the fewest row…
Browse files Browse the repository at this point in the history
…s Optim define tile
  • Loading branch information
xiaochen-zhou committed Jan 7, 2025
1 parent 901aadb commit 9e1a346
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;

import static org.apache.calcite.linq4j.Nullness.castNonNull;
Expand Down Expand Up @@ -241,8 +240,7 @@ private MaterializationService() {
// TODO: Use a partially-ordered set data structure, so we are not scanning
// through all tiles.
if (!exact) {
final PriorityQueue<Pair<CalciteSchema.TableEntry, TileKey>> queue =
new PriorityQueue<>(1, C);
Pair<CalciteSchema.TableEntry, TileKey> bestCandidate = null;
for (Map.Entry<TileKey, MaterializationKey> entry
: actor.keyByTile.entrySet()) {
final TileKey tileKey2 = entry.getKey();
Expand All @@ -254,13 +252,13 @@ && allSatisfiable(measureList, tileKey2)) {
final CalciteSchema.TableEntry tableEntry =
checkValid(materializationKey);
if (tableEntry != null) {
queue.add(Pair.of(tableEntry, tileKey2));
Pair<CalciteSchema.TableEntry, TileKey> candidate = Pair.of(tableEntry, tileKey2);
if (bestCandidate == null || C.compare(candidate, bestCandidate) < 0) {
bestCandidate = candidate;
}
}
}
}
if (!queue.isEmpty()) {
return queue.peek();
}
}

// What we need is not there. If we can't create, we're done.
Expand Down

0 comments on commit 9e1a346

Please sign in to comment.