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


Java RexCall.getType方法代码示例

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


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

示例1: expandPlusMinus

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private RexNode expandPlusMinus(RexCall call, List<RexNode> operands) {
  RelDataType outType = call.getType();
  int outScale = outType.getScale();
  return encodeValue(
      builder.makeCall(
          call.getOperator(),
          ensureScale(
              accessValue(operands.get(0)),
              scaleA,
              outScale),
          ensureScale(
              accessValue(operands.get(1)),
              scaleB,
              outScale)),
      outType);
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:ReduceDecimalsRule.java

示例2: expandDivide

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private RexNode expandDivide(RexCall call, List<RexNode> operands) {
  RelDataType outType = call.getType();
  RexNode dividend =
      builder.makeCall(
          call.getOperator(),
          ensureType(
              real8,
              accessValue(operands.get(0))),
          ensureType(
              real8,
              accessValue(operands.get(1))));
  int scaleDifference = outType.getScale() - scaleA + scaleB;
  RexNode rescale =
      builder.makeCall(
          SqlStdOperatorTable.MULTIPLY,
          dividend,
          makeApproxScaleFactor(scaleDifference));
  return encodeValue(rescale, outType);
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:ReduceDecimalsRule.java

示例3: expand

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
public RexNode expand(RexCall call) {
  RelDataType retType = call.getType();
  int argCount = call.operands.size();
  ImmutableList.Builder<RexNode> opBuilder = ImmutableList.builder();

  for (int i = 0; i < argCount; i++) {
    // skip case conditions
    if (((i % 2) == 0) && (i != (argCount - 1))) {
      opBuilder.add(call.operands.get(i));
      continue;
    }
    RexNode expr = ensureType(retType, call.operands.get(i), false);
    if (SqlTypeUtil.isDecimal(retType)) {
      expr = decodeValue(expr);
    }
    opBuilder.add(expr);
  }

  RexNode newCall =
      builder.makeCall(retType, call.getOperator(), opBuilder.build());
  if (SqlTypeUtil.isDecimal(retType)) {
    newCall = encodeValue(newCall, retType);
  }
  return newCall;
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:ReduceDecimalsRule.java

示例4: visitCall

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public RexNode visitCall(RexCall call) {
  SqlOperator op = call.getOperator();
  SqlKind kind = op.getKind();
  RelDataType type = call.getType();
  if (kind == SqlKind.OR || kind == SqlKind.AND) {
    if (call.getOperands().size() > 2) {
      List<RexNode> children = new ArrayList(call.getOperands());
      RexNode left = children.remove(0).accept(this);
      RexNode right = builder.makeCall(type, op, children).accept(this);
      return builder.makeCall(type, op, ImmutableList.of(left, right));
    }
  }
  return builder.makeCall(type, op, visitChildren(call));
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:16,代码来源:RewriteAsBinaryOperators.java

示例5: visitCall

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public RexNode visitCall(RexCall call) {
  SqlOperator op = call.getOperator();
  SqlKind kind = op.getKind();
  RelDataType type = call.getType();
  if (kind == SqlKind.OR || kind == SqlKind.AND) {
    if (call.getOperands().size() > 2) {
      List<RexNode> children = new ArrayList<>(call.getOperands());
      RexNode left = children.remove(0).accept(this);
      RexNode right = builder.makeCall(type, op, children).accept(this);
      return builder.makeCall(type, op, ImmutableList.of(left, right));
    }
  }
  return builder.makeCall(type, op, visitChildren(call));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:16,代码来源:RewriteAsBinaryOperators.java

示例6: reduceCasts

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private void reduceCasts(RexCall outerCast) {
  List<RexNode> operands = outerCast.getOperands();
  if (operands.size() != 1) {
    return;
  }
  RelDataType outerCastType = outerCast.getType();
  RelDataType operandType = operands.get(0).getType();
  if (operandType.equals(outerCastType)) {
    removableCasts.add(outerCast);
    return;
  }

  // See if the reduction
  // CAST((CAST x AS type) AS type NOT NULL)
  // -> CAST(x AS type NOT NULL)
  // applies.  TODO jvs 15-Dec-2008:  consider
  // similar cases for precision changes.
  if (!(operands.get(0) instanceof RexCall)) {
    return;
  }
  RexCall innerCast = (RexCall) operands.get(0);
  if (innerCast.getOperator() != SqlStdOperatorTable.CAST) {
    return;
  }
  if (innerCast.getOperands().size() != 1) {
    return;
  }
  RelDataType outerTypeNullable =
      typeFactory.createTypeWithNullability(outerCastType, true);
  RelDataType innerTypeNullable =
      typeFactory.createTypeWithNullability(operandType, true);
  if (outerTypeNullable != innerTypeNullable) {
    return;
  }
  if (operandType.isNullable()) {
    removableCasts.add(innerCast);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:39,代码来源:ReduceExpressionsRule.java

示例7: canSimplify

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
/**
 * Detect, in a generic, but strict way, whether it is possible to
 * simplify a reinterpret cast. The rules are as follows:
 *
 * <ol>
 * <li>If value is not the same basic type as outer, then we cannot
 * simplify
 * <li>If the value is nullable but the inner or outer are not, then we
 * cannot simplify.
 * <li>If inner is nullable but outer is not, we cannot simplify.
 * <li>If an overflow check is required from either inner or outer, we
 * cannot simplify.
 * <li>Otherwise, given the same type, and sufficient nullability
 * constraints, we can simplify.
 * </ol>
 *
 * @param outer outer call to reinterpret
 * @param inner inner call to reinterpret
 * @param value inner value
 * @return whether the two reinterpret casts can be removed
 */
private boolean canSimplify(
    RexCall outer,
    RexCall inner,
    RexNode value) {
  RelDataType outerType = outer.getType();
  RelDataType innerType = inner.getType();
  RelDataType valueType = value.getType();
  boolean outerCheck = RexUtil.canReinterpretOverflow(outer);
  boolean innerCheck = RexUtil.canReinterpretOverflow(inner);

  if ((outerType.getSqlTypeName() != valueType.getSqlTypeName())
      || (outerType.getPrecision() != valueType.getPrecision())
      || (outerType.getScale() != valueType.getScale())) {
    return false;
  }
  if (valueType.isNullable()
      && (!innerType.isNullable() || !outerType.isNullable())) {
    return false;
  }
  if (innerType.isNullable() && !outerType.isNullable()) {
    return false;
  }

  // One would think that we could go from Nullable -> Not Nullable
  // since we are substituting a general type with a more specific
  // type. However the optimizer doesn't like it.
  if (valueType.isNullable() != outerType.isNullable()) {
    return false;
  }
  if (innerCheck || outerCheck) {
    return false;
  }
  return true;
}
 
开发者ID:apache,项目名称:calcite,代码行数:56,代码来源:ReduceDecimalsRule.java

示例8: visitCall

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

	boolean[] update = {false};
	List<RexNode> clonedOperands = visitList(call.operands, update);
	if (update[0]) {
		SqlOperator operator = call.getOperator();

		boolean isSpecialCast = false;
		if (operator instanceof SqlFunction) {
			SqlFunction function = (SqlFunction) operator;
			if (function.getKind() == SqlKind.CAST) {
				if (call.operands.size() < 2) {
					isSpecialCast = true;
				}
			}
		}

		final RelDataType newType;
		if (!isSpecialCast) {
			// TODO: ideally this only needs to be called if the result
			// type will also change. However, since that requires
			// support from type inference rules to tell whether a rule
			// decides return type based on input types, for now all
			// operators will be recreated with new type if any operand
			// changed, unless the operator has "built-in" type.
			newType = rexBuilder.deriveReturnType(operator, clonedOperands);
		} else {
			// Use the current return type when creating a new call, for
			// operators with return type built into the operator
			// definition, and with no type inference rules, such as
			// cast function with less than 2 operands.

			// TODO: Comments in RexShuttle.visitCall() mention other
			// types in this category. Need to resolve those together
			// and preferably in the base class RexShuttle.
			newType = call.getType();
		}
		newCall = rexBuilder.makeCall(newType, operator, clonedOperands);
	} else {
		newCall = call;
	}

	if (projectPulledAboveLeftCorrelator && (nullIndicator != null)) {
		return createCaseExpression(nullIndicator, rexBuilder.constantNull(), newCall);
	}
	return newCall;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:50,代码来源:FlinkRelDecorrelator.java

示例9: visitCall

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

  boolean[] update = {false};
  List<RexNode> clonedOperands = visitList(call.operands, update);
  if (update[0]) {
    SqlOperator operator = call.getOperator();

    boolean isSpecialCast = false;
    if (operator instanceof SqlFunction) {
      SqlFunction function = (SqlFunction) operator;
      if (function.getKind() == SqlKind.CAST) {
        if (call.operands.size() < 2) {
          isSpecialCast = true;
        }
      }
    }

    final RelDataType newType;
    if (!isSpecialCast) {
      // TODO: ideally this only needs to be called if the result
      // type will also change. However, since that requires
      // support from type inference rules to tell whether a rule
      // decides return type based on input types, for now all
      // operators will be recreated with new type if any operand
      // changed, unless the operator has "built-in" type.
      newType = rexBuilder.deriveReturnType(operator, clonedOperands);
    } else {
      // Use the current return type when creating a new call, for
      // operators with return type built into the operator
      // definition, and with no type inference rules, such as
      // cast function with less than 2 operands.

      // TODO: Comments in RexShuttle.visitCall() mention other
      // types in this category. Need to resolve those together
      // and preferably in the base class RexShuttle.
      newType = call.getType();
    }
    newCall =
        rexBuilder.makeCall(
            newType,
            operator,
            clonedOperands);
  } else {
    newCall = call;
  }

  if (projectPulledAboveLeftCorrelator && (nullIndicator != null)) {
    return createCaseExpression(
        nullIndicator,
        rexBuilder.constantNull(),
        newCall);
  }
  return newCall;
}
 
开发者ID:apache,项目名称:calcite,代码行数:56,代码来源:RelDecorrelator.java


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