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


Java RexCall.clone方法代码示例

本文整理汇总了Java中org.apache.calcite.rex.RexCall.clone方法的典型用法代码示例。如果您正苦于以下问题:Java RexCall.clone方法的具体用法?Java RexCall.clone怎么用?Java RexCall.clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.rex.RexCall的用法示例。


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

示例1: visitCall

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
public RexNode visitCall(RexCall call) {

    String functionName = call.getOperator().getName();

    List<RexNode> newOps = new ArrayList();
    for (RexNode operand : call.operands) {
      newOps.add(operand.accept(this));
    }
    if (funcReg.isFunctionComplexOutput(functionName) ) {
      RexBuilder builder = new RexBuilder(factory);
      RexNode ret = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), lastUsedIndex);
      lastUsedIndex++;
      complexExprs.add(call.clone(new RelDataTypeDrillImpl(new RelDataTypeHolder(),factory), newOps));
      return ret;
    }
    return call.clone(call.getType(), newOps);
  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:RexVisitorComplexExprSplitter.java

示例2: visitCall

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public RexNode visitCall(RexCall call) {

  String functionName = call.getOperator().getName();

  List<RexNode> newOps = new ArrayList<>();
  for (RexNode operand : call.operands) {
    newOps.add(operand.accept(this));
  }
  if (funcReg.isFunctionComplexOutput(functionName)) {
    RexNode ret = builder.makeInputRef( factory.createTypeWithNullability(factory.createSqlType(SqlTypeName.ANY), true), lastUsedIndex);
    lastUsedIndex++;
    complexExprs.add(call.clone(factory.createTypeWithNullability(factory.createSqlType(SqlTypeName.ANY), true), newOps));
    return ret;
  }
  return call.clone(call.getType(), newOps);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:RexVisitorComplexExprSplitter.java

示例3: visitCall

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public RexNode visitCall(RexCall call) {

  String functionName = call.getOperator().getName();

  List<RexNode> newOps = new ArrayList<>();
  for (RexNode operand : call.operands) {
    newOps.add(operand.accept(this));
  }
  if (funcReg.isFunctionComplexOutput(functionName) ) {
    RexBuilder builder = new RexBuilder(factory);
    RexNode ret = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), lastUsedIndex);
    lastUsedIndex++;
    complexExprs.add(call.clone(new RelDataTypeDrillImpl(new RelDataTypeHolder(),factory), newOps));
    return ret;
  }
  return call.clone(call.getType(), newOps);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:19,代码来源:RexVisitorComplexExprSplitter.java

