Skip to content

Commit

Permalink
Add support for NAryUnion to evaluation statistics.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Hale committed Oct 27, 2023
1 parent 7c4339d commit a3207d6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.msd.gin.halyard.optimizers;

import com.google.common.collect.Iterables;
import com.msd.gin.halyard.algebra.NAryUnion;
import com.msd.gin.halyard.algebra.StarJoin;

import java.io.IOException;
Expand Down Expand Up @@ -308,11 +309,24 @@ public void meetOther(QueryModelNode node) {
meet((TupleFunctionCall)node);
} else if (node instanceof StarJoin) {
meet((StarJoin)node);
} else if (node instanceof NAryUnion) {
meet((NAryUnion)node);
} else {
super.meetOther(node);
}
}

public void meet(NAryUnion node) {
double card = 0.0;
for (TupleExpr expr : node.getArgs()) {
expr.visit(this);
updateMap(expr);
card += this.cardinality;
}
cardinality = card;
updateMap(node);
}

public void meet(StarJoin node) {
TupleExpr sp = node.getArg(0);
sp.visit(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
public class NAryUnionOptimizer implements QueryOptimizer {
private final int minUnions;

public NAryUnionOptimizer(int minJoins) {
if (minJoins < 1) {
public NAryUnionOptimizer(int minUnions) {
if (minUnions < 1) {
throw new IllegalArgumentException("Minimum unions must be greater than or equal to one");
}
this.minUnions = minJoins;
this.minUnions = minUnions;
}

@Override
Expand Down

0 comments on commit a3207d6

Please sign in to comment.