Java Code Examples for org.apache.calcite.plan.RelOptUtil#decomposeConjunction()

The following examples show how to use org.apache.calcite.plan.RelOptUtil#decomposeConjunction() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RexSimplify.java    From Bats with Apache License 2.0 6 votes vote down vote up
RexNode simplifyAnd(RexCall e, RexUnknownAs unknownAs) {
    List<RexNode> operands = RelOptUtil.conjunctions(e);

    if (unknownAs == FALSE && predicateElimination) {
        simplifyAndTerms(operands, FALSE);
    } else {
        simplifyList(operands, unknownAs);
    }

    final List<RexNode> terms = new ArrayList<>();
    final List<RexNode> notTerms = new ArrayList<>();

    for (RexNode o : operands) {
        RelOptUtil.decomposeConjunction(o, terms, notTerms);
    }

    switch (unknownAs) {
    case FALSE:
        return simplifyAnd2ForUnknownAsFalse(terms, notTerms, Comparable.class);
    }
    return simplifyAnd2(terms, notTerms);
}
 
Example 2
Source File: RexSimplify.java    From calcite with Apache License 2.0 6 votes vote down vote up
RexNode simplifyAnd(RexCall e, RexUnknownAs unknownAs) {
  List<RexNode> operands = RelOptUtil.conjunctions(e);

  if (unknownAs == FALSE && predicateElimination) {
    simplifyAndTerms(operands, FALSE);
  } else {
    simplifyList(operands, unknownAs);
  }

  final List<RexNode> terms = new ArrayList<>();
  final List<RexNode> notTerms = new ArrayList<>();

  for (RexNode o : operands) {
    RelOptUtil.decomposeConjunction(o, terms, notTerms);
  }

  switch (unknownAs) {
  case FALSE:
    return simplifyAnd2ForUnknownAsFalse(terms, notTerms, Comparable.class);
  }
  return simplifyAnd2(terms, notTerms);
}
 
Example 3
Source File: RexSimplify.java    From Bats with Apache License 2.0 5 votes vote down vote up
RexNode simplifyAnds(Iterable<? extends RexNode> nodes, RexUnknownAs unknownAs) {
    final List<RexNode> terms = new ArrayList<>();
    final List<RexNode> notTerms = new ArrayList<>();
    for (RexNode e : nodes) {
        RelOptUtil.decomposeConjunction(e, terms, notTerms);
    }
    simplifyList(terms, UNKNOWN);
    simplifyList(notTerms, UNKNOWN);
    if (unknownAs == FALSE) {
        return simplifyAnd2ForUnknownAsFalse(terms, notTerms);
    }
    return simplifyAnd2(terms, notTerms);
}
 
Example 4
Source File: RexProgram.java    From Bats with Apache License 2.0 5 votes vote down vote up
/** Splits this program into a list of project expressions and a list of
 * filter expressions.
 *
 * <p>Neither list is null.
 * The filters are evaluated first. */
public Pair<ImmutableList<RexNode>, ImmutableList<RexNode>> split() {
    final List<RexNode> filters = new ArrayList<>();
    if (condition != null) {
        RelOptUtil.decomposeConjunction(expandLocalRef(condition), filters);
    }
    final ImmutableList.Builder<RexNode> projects = ImmutableList.builder();
    for (RexLocalRef project : this.projects) {
        projects.add(expandLocalRef(project));
    }
    return Pair.of(projects.build(), ImmutableList.copyOf(filters));
}
 
Example 5
Source File: RexSimplify.java    From calcite with Apache License 2.0 5 votes vote down vote up
RexNode simplifyAnds(Iterable<? extends RexNode> nodes,
    RexUnknownAs unknownAs) {
  final List<RexNode> terms = new ArrayList<>();
  final List<RexNode> notTerms = new ArrayList<>();
  for (RexNode e : nodes) {
    RelOptUtil.decomposeConjunction(e, terms, notTerms);
  }
  simplifyList(terms, UNKNOWN);
  simplifyList(notTerms, UNKNOWN);
  if (unknownAs == FALSE) {
    return simplifyAnd2ForUnknownAsFalse(terms, notTerms);
  }
  return simplifyAnd2(terms, notTerms);
}
 
Example 6
Source File: RexProgram.java    From calcite with Apache License 2.0 5 votes vote down vote up
/** Splits this program into a list of project expressions and a list of
 * filter expressions.
 *
 * <p>Neither list is null.
 * The filters are evaluated first. */
public Pair<ImmutableList<RexNode>, ImmutableList<RexNode>> split() {
  final List<RexNode> filters = new ArrayList<>();
  if (condition != null) {
    RelOptUtil.decomposeConjunction(expandLocalRef(condition), filters);
  }
  final ImmutableList.Builder<RexNode> projects = ImmutableList.builder();
  for (RexLocalRef project : this.projects) {
    projects.add(expandLocalRef(project));
  }
  return Pair.of(projects.build(), ImmutableList.copyOf(filters));
}