• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RexProgram类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: visitCalc

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
public Result visitCalc(Calc e) {
  Result x = visitChild(0, e.getInput());
  final RexProgram program = e.getProgram();
  Builder builder =
      program.getCondition() != null
          ? x.builder(e, Clause.WHERE)
          : x.builder(e);
  if (!isStar(program)) {
    final List<SqlNode> selectList = new ArrayList<>();
    for (RexLocalRef ref : program.getProjectList()) {
      SqlNode sqlExpr = builder.context.toSql(program, ref);
      addSelect(selectList, sqlExpr, e.getRowType());
    }
    builder.setSelect(new SqlNodeList(selectList, POS));
  }

  if (program.getCondition() != null) {
    builder.setWhere(
        builder.context.toSql(program, program.getCondition()));
  }
  return builder.result();
}
 
开发者ID:qubole,项目名称:quark,代码行数:23,代码来源:RelToSqlConverter.java


示例2: convert

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
public RelNode convert(RelNode rel) {
  final LogicalCalc calc = (LogicalCalc) rel;

  // If there's a multiset, let FarragoMultisetSplitter work on it
  // first.
  final RexProgram program = calc.getProgram();
  if (RexMultisetUtil.containsMultiset(program)
      || program.containsAggs()) {
    return null;
  }

  return new SparkCalc(
      rel.getCluster(),
      rel.getTraitSet().replace(SparkRel.CONVENTION),
      convert(calc.getInput(),
          calc.getInput().getTraitSet().replace(SparkRel.CONVENTION)),
      program);
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:SparkRules.java


示例3: create

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
public static LogicalCalc create(final RelNode input,
    final RexProgram program) {
  final RelOptCluster cluster = input.getCluster();
  final RelMetadataQuery mq = cluster.getMetadataQuery();
  final RelTraitSet traitSet = cluster.traitSet()
      .replace(Convention.NONE)
      .replaceIfs(RelCollationTraitDef.INSTANCE,
          new Supplier<List<RelCollation>>() {
            public List<RelCollation> get() {
              return RelMdCollation.calc(mq, input, program);
            }
          })
      .replaceIf(RelDistributionTraitDef.INSTANCE,
          new Supplier<RelDistribution>() {
            public RelDistribution get() {
              return RelMdDistribution.calc(mq, input, program);
            }
          });
  return new LogicalCalc(cluster, traitSet, input, program);
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:LogicalCalc.java


示例4: toSql

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
private SqlNode toSql(RexProgram program, RexFieldCollation rfc) {
  SqlNode node = toSql(program, rfc.left);
  switch (rfc.getDirection()) {
  case DESCENDING:
  case STRICTLY_DESCENDING:
    node = SqlStdOperatorTable.DESC.createCall(POS, node);
  }
  if (rfc.getNullDirection()
          != dialect.defaultNullDirection(rfc.getDirection())) {
    switch (rfc.getNullDirection()) {
    case FIRST:
      node = SqlStdOperatorTable.NULLS_FIRST.createCall(POS, node);
      break;
    case LAST:
      node = SqlStdOperatorTable.NULLS_LAST.createCall(POS, node);
      break;
    }
  }
  return node;
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:SqlImplementor.java


示例5: visit

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
/** @see #dispatch */
public Result visit(Calc e) {
  Result x = visitChild(0, e.getInput());
  parseCorrelTable(e, x);
  final RexProgram program = e.getProgram();
  Builder builder =
      program.getCondition() != null
          ? x.builder(e, Clause.WHERE)
          : x.builder(e);
  if (!isStar(program)) {
    final List<SqlNode> selectList = new ArrayList<>();
    for (RexLocalRef ref : program.getProjectList()) {
      SqlNode sqlExpr = builder.context.toSql(program, ref);
      addSelect(selectList, sqlExpr, e.getRowType());
    }
    builder.setSelect(new SqlNodeList(selectList, POS));
  }

  if (program.getCondition() != null) {
    builder.setWhere(
        builder.context.toSql(program, program.getCondition()));
  }
  return builder.result();
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:RelToSqlConverter.java


示例6: onMatch

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
  final EnumerableFilter filter = call.rel(0);
  final RelNode input = filter.getInput();

  // Create a program containing a filter.
  final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
  final RelDataType inputRowType = input.getRowType();
  final RexProgramBuilder programBuilder =
      new RexProgramBuilder(inputRowType, rexBuilder);
  programBuilder.addIdentity();
  programBuilder.addCondition(filter.getCondition());
  final RexProgram program = programBuilder.getProgram();

  final EnumerableCalc calc = EnumerableCalc.create(input, program);
  call.transformTo(calc);
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:EnumerableFilterToCalcRule.java


示例7: RexToLixTranslator

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
private RexToLixTranslator(
    RexProgram program,
    JavaTypeFactory typeFactory,
    Expression root,
    InputGetter inputGetter,
    BlockBuilder list,
    Map<? extends RexNode, Boolean> exprNullableMap,
    RexBuilder builder,
    RexToLixTranslator parent,
    Function1<String, InputGetter> correlates) {
  this.program = program;
  this.typeFactory = typeFactory;
  this.root = root;
  this.inputGetter = inputGetter;
  this.list = list;
  this.exprNullableMap = exprNullableMap;
  this.builder = builder;
  this.parent = parent;
  this.correlates = correlates;
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:RexToLixTranslator.java


示例8: translateProjects

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
/**
 * Translates a {@link RexProgram} to a sequence of expressions and
 * declarations.
 *
 * @param program Program to be translated
 * @param typeFactory Type factory
 * @param list List of statements, populated with declarations
 * @param outputPhysType Output type, or null
 * @param root Root expression
 * @param inputGetter Generates expressions for inputs
 * @param correlates Provider of references to the values of correlated
 *                   variables
 * @return Sequence of expressions, optional condition
 */
public static List<Expression> translateProjects(RexProgram program,
    JavaTypeFactory typeFactory,
    BlockBuilder list,
    PhysType outputPhysType,
    Expression root,
    InputGetter inputGetter,
    Function1<String, InputGetter> correlates) {
  List<Type> storageTypes = null;
  if (outputPhysType != null) {
    final RelDataType rowType = outputPhysType.getRowType();
    storageTypes = new ArrayList<>(rowType.getFieldCount());
    for (int i = 0; i < rowType.getFieldCount(); i++) {
      storageTypes.add(outputPhysType.getJavaFieldType(i));
    }
  }
  return new RexToLixTranslator(program, typeFactory, root, inputGetter, list)
      .setCorrelates(correlates)
      .translateList(program.getProjectList(), storageTypes);
}
 
开发者ID:apache,项目名称:calcite,代码行数:34,代码来源:RexToLixTranslator.java


示例9: translateCondition

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
public static Expression translateCondition(
    RexProgram program,
    JavaTypeFactory typeFactory,
    BlockBuilder list,
    InputGetter inputGetter,
    Function1<String, InputGetter> correlates) {
  if (program.getCondition() == null) {
    return RexImpTable.TRUE_EXPR;
  }
  final ParameterExpression root = DataContext.ROOT;
  RexToLixTranslator translator =
      new RexToLixTranslator(program, typeFactory, root, inputGetter, list);
  translator = translator.setCorrelates(correlates);
  return translator.translate(
      program.getCondition(),
      RexImpTable.NullAs.FALSE);
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:RexToLixTranslator.java


示例10: create

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
/** Creates an EnumerableCalc. */
public static EnumerableCalc create(final RelNode input,
    final RexProgram program) {
  final RelOptCluster cluster = input.getCluster();
  final RelMetadataQuery mq = cluster.getMetadataQuery();
  final RelTraitSet traitSet = cluster.traitSet()
      .replace(EnumerableConvention.INSTANCE)
      .replaceIfs(RelCollationTraitDef.INSTANCE,
          new Supplier<List<RelCollation>>() {
            public List<RelCollation> get() {
              return RelMdCollation.calc(mq, input, program);
            }
          })
      .replaceIf(RelDistributionTraitDef.INSTANCE,
          new Supplier<RelDistribution>() {
            public RelDistribution get() {
              return RelMdDistribution.calc(mq, input, program);
            }
          });
  return new EnumerableCalc(cluster, traitSet, input, program);
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:EnumerableCalc.java


示例11: testBuildProgram

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
/**
 * Tests construction of a RexProgram.
 */
@Test public void testBuildProgram() {
  final RexProgramBuilder builder = createProg(0);
  final RexProgram program = builder.getProgram(false);
  final String programString = program.toString();
  TestUtil.assertEqualsVerbose(
      "(expr#0..1=[{inputs}], expr#2=[+($0, 1)], expr#3=[77], "
          + "expr#4=[+($0, $1)], expr#5=[+($0, $0)], expr#6=[+($t4, $t2)], "
          + "a=[$t6], b=[$t5])",
      programString);

  // Normalize the program using the RexProgramBuilder.normalize API.
  // Note that unused expression '77' is eliminated, input refs (e.g. $0)
  // become local refs (e.g. $t0), and constants are assigned to locals.
  final RexProgram normalizedProgram = program.normalize(rexBuilder, null);
  final String normalizedProgramString = normalizedProgram.toString();
  TestUtil.assertEqualsVerbose(
      "(expr#0..1=[{inputs}], expr#2=[+($t0, $t1)], expr#3=[1], "
          + "expr#4=[+($t0, $t3)], expr#5=[+($t2, $t4)], "
          + "expr#6=[+($t0, $t0)], a=[$t5], b=[$t6])",
      normalizedProgramString);
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:RexProgramTest.java


示例12: testSimplifyCondition

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
/**
 * Tests how the condition is simplified.
 */
@Test public void testSimplifyCondition() {
  final RexProgram program = createProg(3).getProgram(false);
  assertThat(program.toString(),
      is("(expr#0..1=[{inputs}], expr#2=[+($0, 1)], expr#3=[77], "
          + "expr#4=[+($0, $1)], expr#5=[+($0, 1)], expr#6=[+($0, $t5)], "
          + "expr#7=[+($t4, $t2)], expr#8=[5], expr#9=[>($t2, $t8)], "
          + "expr#10=[true], expr#11=[IS NOT NULL($t5)], expr#12=[false], "
          + "expr#13=[null], expr#14=[CASE($t9, $t10, $t11, $t12, $t13)], "
          + "expr#15=[NOT($t14)], a=[$t7], b=[$t6], $condition=[$t15])"));

  assertThat(program.normalize(rexBuilder, simplify).toString(),
      is("(expr#0..1=[{inputs}], expr#2=[+($t0, $t1)], expr#3=[1], "
          + "expr#4=[+($t0, $t3)], expr#5=[+($t2, $t4)], "
          + "expr#6=[+($t0, $t4)], expr#7=[5], expr#8=[>($t4, $t7)], "
          + "expr#9=[CAST($t8):BOOLEAN], expr#10=[IS FALSE($t9)], "
          + "a=[$t5], b=[$t6], $condition=[$t10])"));
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:RexProgramTest.java


示例13: testSimplifyCondition2

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
/**
 * Tests how the condition is simplified.
 */
@Test public void testSimplifyCondition2() {
  final RexProgram program = createProg(4).getProgram(false);
  assertThat(program.toString(),
      is("(expr#0..1=[{inputs}], expr#2=[+($0, 1)], expr#3=[77], "
          + "expr#4=[+($0, $1)], expr#5=[+($0, 1)], expr#6=[+($0, $t5)], "
          + "expr#7=[+($t4, $t2)], expr#8=[5], expr#9=[>($t2, $t8)], "
          + "expr#10=[true], expr#11=[IS NOT NULL($t5)], expr#12=[false], "
          + "expr#13=[null], expr#14=[CASE($t9, $t10, $t11, $t12, $t13)], "
          + "expr#15=[NOT($t14)], expr#16=[IS TRUE($t15)], a=[$t7], b=[$t6], "
          + "$condition=[$t16])"));

  assertThat(program.normalize(rexBuilder, simplify).toString(),
      is("(expr#0..1=[{inputs}], expr#2=[+($t0, $t1)], expr#3=[1], "
          + "expr#4=[+($t0, $t3)], expr#5=[+($t2, $t4)], "
          + "expr#6=[+($t0, $t4)], expr#7=[5], expr#8=[>($t4, $t7)], "
          + "expr#9=[CAST($t8):BOOLEAN], expr#10=[IS FALSE($t9)], "
          + "a=[$t5], b=[$t6], $condition=[$t10])"));
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:RexProgramTest.java


示例14: onMatch

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
    Filter topFilter = call.rel(0);
    Filter bottomFilter = call.rel(1);

    // use RexPrograms to merge the two FilterRels into a single program
    // so we can convert the two FilterRel conditions to directly
    // reference the bottom FilterRel's child
    RexBuilder rexBuilder = topFilter.getCluster().getRexBuilder();
    RexProgram bottomProgram = createProgram(bottomFilter);
    RexProgram topProgram = createProgram(topFilter);

    RexProgram mergedProgram =
        RexProgramBuilder.mergePrograms(
            topProgram,
            bottomProgram,
            rexBuilder);

    RexNode newCondition =
        mergedProgram.expandLocalRef(
            mergedProgram.getCondition());

//    if(!RexUtil.isFlat(newCondition)){
//      RexCall newCall = (RexCall) newCondition;
//      newCondition = rexBuilder.makeFlatCall( newCall.getOperator(), newCall.getOperands());
//    }

    Filter newFilterRel =
        (Filter) filterFactory.createFilter(
            bottomFilter.getInput(),
            RexUtil.flatten(rexBuilder, newCondition));

    call.transformTo(newFilterRel);
  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:34,代码来源:DrillMergeFilterRule.java


示例15: createProgram

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
/**
 * Creates a RexProgram corresponding to a LogicalFilter
 *
 * @param filterRel the LogicalFilter
 * @return created RexProgram
 */
private RexProgram createProgram(Filter filterRel) {
  RexProgramBuilder programBuilder =
      new RexProgramBuilder(
          filterRel.getRowType(),
          filterRel.getCluster().getRexBuilder());
  programBuilder.addIdentity();
  programBuilder.addCondition(filterRel.getCondition());
  return programBuilder.getProgram();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:16,代码来源:DrillMergeFilterRule.java


示例16: copyOf

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
public RexProgram copyOf(RexProgram program) {
  return new RexProgram(
    copyOf(program.getInputRowType()),
    copyRexNodes(program.getExprList()),
    Lists.transform(program.getProjectList(), COPY_REX_LOCAL_REF),
    (RexLocalRef) copyOf(program.getCondition()),
    copyOf(program.getOutputRowType())
  );
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:10,代码来源:CopyWithCluster.java


示例17: getExpression

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
/**
 * Create quasi-Java expression from given {@link RexNode}
 *
 * @param node Expression in the form of {@link RexNode}
 * @param inputRowType Input Data type to expression in the form of {@link RelDataType}
 * @param outputRowType Output data type of expression in the form of {@link RelDataType}
 *
 * @return Returns quasi-Java expression
 */
public String getExpression(RexNode node, RelDataType inputRowType, RelDataType outputRowType)
{
  final RexProgramBuilder programBuilder = new RexProgramBuilder(inputRowType, rexBuilder);
  programBuilder.addProject(node, null);
  final RexProgram program = programBuilder.getProgram();

  final BlockBuilder builder = new BlockBuilder();
  final JavaTypeFactory javaTypeFactory = (JavaTypeFactory)rexBuilder.getTypeFactory();

  final RexToLixTranslator.InputGetter inputGetter = new RexToLixTranslator.InputGetterImpl(ImmutableList
      .of(Pair.<Expression, PhysType>of(Expressions.variable(Object[].class, "inputValues"),
      PhysTypeImpl.of(javaTypeFactory, inputRowType, JavaRowFormat.ARRAY, false))));
  final Function1<String, RexToLixTranslator.InputGetter> correlates =
      new Function1<String, RexToLixTranslator.InputGetter>()
    {
      public RexToLixTranslator.InputGetter apply(String a0)
      {
        throw new UnsupportedOperationException();
      }
    };

  final List<Expression> list = RexToLixTranslator.translateProjects(program, javaTypeFactory, builder,
      PhysTypeImpl.of(javaTypeFactory, outputRowType, JavaRowFormat.ARRAY, false), null, inputGetter, correlates);

  for (int i = 0; i < list.size(); i++) {
    Statement statement = Expressions.statement(list.get(i));
    builder.add(statement);
  }

  return finalizeExpression(builder.toBlock(), inputRowType);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:41,代码来源:ExpressionCompiler.java


示例18: toSql

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
private List<SqlNode> toSql(RexProgram program, List<RexNode> operandList) {
    final List<SqlNode> list = new ArrayList<>();
    for (RexNode rex : operandList) {
        list.add(toSql(program, rex));
    }
    return list;
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:8,代码来源:JdbcImplementor.java


示例19: isStar

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
private static boolean isStar(RexProgram program) {
    int i = 0;
    for (RexLocalRef ref : program.getProjectList()) {
        if (ref.getIndex() != i++) {
            return false;
        }
    }
    return i == program.getInputRowType().getFieldCount();
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:10,代码来源:JdbcRules.java


示例20: JdbcCalc

import org.apache.calcite.rex.RexProgram; //导入依赖的package包/类
public JdbcCalc(RelOptCluster cluster,
                RelTraitSet traitSet,
                RelNode input,
                RexProgram program) {
    super(cluster, traitSet, input);
    assert getConvention() instanceof JdbcConvention;
    this.program = program;
    this.rowType = program.getOutputRowType();
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:10,代码来源:JdbcRules.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Thumbnail类代码示例发布时间:2022-05-22
下一篇:
Java JPEGImageReader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap