当前位置: 首页>>代码示例>>Java>>正文


Java RelOptPredicateList类代码示例

本文整理汇总了Java中org.apache.calcite.plan.RelOptPredicateList的典型用法代码示例。如果您正苦于以下问题:Java RelOptPredicateList类的具体用法?Java RelOptPredicateList怎么用?Java RelOptPredicateList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RelOptPredicateList类属于org.apache.calcite.plan包,在下文中一共展示了RelOptPredicateList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: numReducibleExprs

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
public static int numReducibleExprs(Project project) {
  final List<RexNode> expList = Lists.newArrayList(project.getProjects());
  final RelMetadataQuery mq = RelMetadataQuery.instance(DefaultRelMetadataProvider.INSTANCE);
  final RelOptPredicateList predicates = mq.getPulledUpPredicates(project.getInput());
  boolean reducible = reduceExpressions(project, expList, predicates);
  if (reducible) {
    int numReducible = 0;
    for (int i = 0; i < project.getProjects().size(); i++) {
      if (!project.getProjects().get(i).toString().equals(expList.get(i).toString())) {
        numReducible++;
      }
    }
    return numReducible;
  } else {
    return 0;
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:ReduceExpressionsUtil.java

示例2: getPredicates

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
/** Infers predicates for a {@link org.apache.calcite.rel.core.SemiJoin}. */
public RelOptPredicateList getPredicates(SemiJoin semiJoin,
    RelMetadataQuery mq) {
  RexBuilder rB = semiJoin.getCluster().getRexBuilder();
  final RelNode left = semiJoin.getInput(0);
  final RelNode right = semiJoin.getInput(1);

  final RelOptPredicateList leftInfo = mq.getPulledUpPredicates(left);
  final RelOptPredicateList rightInfo = mq.getPulledUpPredicates(right);

  JoinConditionBasedPredicateInference jI =
      new JoinConditionBasedPredicateInference(semiJoin,
          RexUtil.composeConjunction(rB, leftInfo.pulledUpPredicates, false),
          RexUtil.composeConjunction(rB, rightInfo.pulledUpPredicates, false));

  return jI.inferPredicates(false);
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:RelMdPredicates.java

示例3: onMatch

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
@Override public void onMatch(RelOptRuleCall call) {
  final Project project = call.rel(0);
  final RelMetadataQuery mq = call.getMetadataQuery();
  final RelOptPredicateList predicates =
      mq.getPulledUpPredicates(project.getInput());
  final List<RexNode> expList =
      Lists.newArrayList(project.getProjects());
  if (reduceExpressions(project, expList, predicates, false,
      matchNullability)) {
    call.transformTo(
        call.builder()
            .push(project.getInput())
            .project(expList, project.getRowType().getFieldNames())
            .build());

    // New plan is absolutely better than old plan.
    call.getPlanner().setImportance(project, 0.0);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:ReduceExpressionsRule.java

示例4: create

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
@Deprecated // to be removed before 2.0
public static RexProgramBuilder create(
    RexBuilder rexBuilder,
    final RelDataType inputRowType,
    final List<RexNode> exprList,
    final List<? extends RexNode> projectList,
    final RexNode condition,
    final RelDataType outputRowType,
    boolean normalize,
    boolean simplify_) {
  RexSimplify simplify = null;
  if (simplify_) {
    simplify = new RexSimplify(rexBuilder, RelOptPredicateList.EMPTY, false,
        RexUtil.EXECUTOR);
  }
  return new RexProgramBuilder(rexBuilder, inputRowType, exprList,
      projectList, condition, outputRowType, normalize, simplify);
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:RexProgramBuilder.java

示例5: testAllPredicatesAggregate1

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
@Test public void testAllPredicatesAggregate1() {
  final String sql = "select a, max(b) from (\n"
      + "  select empno as a, sal as b from emp where empno = 5)subq\n"
      + "group by a";
  final RelNode rel = convertSql(sql);
  final RelMetadataQuery mq = RelMetadataQuery.instance();
  RelOptPredicateList inputSet = mq.getAllPredicates(rel);
  ImmutableList<RexNode> pulledUpPredicates = inputSet.pulledUpPredicates;
  assertThat(pulledUpPredicates.size(), is(1));
  RexCall call = (RexCall) pulledUpPredicates.get(0);
  assertThat(call.getOperands().size(), is(2));
  final RexTableInputRef inputRef1 = (RexTableInputRef) call.getOperands().get(0);
  assertTrue(inputRef1.getQualifiedName().equals(EMP_QNAME));
  assertThat(inputRef1.getIndex(), is(0));
  final RexLiteral constant = (RexLiteral) call.getOperands().get(1);
  assertThat(constant.toString(), is("5"));
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:RelMetadataTest.java

示例6: testAllPredicatesAggregate2

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
@Test public void testAllPredicatesAggregate2() {
  final String sql = "select * from (select a, max(b) from (\n"
      + "  select empno as a, sal as b from emp)subq\n"
      + "group by a) \n"
      + "where a = 5";
  final RelNode rel = convertSql(sql);
  final RelMetadataQuery mq = RelMetadataQuery.instance();
  RelOptPredicateList inputSet = mq.getAllPredicates(rel);
  ImmutableList<RexNode> pulledUpPredicates = inputSet.pulledUpPredicates;
  assertThat(pulledUpPredicates.size(), is(1));
  RexCall call = (RexCall) pulledUpPredicates.get(0);
  assertThat(call.getOperands().size(), is(2));
  final RexTableInputRef inputRef1 = (RexTableInputRef) call.getOperands().get(0);
  assertTrue(inputRef1.getQualifiedName().equals(EMP_QNAME));
  assertThat(inputRef1.getIndex(), is(0));
  final RexLiteral constant = (RexLiteral) call.getOperands().get(1);
  assertThat(constant.toString(), is("5"));
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:RelMetadataTest.java

示例7: testAllPredicatesAndTableUnion

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
@Test public void testAllPredicatesAndTableUnion() {
  final String sql = "select a.deptno, c.sal from (select * from emp limit 7) as a\n"
      + "cross join (select * from dept limit 1) as b\n"
      + "inner join (select * from emp limit 2) as c\n"
      + "on a.deptno = c.deptno\n"
      + "union all\n"
      + "select a.deptno, c.sal from (select * from emp limit 7) as a\n"
      + "cross join (select * from dept limit 1) as b\n"
      + "inner join (select * from emp limit 2) as c\n"
      + "on a.deptno = c.deptno";
  final RelNode rel = convertSql(sql);
  final RelMetadataQuery mq = RelMetadataQuery.instance();
  final RelOptPredicateList inputSet = mq.getAllPredicates(rel);
  assertThat(inputSet.pulledUpPredicates.toString(),
      equalTo("[true, "
          + "=([CATALOG, SALES, EMP].#0.$7, [CATALOG, SALES, EMP].#1.$7), "
          + "true, "
          + "=([CATALOG, SALES, EMP].#2.$7, [CATALOG, SALES, EMP].#3.$7)]"));
  final Set<RelTableRef> tableReferences = Sets.newTreeSet(mq.getTableReferences(rel));
  assertThat(tableReferences.toString(),
      equalTo("[[CATALOG, SALES, DEPT].#0, [CATALOG, SALES, DEPT].#1, "
          + "[CATALOG, SALES, EMP].#0, [CATALOG, SALES, EMP].#1, "
          + "[CATALOG, SALES, EMP].#2, [CATALOG, SALES, EMP].#3]"));
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:RelMetadataTest.java

示例8: getPulledUpPredicates

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
/**
 * Returns the
 * {@link BuiltInMetadata.Predicates#getPredicates()}
 * statistic.
 *
 * @param rel the relational expression
 * @return Predicates that can be pulled above this RelNode
 */
public RelOptPredicateList getPulledUpPredicates(RelNode rel) {
  for (;;) {
    try {
      return predicatesHandler.getPredicates(rel, this);
    } catch (JaninoRelMetadataProvider.NoHandler e) {
      predicatesHandler = revise(e.relClass, BuiltInMetadata.Predicates.DEF);
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:RelMetadataQuery.java

示例9: getAllPredicates

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
/**
 * Returns the
 * {@link BuiltInMetadata.AllPredicates#getAllPredicates()}
 * statistic.
 *
 * @param rel the relational expression
 * @return All predicates within and below this RelNode
 */
public RelOptPredicateList getAllPredicates(RelNode rel) {
  for (;;) {
    try {
      return allPredicatesHandler.getAllPredicates(rel, this);
    } catch (JaninoRelMetadataProvider.NoHandler e) {
      allPredicatesHandler = revise(e.relClass, BuiltInMetadata.AllPredicates.DEF);
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:RelMetadataQuery.java

示例10: getAllPredicates

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
/**
 * Add the Filter condition to the list obtained from the input.
 */
public RelOptPredicateList getAllPredicates(Filter filter, RelMetadataQuery mq) {
  final RelNode input = filter.getInput();
  final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
  final RexNode pred = filter.getCondition();

  final RelOptPredicateList predsBelow = mq.getAllPredicates(input);
  if (predsBelow == null) {
    // Safety check
    return null;
  }

  // Extract input fields referenced by Filter condition
  final Set<RelDataTypeField> inputExtraFields = new LinkedHashSet<>();
  final RelOptUtil.InputFinder inputFinder = new RelOptUtil.InputFinder(inputExtraFields);
  pred.accept(inputFinder);
  final ImmutableBitSet inputFieldsUsed = inputFinder.inputBitSet.build();

  // Infer column origin expressions for given references
  final Map<RexInputRef, Set<RexNode>> mapping = new LinkedHashMap<>();
  for (int idx : inputFieldsUsed) {
    final RexInputRef ref = RexInputRef.of(idx, filter.getRowType().getFieldList());
    final Set<RexNode> originalExprs = mq.getExpressionLineage(filter, ref);
    if (originalExprs == null) {
      // Bail out
      return null;
    }
    mapping.put(ref, originalExprs);
  }

  // Replace with new expressions and return union of predicates
  return predsBelow.union(rexBuilder,
      RelOptPredicateList.of(rexBuilder,
          RelMdExpressionLineage.createAllPossibleExpressions(rexBuilder, pred, mapping)));
}
 
开发者ID:apache,项目名称:calcite,代码行数:38,代码来源:RelMdAllPredicates.java

示例11: normalize

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
@Deprecated // to be removed before 2.0
public RexProgram normalize(RexBuilder rexBuilder, boolean simplify) {
  final RelOptPredicateList predicates = RelOptPredicateList.EMPTY;
  return normalize(rexBuilder, simplify
      ? new RexSimplify(rexBuilder, predicates, false, RexUtil.EXECUTOR)
      : null);
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:RexProgram.java

示例12: simplifyAnds

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
/**
 * Simplifies a conjunction of boolean expressions.
 *
 * @deprecated Use {@link RexSimplify#simplifyAnds(Iterable)},
 * which allows you to specify an {@link RexExecutor}.
 */
@Deprecated // to be removed before 2.0
public static RexNode simplifyAnds(RexBuilder rexBuilder,
    Iterable<? extends RexNode> nodes) {
  return new RexSimplify(rexBuilder, RelOptPredicateList.EMPTY, false,
      EXECUTOR).simplifyAnds(nodes);
}
 
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:RexUtil.java

示例13: simplifyAnd2ForUnknownAsFalse

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
@Deprecated // to be removed before 2.0
public static RexNode simplifyAnd2ForUnknownAsFalse(RexBuilder rexBuilder,
    List<RexNode> terms, List<RexNode> notTerms) {
  final Class<Comparable> clazz = Comparable.class;
  return new RexSimplify(rexBuilder, RelOptPredicateList.EMPTY, true,
      EXECUTOR).simplifyAnd2ForUnknownAsFalse(terms, notTerms);
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:RexUtil.java

示例14: checkMetadataPredicates

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
/** Helper method for testing {@link RelMetadataQuery#getPulledUpPredicates}
 * metadata. */
private void checkMetadataPredicates(String sql,
    String expectedPredicates) throws Exception {
  Planner planner = getPlanner(null);
  SqlNode parse = planner.parse(sql);
  SqlNode validate = planner.validate(parse);
  RelNode rel = planner.rel(validate).project();
  final RelMetadataQuery mq = RelMetadataQuery.instance();
  final RelOptPredicateList predicates = mq.getPulledUpPredicates(rel);
  final String buf = predicates.pulledUpPredicates.toString();
  assertThat(buf, equalTo(expectedPredicates));
}
 
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:PlannerTest.java

示例15: testPullUpPredicatesFromAggregation

import org.apache.calcite.plan.RelOptPredicateList; //导入依赖的package包/类
/**
 * Unit test for
 * {@link org.apache.calcite.rel.metadata.RelMdPredicates#getPredicates(Aggregate, RelMetadataQuery)}.
 */
@Test public void testPullUpPredicatesFromAggregation() {
  final String sql = "select a, max(b) from (\n"
      + "  select 1 as a, 2 as b from emp)subq\n"
      + "group by a";
  final Aggregate rel = (Aggregate) convertSql(sql);
  final RelMetadataQuery mq = RelMetadataQuery.instance();
  RelOptPredicateList inputSet = mq.getPulledUpPredicates(rel);
  ImmutableList<RexNode> pulledUpPredicates = inputSet.pulledUpPredicates;
  assertThat(pulledUpPredicates, sortsAs("[=($0, 1)]"));
}
 
开发者ID:apache,项目名称:calcite,代码行数:15,代码来源:RelMetadataTest.java


注:本文中的org.apache.calcite.plan.RelOptPredicateList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。