Class RelDataTypeFactoryImpl

    • Field Detail

      • KEY2TYPE_CACHE

        private static final com.google.common.cache.LoadingCache<RelDataTypeFactoryImpl.Key,​RelDataType> KEY2TYPE_CACHE
        Global cache for Key to RelDataType. Uses soft values to allow GC.
      • DATATYPE_CACHE

        private static final com.google.common.collect.Interner<RelDataType> DATATYPE_CACHE
        Global cache for RelDataType.
      • CLASS_FAMILIES

        private static final java.util.Map<java.lang.Class,​RelDataTypeFamily> CLASS_FAMILIES
    • Constructor Detail

      • RelDataTypeFactoryImpl

        protected RelDataTypeFactoryImpl​(RelDataTypeSystem typeSystem)
        Creates a type factory.
    • Method Detail

      • createJavaType

        public RelDataType createJavaType​(java.lang.Class clazz)
        Description copied from interface: RelDataTypeFactory
        Creates a type that corresponds to a Java class.
        Specified by:
        createJavaType in interface RelDataTypeFactory
        Parameters:
        clazz - the Java class used to define the type
        Returns:
        canonical Java type descriptor
      • createStructType

        public RelDataType createStructType​(java.util.List<RelDataType> typeList,
                                            java.util.List<java.lang.String> fieldNameList)
        Description copied from interface: RelDataTypeFactory
        Creates a type that represents a structured collection of fields. Shorthand for createStructType(StructKind.FULLY_QUALIFIED, typeList, fieldNameList).
        Specified by:
        createStructType in interface RelDataTypeFactory
      • createStructType

        public RelDataType createStructType​(StructKind kind,
                                            java.util.List<RelDataType> typeList,
                                            java.util.List<java.lang.String> fieldNameList)
        Description copied from interface: RelDataTypeFactory
        Creates a type that represents a structured collection of fields, given lists of the names and types of the fields.
        Specified by:
        createStructType in interface RelDataTypeFactory
        Parameters:
        kind - Name resolution policy
        typeList - types of the fields
        fieldNameList - names of the fields
        Returns:
        canonical struct type descriptor
      • createStructType

        private RelDataType createStructType​(StructKind kind,
                                             java.util.List<RelDataType> typeList,
                                             java.util.List<java.lang.String> fieldNameList,
                                             boolean nullable)
      • createStructType

        public final RelDataType createStructType​(java.util.List<? extends java.util.Map.Entry<java.lang.String,​RelDataType>> fieldList)
        Description copied from interface: RelDataTypeFactory
        Creates a type that represents a structured collection of fieldList, obtaining the field information from a list of (name, type) pairs.
        Specified by:
        createStructType in interface RelDataTypeFactory
        Parameters:
        fieldList - List of (name, type) pairs
        Returns:
        canonical struct type descriptor
      • createStructType

        private RelDataType createStructType​(java.util.List<? extends java.util.Map.Entry<java.lang.String,​RelDataType>> fieldList,
                                             boolean nullable)
      • leastRestrictive

        public RelDataType leastRestrictive​(java.util.List<RelDataType> types)
        Description copied from interface: RelDataTypeFactory
        Returns the most general of a set of types (that is, one type to which they can all be cast), or null if conversion is not possible. The result may be a new type that is less restrictive than any of the input types, e.g. leastRestrictive(INT, NUMERIC(3, 2)) could be NUMERIC(12, 2).
        Specified by:
        leastRestrictive in interface RelDataTypeFactory
        Parameters:
        types - input types to be combined using union (not null, not empty)
        Returns:
        canonical union type descriptor
      • leastRestrictiveStructuredType

        protected RelDataType leastRestrictiveStructuredType​(java.util.List<RelDataType> types)
      • copyRecordType

        private RelDataType copyRecordType​(RelRecordType type,
                                           boolean ignoreNullable,
                                           boolean nullable)
      • copyType

        public RelDataType copyType​(RelDataType type)
        Description copied from interface: RelDataTypeFactory
        Duplicates a type, making a deep copy. Normally, this is a no-op, since canonical type objects are returned. However, it is useful when copying a type from one factory to another.
        Specified by:
        copyType in interface RelDataTypeFactory
        Parameters:
        type - input type
        Returns:
        output type, a new object equivalent to input type
      • createTypeWithNullability

        public RelDataType createTypeWithNullability​(RelDataType type,
                                                     boolean nullable)
        Description copied from interface: RelDataTypeFactory
        Creates a type that is the same as another type but with possibly different nullability. The output type may be identical to the input type. For type systems without a concept of nullability, the return value is always the same as the input.
        Specified by:
        createTypeWithNullability in interface RelDataTypeFactory
        Parameters:
        type - input type
        nullable - true to request a nullable type; false to request a NOT NULL type
        Returns:
        output type, same as input type except with specified nullability
      • canonize

        protected RelDataType canonize​(RelDataType type)
        Registers a type, or returns the existing type if it is already registered.
        Throws:
        java.lang.NullPointerException - if type is null
      • canonize

        protected RelDataType canonize​(StructKind kind,
                                       java.util.List<java.lang.String> names,
                                       java.util.List<RelDataType> types,
                                       boolean nullable)
        Looks up a type using a temporary key, and if not present, creates a permanent key and type.

        This approach allows us to use a cheap temporary key. A permanent key is more expensive, because it must be immutable and not hold references into other data structures.

      • getFieldList

        private static java.util.List<RelDataTypeField> getFieldList​(java.util.List<RelDataType> types)
        Returns a list of the fields in a list of types.
      • getTypeList

        private static void getTypeList​(com.google.common.collect.ImmutableList<RelDataType> inTypes,
                                        java.util.List<RelDataType> flatTypes)
        Returns a list of all atomic types in a list.
      • addFields

        private static void addFields​(RelDataType type,
                                      java.util.List<RelDataTypeField> fieldList)
        Adds all fields in type to fieldList, renumbering the fields (if necessary) to ensure that their index matches their position in the list.
      • isJavaType

        public static boolean isJavaType​(RelDataType t)
      • decimalOf

        public RelDataType decimalOf​(RelDataType type)
        Description copied from interface: RelDataTypeFactory
        Create a decimal type equivalent to the numeric type, this is related to specific system implementation, you can override this logic if it is required.
        Specified by:
        decimalOf in interface RelDataTypeFactory
        Parameters:
        type - the numeric type to create decimal type with
        Returns:
        decimal equivalence of the numeric type.
      • decimalOf2

        private RelDataType decimalOf2​(RelDataType type)
        Create decimal type equivalent with the given type while sans nullability.
      • getDefaultCharset

        public java.nio.charset.Charset getDefaultCharset()
        Specified by:
        getDefaultCharset in interface RelDataTypeFactory
        Returns:
        the default Charset for string types