org.apache.calcite.plan.RelOptRuleOperand Java Examples

The following examples show how to use org.apache.calcite.plan.RelOptRuleOperand. 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: MaterializedViewOnlyAggregateRule.java    From calcite with Apache License 2.0 6 votes vote down vote up
public MaterializedViewOnlyAggregateRule(RelOptRuleOperand operand,
    RelBuilderFactory relBuilderFactory, String description,
    boolean generateUnionRewriting, HepProgram unionRewritingPullProgram,
    RelOptRule filterProjectTransposeRule,
    RelOptRule filterAggregateTransposeRule,
    RelOptRule aggregateProjectPullUpConstantsRule,
    RelOptRule projectMergeRule) {
  super(
      operand(Aggregate.class, any()),
      relBuilderFactory,
      "MaterializedViewAggregateRule(Aggregate)",
      generateUnionRewriting, unionRewritingPullProgram,
      filterProjectTransposeRule,
      filterAggregateTransposeRule,
      aggregateProjectPullUpConstantsRule,
      projectMergeRule);
}
 
Example #2
Source File: MockRelOptPlanner.java    From calcite with Apache License 2.0 6 votes vote down vote up
/**
 * Matches a relational expression to a rule.
 *
 * @param operand  Root operand of rule
 * @param rel      Relational expression
 * @param bindings Bindings, populated on successful match
 * @return whether relational expression matched rule
 */
private boolean match(
    RelOptRuleOperand operand,
    RelNode rel,
    List<RelNode> bindings) {
  if (!operand.matches(rel)) {
    return false;
  }
  bindings.add(rel);
  switch (operand.childPolicy) {
  case ANY:
    return true;
  }
  List<RelOptRuleOperand> childOperands = operand.getChildOperands();
  List<? extends RelNode> childRels = rel.getInputs();
  if (childOperands.size() != childRels.size()) {
    return false;
  }
  for (Pair<RelOptRuleOperand, ? extends RelNode> pair
      : Pair.zip(childOperands, childRels)) {
    if (!match(pair.left, pair.right, bindings)) {
      return false;
    }
  }
  return true;
}
 
Example #3
Source File: VolcanoPlanner.java    From calcite with Apache License 2.0 6 votes vote down vote up
@Override protected void onNewClass(RelNode node) {
  super.onNewClass(node);

  final boolean isPhysical = node instanceof PhysicalNode;
  // Create mappings so that instances of this class will match existing
  // operands.
  final Class<? extends RelNode> clazz = node.getClass();
  for (RelOptRule rule : mapDescToRule.values()) {
    if (isPhysical && rule instanceof TransformationRule) {
      continue;
    }
    for (RelOptRuleOperand operand : rule.getOperands()) {
      if (operand.getMatchedClass().isAssignableFrom(clazz)) {
        classOperands.put(clazz, operand);
      }
    }
  }
}
 
Example #4
Source File: FlinkFilterJoinRule.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FlinkFilterJoinRule with an explicit root operand and
 * factories.
 */
@Deprecated // to be removed before 2.0
protected FlinkFilterJoinRule(RelOptRuleOperand operand, String id,
		boolean smart, RelFactories.FilterFactory filterFactory,
		RelFactories.ProjectFactory projectFactory) {
	this(operand, id, smart, RelBuilder.proto(filterFactory, projectFactory),
			TRUE_PREDICATE);
}
 
Example #5
Source File: FilterJoinRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FilterProjectTransposeRule with an explicit root operand and
 * factories.
 */
protected FilterJoinRule(RelOptRuleOperand operand, String id,
    boolean smart, RelBuilderFactory relBuilderFactory, Predicate predicate) {
  super(operand, relBuilderFactory, "FilterJoinRule:" + id);
  this.smart = smart;
  this.predicate = Objects.requireNonNull(predicate);
}
 
Example #6
Source File: FilterJoinRule.java    From calcite with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FilterJoinRule with an explicit root operand and
 * factories.
 */
protected FilterJoinRule(RelOptRuleOperand operand, String id,
    boolean smart, RelBuilderFactory relBuilderFactory, Predicate predicate) {
  super(operand, relBuilderFactory, "FilterJoinRule:" + id);
  this.smart = smart;
  this.predicate = Objects.requireNonNull(predicate);
}
 
Example #7
Source File: VolcanoRuleMatch.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a <code>VolcanoRuleMatch</code>.
 *
 * @param operand0 Primary operand
 * @param rels     List of targets; copied by the constructor, so the client
 *                 can modify it later
 * @param nodeInputs Map from relational expressions to their inputs
 */
VolcanoRuleMatch(VolcanoPlanner volcanoPlanner, RelOptRuleOperand operand0,
    RelNode[] rels, Map<RelNode, List<RelNode>> nodeInputs) {
  super(volcanoPlanner, operand0, rels.clone(), nodeInputs);
  assert allNotNull(rels, Litmus.THROW);

  // Try to deduce which subset the result will belong to. Assume --
  // for now -- that the set is the same as the root relexp.
  targetSet = volcanoPlanner.getSet(rels[0]);
  assert targetSet != null : rels[0].toString() + " isn't in a set";
  digest = computeDigest();
}
 
