本文整理了Java中org.apache.calcite.rel.type.RelDataTypeFactory.useDoubleMultiplication
方法的一些代码示例,展示了RelDataTypeFactory.useDoubleMultiplication
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RelDataTypeFactory.useDoubleMultiplication
方法的具体详情如下:
包路径:org.apache.calcite.rel.type.RelDataTypeFactory
类名称:RelDataTypeFactory
方法名:useDoubleMultiplication
[英]Returns whether a decimal multiplication should be implemented by casting arguments to double values.
Pre-condition: createDecimalProduct(type1, type2) != null
[中]
代码示例来源:origin: Qihoo360/Quicksql
private RexNode expandTimes(RexCall call, List<RexNode> operands) {
// Multiplying the internal values of the two arguments leads to
// a number with scale = scaleA + scaleB. If the result type has
// a lower scale, then the number should be scaled down.
int divisor = scaleA + scaleB - call.getType().getScale();
if (builder.getTypeFactory().useDoubleMultiplication(
typeA,
typeB)) {
// Approximate implementation:
// cast (a as double) * cast (b as double)
// / 10^divisor
RexNode division =
makeDivide(
makeMultiply(
ensureType(real8, accessValue(operands.get(0))),
ensureType(real8, accessValue(operands.get(1)))),
makeApproxLiteral(BigDecimal.TEN.pow(divisor)));
return encodeValue(division, call.getType(), true);
} else {
// Exact implementation: scaleDown(a * b)
return encodeValue(
scaleDown(
builder.makeCall(
call.getOperator(),
accessValue(operands.get(0)),
accessValue(operands.get(1))),
divisor),
call.getType());
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
private RexNode expandTimes(RexCall call, List<RexNode> operands) {
// Multiplying the internal values of the two arguments leads to
// a number with scale = scaleA + scaleB. If the result type has
// a lower scale, then the number should be scaled down.
int divisor = scaleA + scaleB - call.getType().getScale();
if (builder.getTypeFactory().useDoubleMultiplication(
typeA,
typeB)) {
// Approximate implementation:
// cast (a as double) * cast (b as double)
// / 10^divisor
RexNode division =
makeDivide(
makeMultiply(
ensureType(real8, accessValue(operands.get(0))),
ensureType(real8, accessValue(operands.get(1)))),
makeApproxLiteral(BigDecimal.TEN.pow(divisor)));
return encodeValue(division, call.getType(), true);
} else {
// Exact implementation: scaleDown(a * b)
return encodeValue(
scaleDown(
builder.makeCall(
call.getOperator(),
accessValue(operands.get(0)),
accessValue(operands.get(1))),
divisor),
call.getType());
}
}
内容来源于网络,如有侵权,请联系作者删除!