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

[CALCITE-6763] Optimize logic to select the tiles with the fewest rows #4125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -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;
ILuffZhe marked this conversation as resolved.
Show resolved Hide resolved
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
Loading