This is an automated email from the ASF dual-hosted git repository.
mbudiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new 84af5621db [CALCITE-6763] Optimize logic to select the tiles with the
fewest rows Optim define tile
84af5621db is described below
commit 84af5621db8150a503bc9e3c9d1c8b4158ddbc10
Author: Xiaochen Zhou <[email protected]>
AuthorDate: Sun Jan 5 09:01:49 2025 +0800
[CALCITE-6763] Optimize logic to select the tiles with the fewest rows
Optim define tile
---
.../apache/calcite/materialize/MaterializationService.java | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git
a/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java
b/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java
index 91cdeca0c0..195f50fb91 100644
---
a/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java
+++
b/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java
@@ -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;
@@ -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();
@@ -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.