示例4: go

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
public RexNode go(RexNode rex) {
  if (rex instanceof RexCall) {
    ImmutableList.Builder<RexNode> builder =
        ImmutableList.builder();
    final RexCall call = (RexCall) rex;
    for (RexNode operand : call.operands) {
      builder.add(go(operand));
    }
    return call.clone(call.getType(), builder.build());
  } else if (rex instanceof RexInputRef) {
    RexInputRef var = (RexInputRef) rex;
    int index = var.getIndex();
    if (index < leftFields.size()) {
      // Field came from left side of join. Move it to the right.
      return rexBuilder.makeInputRef(
          leftFields.get(index).getType(),
          rightFields.size() + index);
    }
    index -= leftFields.size();
    if (index < rightFields.size()) {
      // Field came from right side of join. Move it to the left.
      return rexBuilder.makeInputRef(
          rightFields.get(index).getType(),
          index);
    }
    throw new AssertionError("Bad field offset: index=" + var.getIndex()
        + ", leftFieldCount=" + leftFields.size()
        + ", rightFieldCount=" + rightFields.size());
  } else {
    return rex;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:33,代码来源:JoinCommuteRule.java

示例5: stripCastFromString

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
/** Removes cast from string.
 *
 * <p>For example, {@code x > CAST('2015-01-07' AS DATE)}
 * becomes {@code x > '2015-01-07'}.
 */
private static RexNode stripCastFromString(RexNode node) {
  switch (node.getKind()) {
  case EQUALS:
  case IS_NOT_DISTINCT_FROM:
  case NOT_EQUALS:
  case GREATER_THAN:
  case GREATER_THAN_OR_EQUAL:
  case LESS_THAN:
  case LESS_THAN_OR_EQUAL:
    final RexCall call = (RexCall) node;
    final RexNode o0 = call.operands.get(0);
    final RexNode o1 = call.operands.get(1);
    if (o0.getKind() == SqlKind.CAST
        && o1.getKind() != SqlKind.CAST) {
      final RexNode o0b = ((RexCall) o0).getOperands().get(0);
      switch (o0b.getType().getSqlTypeName()) {
      case CHAR:
      case VARCHAR:
        return call.clone(call.getType(), ImmutableList.of(o0b, o1));
      }
    }
    if (o1.getKind() == SqlKind.CAST
        && o0.getKind() != SqlKind.CAST) {
      final RexNode o1b = ((RexCall) o1).getOperands().get(0);
      switch (o1b.getType().getSqlTypeName()) {
      case CHAR:
      case VARCHAR:
        return call.clone(call.getType(), ImmutableList.of(o0, o1b));
      }
    }
  }
  return node;
}
 
开发者ID:apache,项目名称:calcite,代码行数:39,代码来源:SqlImplementor.java

示例6: call2

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private static RexCall call2(
    boolean harmonize,
    RexToLixTranslator translator,
    RexCall call) {
  if (!harmonize) {
    return call;
  }
  final List<RexNode> operands2 =
      harmonize(translator, call.getOperands());
  if (operands2.equals(call.getOperands())) {
    return call;
  }
  return call.clone(call.getType(), operands2);
}
 
开发者ID:apache,项目名称:calcite,代码行数:15,代码来源:RexImpTable.java

示例7: pushPredicateIntoCase

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
/** Pushes predicates into a CASE.
 *
 * <p>We have a loose definition of 'predicate': any boolean expression will
 * do, except CASE. For example '(CASE ...) = 5' or '(CASE ...) IS NULL'.
 */
public static RexCall pushPredicateIntoCase(RexCall call) {
  if (call.getType().getSqlTypeName() != SqlTypeName.BOOLEAN) {
    return call;
  }
  switch (call.getKind()) {
  case CASE:
  case AND:
  case OR:
    return call; // don't push CASE into CASE!
  case EQUALS: {
    // checks that the EQUALS operands may be splitted and
    // doesn't push EQUALS into CASE
    List<RexNode> equalsOperands = call.getOperands();
    ImmutableBitSet left = RelOptUtil.InputFinder.bits(equalsOperands.get(0));
    ImmutableBitSet right = RelOptUtil.InputFinder.bits(equalsOperands.get(1));
    if (!left.isEmpty() && !right.isEmpty() && left.intersect(right).isEmpty()) {
      return call;
    }
  }
  }
  int caseOrdinal = -1;
  final List<RexNode> operands = call.getOperands();
  for (int i = 0; i < operands.size(); i++) {
    RexNode operand = operands.get(i);
    switch (operand.getKind()) {
    case CASE:
      caseOrdinal = i;
    }
  }
  if (caseOrdinal < 0) {
    return call;
  }
  // Convert
  //   f(CASE WHEN p1 THEN v1 ... END, arg)
  // to
  //   CASE WHEN p1 THEN f(v1, arg) ... END
  final RexCall case_ = (RexCall) operands.get(caseOrdinal);
  final List<RexNode> nodes = new ArrayList<>();
  for (int i = 0; i < case_.getOperands().size(); i++) {
    RexNode node = case_.getOperands().get(i);
    if (!RexUtil.isCasePredicate(case_, i)) {
      node = substitute(call, caseOrdinal, node);
    }
    nodes.add(node);
  }
  return case_.clone(call.getType(), nodes);
}
 
开发者ID:apache,项目名称:calcite,代码行数:53,代码来源:ReduceExpressionsRule.java

示例8: substitute

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
/** Converts op(arg0, ..., argOrdinal, ..., argN) to op(arg0,..., node, ..., argN). */
protected static RexNode substitute(RexCall call, int ordinal, RexNode node) {
  final List<RexNode> newOperands = Lists.newArrayList(call.getOperands());
  newOperands.set(ordinal, node);
  return call.clone(call.getType(), newOperands);
}
 
开发者ID:apache,项目名称:calcite,代码行数:7,代码来源:ReduceExpressionsRule.java

示例9: pushDownEqualJoinConditions

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
/**
 * Pushes down parts of a join condition.
 *
 * <p>For example, given
 * "emp JOIN dept ON emp.deptno + 1 = dept.deptno", adds a project above
 * "emp" that computes the expression
 * "emp.deptno + 1". The resulting join condition is a simple combination
 * of AND, equals, and input fields.
 */
private static RexNode pushDownEqualJoinConditions(
    RexNode node,
    int leftCount,
    int rightCount,
    List<RexNode> extraLeftExprs,
    List<RexNode> extraRightExprs) {
  switch (node.getKind()) {
  case AND:
  case EQUALS:
    final RexCall call = (RexCall) node;
    final List<RexNode> list = new ArrayList<>();
    List<RexNode> operands = Lists.newArrayList(call.getOperands());
    for (int i = 0; i < operands.size(); i++) {
      RexNode operand = operands.get(i);
      final int left2 = leftCount + extraLeftExprs.size();
      final int right2 = rightCount + extraRightExprs.size();
      final RexNode e =
          pushDownEqualJoinConditions(
              operand,
              leftCount,
              rightCount,
              extraLeftExprs,
              extraRightExprs);
      final List<RexNode> remainingOperands = Util.skip(operands, i + 1);
      final int left3 = leftCount + extraLeftExprs.size();
      fix(remainingOperands, left2, left3);
      fix(list, left2, left3);
      list.add(e);
    }
    if (!list.equals(call.getOperands())) {
      return call.clone(call.getType(), list);
    }
    return call;
  case OR:
  case INPUT_REF:
  case LITERAL:
    return node;
  default:
    final ImmutableBitSet bits = RelOptUtil.InputFinder.bits(node);
    final int mid = leftCount + extraLeftExprs.size();
    switch (Side.of(bits, mid)) {
    case LEFT:
      fix(extraRightExprs, mid, mid + 1);
      extraLeftExprs.add(node);
      return new RexInputRef(mid, node.getType());
    case RIGHT:
      final int index2 = mid + rightCount + extraRightExprs.size();
      extraRightExprs.add(node);
      return new RexInputRef(index2, node.getType());
    case BOTH:
    case EMPTY:
    default:
      return node;
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:66,代码来源:RelOptUtil.java


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