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

Java RexShuttle类代码示例

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

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



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

示例1: visit

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
@Override
public RelNode visit(final LogicalFilter filter) {
  final RelBuilder relBuilder = newCalciteRelBuilderWithoutContext(filter.getCluster());
  RelNode input = filter.getInput().accept(this);
  relBuilder.push(input);

  RexNode newCondition = filter.getCondition().accept(new RexShuttle() {
    @Override
    public RexNode visitInputRef(RexInputRef inputRef) {
      return relBuilder.field(filter.getRowType().getFieldNames().get(inputRef.getIndex()));
    }
  });

  relBuilder.filter(newCondition);
  return relBuilder.build();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:IncrementalUpdateUtils.java


示例2: shuttleReferences

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
/**
 * Replaces all the input references by the position in the
 * input column set. If a reference index cannot be found in
 * the input set, then we return null.
 */
private static RexNode shuttleReferences(final RexBuilder rexBuilder,
    final RexNode node, final Mapping mapping) {
  try {
    RexShuttle visitor =
        new RexShuttle() {
          @Override public RexNode visitInputRef(RexInputRef inputRef) {
            int pos = mapping.getTargetOpt(inputRef.getIndex());
            if (pos != -1) {
              // Found it
              return rexBuilder.makeInputRef(inputRef.getType(), pos);
            }
            throw Util.FoundOne.NULL;
          }
        };
    return visitor.apply(node);
  } catch (Util.FoundOne ex) {
    Util.swallow(ex, null);
    return null;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:AbstractMaterializedViewRule.java


示例3: accept

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
public RelNode accept(RexShuttle shuttle) {
  RexNode joinFilter = shuttle.apply(this.joinFilter);
  List<RexNode> outerJoinConditions = shuttle.apply(this.outerJoinConditions);
  RexNode postJoinFilter = shuttle.apply(this.postJoinFilter);

  if (joinFilter == this.joinFilter
      && outerJoinConditions == this.outerJoinConditions
      && postJoinFilter == this.postJoinFilter) {
    return this;
  }

  return new MultiJoin(
      getCluster(),
      inputs,
      joinFilter,
      rowType,
      isFullOuterJoin,
      outerJoinConditions,
      joinTypes,
      projFields,
      joinFieldRefCountsMap,
      postJoinFilter);
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:MultiJoin.java


示例4: transformRex

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
private static List<RexNode> transformRex(
    List<RexNode> nodes,
    final List<RelDataTypeField> oldFields,
    final List<RelDataTypeField> newFields) {
  RexShuttle shuttle = new RexShuttle() {
    @Override public RexNode visitInputRef(RexInputRef ref) {
      RelDataTypeField f = oldFields.get(ref.getIndex());
      for (int index = 0; index < newFields.size(); index++) {
        RelDataTypeField newf = newFields.get(index);
        if (f.getKey().equals(newf.getKey())
            && f.getValue() == newf.getValue()) {
          return new RexInputRef(index, f.getValue());
        }
      }
      throw MatchFailed.INSTANCE;
    }
  };
  return shuttle.apply(nodes);
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:MaterializedViewSubstitutionVisitor.java


示例5: apply

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
public UnifyResult apply(UnifyRuleCall call) {
  final MutableProject target = (MutableProject) call.target;
  final MutableScan query = (MutableScan) call.query;
  // We do not need to check query's parent type to avoid duplication
  // of ProjectToProjectUnifyRule or FilterToProjectUnifyRule, since
  // SubstitutionVisitor performs a top-down match.
  if (!query.equals(target.getInput())) {
    return null;
  }
  final RexShuttle shuttle = getRexShuttle(target);
  final RexBuilder rexBuilder = target.cluster.getRexBuilder();
  final List<RexNode> newProjects;
  try {
    newProjects = (List<RexNode>)
        shuttle.apply(rexBuilder.identityProjects(query.rowType));
  } catch (MatchFailed e) {
    return null;
  }
  final MutableProject newProject =
      MutableProject.of(query.rowType, target, newProjects);
  final MutableRel newProject2 = MutableRels.strip(newProject);
  return call.result(newProject2);
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:SubstitutionVisitor.java


示例6: onMatch

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
  LogicalCalc calc = call.rel(0);

  // Expand decimals in every expression in this program. If no
  // expression changes, don't apply the rule.
  final RexProgram program = calc.getProgram();
  if (!RexUtil.requiresDecimalExpansion(program, true)) {
    return;
  }

  final RexBuilder rexBuilder = calc.getCluster().getRexBuilder();
  final RexShuttle shuttle = new DecimalShuttle(rexBuilder);
  RexProgramBuilder programBuilder =
      RexProgramBuilder.create(
          rexBuilder,
          calc.getInput().getRowType(),
          program.getExprList(),
          program.getProjectList(),
          program.getCondition(),
          program.getOutputRowType(),
          shuttle,
          true);

  final RexProgram newProgram = programBuilder.getProgram();
  LogicalCalc newCalc = LogicalCalc.create(calc.getInput(), newProgram);
  call.transformTo(newCalc);
}
 
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:ReduceDecimalsRule.java


示例7: accept

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
public RelNode accept(RexShuttle shuttle) {
  List<RexNode> oldExprs = program.getExprList();
  List<RexNode> exprs = shuttle.apply(oldExprs);
  List<RexLocalRef> oldProjects = program.getProjectList();
  List<RexLocalRef> projects = shuttle.apply(oldProjects);
  RexLocalRef oldCondition = program.getCondition();
  RexNode condition;
  if (oldCondition != null) {
    condition = shuttle.apply(oldCondition);
    assert condition instanceof RexLocalRef
        : "Invalid condition after rewrite. Expected RexLocalRef, got "
        + condition;
  } else {
    condition = null;
  }
  if (exprs == oldExprs
      && projects == oldProjects
      && condition == oldCondition) {
    return this;
  }
  return copy(traitSet, getInput(),
      new RexProgram(program.getInputRowType(),
          exprs,
          projects,
          (RexLocalRef) condition,
          program.getOutputRowType()));
}
 
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:Calc.java


示例8: accept

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
@Override public RelNode accept(RexShuttle shuttle) {
  RexNode condition = shuttle.apply(this.condition);
  if (this.condition == condition) {
    return this;
  }
  return copy(traitSet, condition, left, right, joinType, isSemiJoinDone());
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:Join.java


示例9: accept

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
public RelNode accept(RexShuttle shuttle) {
  RexNode condition = shuttle.apply(this.condition);
  if (this.condition == condition) {
    return this;
  }
  return copy(traitSet, getInput(), condition);
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:Filter.java


示例10: accept

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
public RelNode accept(RexShuttle shuttle) {
  RexNode offset = shuttle.apply(this.offset);
  RexNode fetch = shuttle.apply(this.fetch);
  List<RexNode> fieldExps = shuttle.apply(this.fieldExps);
  assert fieldExps == this.fieldExps
      : "Sort node does not support modification of input field expressions."
        + " Old expressions: " + this.fieldExps + ", new ones: " + fieldExps;
  if (offset == this.offset
      && fetch == this.fetch) {
    return this;
  }
  return copy(traitSet, getInput(), collation, offset, fetch);
}
 
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:Sort.java


示例11: accept

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
public RelNode accept(RexShuttle shuttle) {
  List<RexNode> exps = shuttle.apply(this.exps);
  if (this.exps == exps) {
    return this;
  }
  return copy(traitSet, getInput(), exps, rowType);
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:Project.java


示例12: accept

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
public RelNode accept(RexShuttle shuttle) {
  RexNode rexCall = shuttle.apply(this.rexCall);
  if (rexCall == this.rexCall) {
    return this;
  }
  return copy(traitSet, inputs, rexCall, elementType, rowType,
      columnMappings);
}
 
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:TableFunctionScan.java


示例13: pushShuttle

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
private static RexShuttle pushShuttle(final Project project) {
  return new RexShuttle() {
    @Override public RexNode visitInputRef(RexInputRef ref) {
      return project.getProjects().get(ref.getIndex());
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:RelOptUtil.java


示例14: convertOver

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
private RexNode convertOver(Blackboard bb, SqlNode node) {
	SqlCall call = (SqlCall) node;
	SqlCall aggCall = call.operand(0);
	SqlNode windowOrRef = call.operand(1);
	final SqlWindow window =
		validator.resolveWindow(windowOrRef, bb.scope, true);

	// ROW_NUMBER() expects specific kind of framing.
	if (aggCall.getKind() == SqlKind.ROW_NUMBER) {
		window.setLowerBound(SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO));
		window.setUpperBound(SqlWindow.createCurrentRow(SqlParserPos.ZERO));
		window.setRows(SqlLiteral.createBoolean(true, SqlParserPos.ZERO));
	}
	final SqlNodeList partitionList = window.getPartitionList();
	final ImmutableList.Builder<RexNode> partitionKeys =
		ImmutableList.builder();
	for (SqlNode partition : partitionList) {
		partitionKeys.add(bb.convertExpression(partition));
	}
	RexNode lowerBound = bb.convertExpression(window.getLowerBound());
	RexNode upperBound = bb.convertExpression(window.getUpperBound());
	SqlNodeList orderList = window.getOrderList();
	if ((orderList.size() == 0) && !window.isRows()) {
		// A logical range requires an ORDER BY clause. Use the implicit
		// ordering of this relation. There must be one, otherwise it would
		// have failed validation.
		orderList = bb.scope.getOrderList();
		if (orderList == null) {
			throw new AssertionError(
				"Relation should have sort key for implicit ORDER BY");
		}
	}
	final ImmutableList.Builder<RexFieldCollation> orderKeys =
		ImmutableList.builder();
	final Set<SqlKind> flags = EnumSet.noneOf(SqlKind.class);
	for (SqlNode order : orderList) {
		flags.clear();
		RexNode e = bb.convertSortExpression(order, flags);
		orderKeys.add(new RexFieldCollation(e, flags));
	}
	try {
		Preconditions.checkArgument(bb.window == null,
			"already in window agg mode");
		bb.window = window;
		RexNode rexAgg = exprConverter.convertCall(bb, aggCall);
		rexAgg =
			rexBuilder.ensureType(
				validator.getValidatedNodeType(call), rexAgg, false);

		// Walk over the tree and apply 'over' to all agg functions. This is
		// necessary because the returned expression is not necessarily a call
		// to an agg function. For example, AVG(x) becomes SUM(x) / COUNT(x).
		final RexShuttle visitor =
			new HistogramShuttle(
				partitionKeys.build(), orderKeys.build(),
				RexWindowBound.create(window.getLowerBound(), lowerBound),
				RexWindowBound.create(window.getUpperBound(), upperBound),
				window);
		return rexAgg.accept(visitor);
	} finally {
		bb.window = null;
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:64,代码来源:SqlToRelConverter.java


示例15: convertOver

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
private RexNode convertOver(Blackboard bb, SqlNode node) {
  SqlCall call = (SqlCall) node;
  SqlCall aggCall = call.operand(0);
  SqlNode windowOrRef = call.operand(1);
  final SqlWindow window =
      validator.resolveWindow(windowOrRef, bb.scope, true);

  // ROW_NUMBER() expects specific kind of framing.
  if (aggCall.getKind() == SqlKind.ROW_NUMBER) {
    window.setLowerBound(SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO));
    window.setUpperBound(SqlWindow.createCurrentRow(SqlParserPos.ZERO));
    window.setRows(SqlLiteral.createBoolean(true, SqlParserPos.ZERO));
  }
  final SqlNodeList partitionList = window.getPartitionList();
  final ImmutableList.Builder<RexNode> partitionKeys =
      ImmutableList.builder();
  for (SqlNode partition : partitionList) {
    partitionKeys.add(bb.convertExpression(partition));
  }
  RexNode lowerBound = bb.convertExpression(window.getLowerBound());
  RexNode upperBound = bb.convertExpression(window.getUpperBound());
  SqlNodeList orderList = window.getOrderList();
  if ((orderList.size() == 0) && !window.isRows()) {
    // A logical range requires an ORDER BY clause. Use the implicit
    // ordering of this relation. There must be one, otherwise it would
    // have failed validation.
    orderList = bb.scope.getOrderList();
    if (orderList == null) {
      throw new AssertionError(
          "Relation should have sort key for implicit ORDER BY");
    }
  }
  final ImmutableList.Builder<RexFieldCollation> orderKeys =
      ImmutableList.builder();
  final Set<SqlKind> flags = EnumSet.noneOf(SqlKind.class);
  for (SqlNode order : orderList) {
    flags.clear();
    RexNode e = bb.convertSortExpression(order, flags);
    orderKeys.add(new RexFieldCollation(e, flags));
  }
  try {
    Preconditions.checkArgument(bb.window == null,
        "already in window agg mode");
    bb.window = window;
    RexNode rexAgg = exprConverter.convertCall(bb, aggCall);
    rexAgg =
        rexBuilder.ensureType(
            validator.getValidatedNodeType(call), rexAgg, false);

    // Walk over the tree and apply 'over' to all agg functions. This is
    // necessary because the returned expression is not necessarily a call
    // to an agg function. For example, AVG(x) becomes SUM(x) / COUNT(x).

    boolean isDistinct = false;
    if (aggCall.getFunctionQuantifier() != null
      && aggCall.getFunctionQuantifier().getValue().equals(SqlSelectKeyword.DISTINCT)) {
      isDistinct = true;
    }

    final RexShuttle visitor =
        new HistogramShuttle(
            partitionKeys.build(), orderKeys.build(),
            RexWindowBound.create(window.getLowerBound(), lowerBound),
            RexWindowBound.create(window.getUpperBound(), upperBound),
            window,
            isDistinct);
    RexNode overNode = rexAgg.accept(visitor);

    return overNode;
  } finally {
    bb.window = null;
  }
}
 
开发者ID:apache,项目名称:kylin,代码行数:74,代码来源:SqlToRelConverter.java


示例16: accept

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
public RelNode accept(RexShuttle shuttle) {
  return this;
}
 
开发者ID:apache,项目名称:calcite,代码行数:4,代码来源:AbstractRelNode.java


示例17: convertOver

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
private RexNode convertOver(Blackboard bb, SqlNode node) {
  SqlCall call = (SqlCall) node;
  SqlCall aggCall = call.operand(0);
  SqlNode windowOrRef = call.operand(1);
  final SqlWindow window =
      validator.resolveWindow(windowOrRef, bb.scope, true);

  // ROW_NUMBER() expects specific kind of framing.
  if (aggCall.getKind() == SqlKind.ROW_NUMBER) {
    window.setLowerBound(SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO));
    window.setUpperBound(SqlWindow.createCurrentRow(SqlParserPos.ZERO));
    window.setRows(SqlLiteral.createBoolean(true, SqlParserPos.ZERO));
  }
  final SqlNodeList partitionList = window.getPartitionList();
  final ImmutableList.Builder<RexNode> partitionKeys =
      ImmutableList.builder();
  for (SqlNode partition : partitionList) {
    partitionKeys.add(bb.convertExpression(partition));
  }
  RexNode lowerBound = bb.convertExpression(window.getLowerBound());
  RexNode upperBound = bb.convertExpression(window.getUpperBound());
  SqlNodeList orderList = window.getOrderList();
  if ((orderList.size() == 0) && !window.isRows()) {
    // A logical range requires an ORDER BY clause. Use the implicit
    // ordering of this relation. There must be one, otherwise it would
    // have failed validation.
    orderList = bb.scope.getOrderList();
    if (orderList == null) {
      throw new AssertionError(
          "Relation should have sort key for implicit ORDER BY");
    }
  }
  final ImmutableList.Builder<RexFieldCollation> orderKeys =
      ImmutableList.builder();
  final Set<SqlKind> flags = EnumSet.noneOf(SqlKind.class);
  for (SqlNode order : orderList) {
    flags.clear();
    RexNode e = bb.convertSortExpression(order, flags);
    orderKeys.add(new RexFieldCollation(e, flags));
  }
  try {
    Preconditions.checkArgument(bb.window == null,
        "already in window agg mode");
    bb.window = window;
    RexNode rexAgg = exprConverter.convertCall(bb, aggCall);
    rexAgg =
        rexBuilder.ensureType(
            validator.getValidatedNodeType(call), rexAgg, false);

    // Walk over the tree and apply 'over' to all agg functions. This is
    // necessary because the returned expression is not necessarily a call
    // to an agg function. For example, AVG(x) becomes SUM(x) / COUNT(x).

    final SqlLiteral q = aggCall.getFunctionQuantifier();
    final boolean isDistinct = q != null
        && q.getValue() == SqlSelectKeyword.DISTINCT;

    final RexShuttle visitor =
        new HistogramShuttle(
            partitionKeys.build(), orderKeys.build(),
            RexWindowBound.create(window.getLowerBound(), lowerBound),
            RexWindowBound.create(window.getUpperBound(), upperBound),
            window,
            isDistinct);
    RexNode overNode = rexAgg.accept(visitor);

    return overNode;
  } finally {
    bb.window = null;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:72,代码来源:SqlToRelConverter.java


示例18: accept

import org.apache.calcite.rex.RexShuttle; //导入依赖的package包/类
/**
 * Accepts a visit from a shuttle. If the shuttle updates expression, then
 * a copy of the relation should be created.
 *
 * @param shuttle Shuttle
 * @return A copy of this node incorporating changes made by the shuttle to
 * this node's children
 */
RelNode accept(RexShuttle shuttle);
 
开发者ID:apache,项目名称:calcite,代码行数:10,代码来源:RelNode.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Vector3类代码示例发布时间:2022-05-22
下一篇:
Java FactHandle类代码示例发布时间: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