Example #8
Source File: HepRuleCall.java    From Bats with Apache License 2.0 5 votes vote down vote up
HepRuleCall(
    RelOptPlanner planner,
    RelOptRuleOperand operand,
    RelNode[] rels,
    Map<RelNode, List<RelNode>> nodeChildren,
    List<RelNode> parents) {
  super(planner, operand, rels, nodeChildren, parents);

  results = new ArrayList<>();
}
 
Example #9
Source File: MaterializedViewAggregateRule.java    From calcite with Apache License 2.0 5 votes vote down vote up
/** Creates a MaterializedViewAggregateRule. */
protected MaterializedViewAggregateRule(RelOptRuleOperand operand,
    RelBuilderFactory relBuilderFactory, String description,
    boolean generateUnionRewriting, HepProgram unionRewritingPullProgram) {
  this(operand, relBuilderFactory, description, generateUnionRewriting,
      unionRewritingPullProgram,
      new FilterProjectTransposeRule(
          Filter.class, Project.class, true, true, relBuilderFactory),
      new FilterAggregateTransposeRule(
          Filter.class, relBuilderFactory, Aggregate.class),
      new AggregateProjectPullUpConstantsRule(
          Aggregate.class, Filter.class, relBuilderFactory, "AggFilterPullUpConstants"),
      new ProjectMergeRule(true, ProjectMergeRule.DEFAULT_BLOAT,
          relBuilderFactory));
}
 
Example #10
Source File: FlinkFilterJoinRule.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FlinkFilterJoinRule with an explicit root operand and
 * factories.
 */
@Deprecated // to be removed before 2.0
protected FlinkFilterJoinRule(RelOptRuleOperand operand, String id,
		boolean smart, RelFactories.FilterFactory filterFactory,
		RelFactories.ProjectFactory projectFactory) {
	this(operand, id, smart, RelBuilder.proto(filterFactory, projectFactory),
			TRUE_PREDICATE);
}
 
Example #11
Source File: FilterJoinRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FilterProjectTransposeRule with an explicit root operand and
 * factories.
 */
@Deprecated // to be removed before 2.0
protected FilterJoinRule(RelOptRuleOperand operand, String id,
    boolean smart, RelFactories.FilterFactory filterFactory,
    RelFactories.ProjectFactory projectFactory,
    Predicate predicate) {
  this(operand, id, smart, RelBuilder.proto(filterFactory, projectFactory),
      predicate);
}
 
Example #12
Source File: FlinkFilterJoinRule.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FilterProjectTransposeRule with an explicit root operand and
 * factories.
 */
@Deprecated // to be removed before 2.0
protected FlinkFilterJoinRule(RelOptRuleOperand operand, String id,
		boolean smart, RelFactories.FilterFactory filterFactory,
		RelFactories.ProjectFactory projectFactory,
		Predicate predicate) {
	this(operand, id, smart, RelBuilder.proto(filterFactory, projectFactory),
			predicate);
}
 
Example #13
Source File: AggregateReduceFunctionsRule.java    From calcite with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an AggregateReduceFunctionsRule to reduce all functions
 * handled by this rule
 * @param operand operand to determine if rule can be applied
 * @param relBuilderFactory builder for relational expressions
 */
public AggregateReduceFunctionsRule(RelOptRuleOperand operand,
    RelBuilderFactory relBuilderFactory) {
  super(operand, relBuilderFactory, null);
  functionsToReduce = EnumSet.noneOf(SqlKind.class);
  addDefaultSetOfFunctionsToReduce();
}
 
Example #14
Source File: FlinkFilterJoinRule.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FilterProjectTransposeRule with an explicit root operand and
 * factories.
 */
protected FlinkFilterJoinRule(RelOptRuleOperand operand, String id,
		boolean smart, RelBuilderFactory relBuilderFactory, Predicate predicate) {
	super(operand, relBuilderFactory, "FlinkFilterJoinRule:" + id);
	this.smart = smart;
	this.predicate = Objects.requireNonNull(predicate);
}
 
Example #15
Source File: FilterProjectTransposeRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
protected FilterProjectTransposeRule(
    RelOptRuleOperand operand,
    boolean copyFilter,
    boolean copyProject,
    RelBuilderFactory relBuilderFactory) {
  super(operand, relBuilderFactory, null);
  this.copyFilter = copyFilter;
  this.copyProject = copyProject;
}
 
