Skip to content

Commit 2dfd6a8

Browse files
committed
[SQL] Share indexes between joins when possible
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
1 parent b81033a commit 2dfd6a8

File tree

7 files changed

+517
-3
lines changed

7 files changed

+517
-3
lines changed

sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/visitors/inner/EquivalenceContext.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.dbsp.sqlCompiler.ir.IDBSPDeclaration;
55
import org.dbsp.sqlCompiler.ir.expression.DBSPExpression;
66

7+
import javax.annotation.CheckReturnValue;
78
import javax.annotation.Nullable;
89
import java.util.List;
910

@@ -31,10 +32,12 @@ public EquivalenceContext() {
3132
this.leftToRight = new Substitution<>();
3233
}
3334

35+
@CheckReturnValue
3436
public static boolean equiv(@Nullable DBSPExpression left, @Nullable DBSPExpression right) {
3537
return new EquivalenceContext().equivalent(left, right);
3638
}
3739

40+
@CheckReturnValue
3841
public static boolean equiv(@Nullable DBSPAggregateList left, @Nullable DBSPAggregateList right) {
3942
if (left == null)
4043
return right == null;
@@ -43,6 +46,7 @@ public static boolean equiv(@Nullable DBSPAggregateList left, @Nullable DBSPAggr
4346
return left.equivalent(right);
4447
}
4548

49+
@CheckReturnValue
4650
public boolean equivalent(@Nullable DBSPExpression left, @Nullable DBSPExpression right) {
4751
if (left == null)
4852
return right == null;
@@ -51,6 +55,7 @@ public boolean equivalent(@Nullable DBSPExpression left, @Nullable DBSPExpressio
5155
return left.equivalent(this, right);
5256
}
5357

58+
@CheckReturnValue
5459
public boolean equivalent(@Nullable DBSPExpression[] left, @Nullable DBSPExpression[] right) {
5560
if (left == null)
5661
return right == null;
@@ -64,6 +69,7 @@ public boolean equivalent(@Nullable DBSPExpression[] left, @Nullable DBSPExpress
6469
return true;
6570
}
6671

72+
@CheckReturnValue
6773
public <T extends DBSPExpression> boolean equivalent(@Nullable List<T> left, @Nullable List<T> right) {
6874
if (left == null)
6975
return right == null;

sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/visitors/outer/CircuitOptimizer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ void createOptimizer() {
108108
this.add(new RemoveIAfterD(compiler));
109109
this.add(new DeadCode(compiler, true));
110110
this.add(new Simplify(compiler).circuitRewriter(true));
111+
this.add(new ShareIndexes(compiler));
111112
this.add(new RemoveFilters(compiler));
112113
this.add(new OptimizeWithGraph(compiler, g -> new OptimizeProjectionVisitor(compiler, g)));
113114
this.add(new OptimizeWithGraph(compiler,

0 commit comments

Comments
 (0)