Tabnine Logo
RelDataTypeFactory.useDoubleMultiplication
Code IndexAdd Tabnine to your IDE (free)

How to use
useDoubleMultiplication
method
in
org.apache.calcite.rel.type.RelDataTypeFactory

Best Java code snippets using org.apache.calcite.rel.type.RelDataTypeFactory.useDoubleMultiplication (Showing top 2 results out of 315)

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());
 }
}
org.apache.calcite.rel.typeRelDataTypeFactoryuseDoubleMultiplication

Javadoc

Returns whether a decimal multiplication should be implemented by casting arguments to double values.

Pre-condition: createDecimalProduct(type1, type2) != null

Popular methods of RelDataTypeFactory

  • createSqlType
    Creates a SQL type with precision and scale.
  • createTypeWithNullability
    Creates a type that is the same as another type but with possibly different nullability. The output
  • createStructType
    Creates a type that represents a structured collection of fields, given lists of the names and types
  • builder
    Creates a org.apache.calcite.rel.type.RelDataTypeFactory.FieldInfoBuilder. But since FieldInfoBuilde
  • createMapType
    Creates a map type. Maps are unordered collections of key/value pairs.
  • getTypeSystem
    Returns the type system.
  • createArrayType
    Creates an array type. Arrays are ordered collections of elements.
  • createJavaType
    Creates a type that corresponds to a Java class.
  • createSqlIntervalType
    Creates a SQL interval type.
  • createTypeWithCharsetAndCollation
    Creates a type that is the same as another type but with possibly different charset or collation. Fo
  • leastRestrictive
    Returns the most general of a set of types (that is, one type to which they can all be cast), or nul
  • createMultisetType
    Creates a multiset type. Multisets are unordered collections of elements.
  • leastRestrictive,
  • createMultisetType,
  • copyType,
  • createUnknownType,
  • getDefaultCharset,
  • createJoinType

Popular in Java

  • Reading from database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • requestLocationUpdates (LocationManager)
  • setContentView (Activity)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now