Example #16
Source File: AbstractMaterializedViewRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
/** Creates a MaterializedViewJoinRule. */
protected MaterializedViewJoinRule(RelOptRuleOperand operand, RelBuilderFactory relBuilderFactory,
        String description, boolean generateUnionRewriting, HepProgram unionRewritingPullProgram,
        boolean fastBailOut) {
    super(operand, relBuilderFactory, description, generateUnionRewriting, unionRewritingPullProgram,
            fastBailOut);
}
 
Example #17
Source File: HepRuleCall.java    From calcite with Apache License 2.0 5 votes vote down vote up
HepRuleCall(
    RelOptPlanner planner,
    RelOptRuleOperand operand,
    RelNode[] rels,
    Map<RelNode, List<RelNode>> nodeChildren,
    List<RelNode> parents) {
  super(planner, operand, rels, nodeChildren, parents);

  results = new ArrayList<>();
}
 
Example #18
Source File: MaterializedViewRule.java    From calcite with Apache License 2.0 5 votes vote down vote up
/** Creates a AbstractMaterializedViewRule. */
protected MaterializedViewRule(RelOptRuleOperand operand,
    RelBuilderFactory relBuilderFactory, String description,
    boolean generateUnionRewriting, HepProgram unionRewritingPullProgram,
    boolean fastBailOut) {
  super(operand, relBuilderFactory, description);
  this.generateUnionRewriting = generateUnionRewriting;
  this.unionRewritingPullProgram = unionRewritingPullProgram;
  this.fastBailOut = fastBailOut;
}
 
Example #19
Source File: MockRelOptPlanner.java    From calcite with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a MockRuleCall.
 *
 * @param planner Planner
 * @param operand Operand
 * @param rels    List of matched relational expressions
 */
MockRuleCall(
    RelOptPlanner planner,
    RelOptRuleOperand operand,
    RelNode[] rels) {
  super(
      planner,
      operand,
      rels,
      Collections.emptyMap());
}
 
Example #20
Source File: ConvertCountToDirectScan.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
private ConvertCountToDirectScan(RelOptRuleOperand rule, String id, int scanIndex, SourceType type) {
  super(rule, "ConvertCountToDirectScan:" + id);
  this.type = type;
  this.scanIndex = scanIndex;
}
 
Example #21
Source File: RelOptHelper.java    From Bats with Apache License 2.0 4 votes vote down vote up
public static RelOptRuleOperand some(Class<? extends RelNode> rel, RelOptRuleOperand first, RelOptRuleOperand... rest){
  return RelOptRule.operand(rel, RelOptRule.some(first, rest));
}
 
Example #22
Source File: MaterializedViewFilterScanRule.java    From quark with Apache License 2.0 4 votes vote down vote up
/** Creates a FilterTableRule. */
protected MaterializedViewFilterScanRule(RelOptRuleOperand operand, String description) {
  super(operand, description);
}
 
Example #23
Source File: DrillPushLimitToScanRule.java    From Bats with Apache License 2.0 4 votes vote down vote up
private DrillPushLimitToScanRule(RelOptRuleOperand operand, String description) {
  super(operand, DrillRelFactories.LOGICAL_BUILDER, description);
}
 
Example #24
Source File: ProjectSortTransposeRule.java    From calcite with Apache License 2.0 4 votes vote down vote up
/** Creates a ProjectSortTransposeRule with an operand. */
protected ProjectSortTransposeRule(RelOptRuleOperand operand,
    RelBuilderFactory relBuilderFactory, String description) {
  super(operand, relBuilderFactory, description);
}
 
Example #25
Source File: AggregateProjectReduceRule.java    From kylin with Apache License 2.0 4 votes vote down vote up
private AggregateProjectReduceRule(RelOptRuleOperand operand, RelBuilderFactory factory, String description) {
    super(operand, factory, description);
}
 
Example #26
Source File: ConvertCountToDirectScanRule.java    From Bats with Apache License 2.0 4 votes vote down vote up
protected ConvertCountToDirectScanRule(RelOptRuleOperand rule, String id) {
  super(rule, "ConvertCountToDirectScanRule:" + id);
}
 
Example #27
Source File: RelOptHelper.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public static RelOptRuleOperand any(Class<? extends RelNode> first, Class<? extends RelNode> second) {
  return RelOptRule.operand(first, RelOptRule.operand(second, RelOptRule.any()));
}
 
Example #28
Source File: AggPruleBase.java    From Bats with Apache License 2.0 4 votes vote down vote up
protected AggPruleBase(RelOptRuleOperand operand, String description) {
  super(operand, description);
}
 
Example #29
Source File: Prule.java    From Bats with Apache License 2.0 4 votes vote down vote up
public Prule(RelOptRuleOperand operand, String description) {
  super(operand, DrillRelFactories.LOGICAL_BUILDER, description);
}
 
Example #30
Source File: RelOptHelper.java    From Bats with Apache License 2.0 4 votes vote down vote up
public static RelOptRuleOperand any(Class<? extends RelNode> first, RelTrait trait){
  return RelOptRule.operand(first, trait, RelOptRule.any());
}