Skip to content

Commit

Permalink
always compute unbound
Browse files Browse the repository at this point in the history
  • Loading branch information
924060929 committed Mar 11, 2024
1 parent 4d36405 commit c03dca0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,26 @@ public abstract class Expression extends AbstractTreeNode<Expression> implements
private final int width;
// Mark this expression is from predicate infer or something else infer
private final boolean inferred;
private final boolean hasUnbound;
private final Supplier<Set<Slot>> inputSlots = Suppliers.memoize(() -> collect(Slot.class::isInstance));

protected Expression(Expression... children) {
super(children);
int maxChildDepth = 0;
int sumChildWidth = 0;
boolean hasUnbound = false;
for (int i = 0; i < children.length; ++i) {
Expression child = children[i];
maxChildDepth = Math.max(child.depth, maxChildDepth);
sumChildWidth += child.width;
hasUnbound |= child.hasUnbound;
}
this.depth = maxChildDepth + 1;
this.width = sumChildWidth + ((children.length == 0) ? 1 : 0);

checkLimit();
this.inferred = false;
this.hasUnbound = hasUnbound || this instanceof Unbound;
}

protected Expression(List<Expression> children) {
Expand All @@ -90,16 +94,19 @@ protected Expression(List<Expression> children, boolean inferred) {
super(children);
int maxChildDepth = 0;
int sumChildWidth = 0;
boolean hasUnbound = false;
for (int i = 0; i < children.size(); ++i) {
Expression child = children.get(i);
maxChildDepth = Math.max(child.depth, maxChildDepth);
sumChildWidth += child.width;
hasUnbound |= child.hasUnbound;
}
this.depth = maxChildDepth + 1;
this.width = sumChildWidth + ((children.isEmpty()) ? 1 : 0);

checkLimit();
this.inferred = inferred;
this.hasUnbound = hasUnbound || this instanceof Unbound;
}

private void checkLimit() {
Expand Down Expand Up @@ -368,15 +375,7 @@ public int hashCode() {
* This expression has unbound symbols or not.
*/
public boolean hasUnbound() {
if (this instanceof Unbound) {
return true;
}
for (Expression child : children) {
if (child.hasUnbound()) {
return true;
}
}
return false;
return this.hasUnbound;
}

public String shapeInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ protected AbstractPlan(PlanType type, Optional<GroupExpression> groupExpression,
this.type = Objects.requireNonNull(type, "type can not be null");
this.groupExpression = Objects.requireNonNull(groupExpression, "groupExpression can not be null");
Objects.requireNonNull(optLogicalProperties, "logicalProperties can not be null");
this.logicalPropertiesSupplier = Suppliers.memoize(() -> optLogicalProperties.orElseGet(
this::computeLogicalProperties));
this.logicalPropertiesSupplier = Suppliers.memoize(() ->
optLogicalProperties.orElseGet(this::computeLogicalProperties));
this.statistics = statistics;
this.id = StatementScopeIdGenerator.newObjectId();
}
Expand Down

0 comments on commit c03dca0

Please sign in to comment.