Class CompleteDataType

    • Field Detail

      • type

        protected final DataType type
        Wrapped data type
      • TYPE_TO_TYPE_SCORE

        public static final long TYPE_TO_TYPE_SCORE
        Type to type coercion value
        See Also:
        Constant Field Values
      • NULL_TO_TYPE_SCORE

        public static final long NULL_TO_TYPE_SCORE
        Null to type coercion value
        See Also:
        Constant Field Values
      • WILDCARD_SCORE

        public static final long WILDCARD_SCORE
        Wild card coercion value
        See Also:
        Constant Field Values
    • Constructor Detail

      • CompleteDataType

        protected CompleteDataType​(DataType type)
        Constructor
        Parameters:
        type - Data type
    • Method Detail

      • getDataType

        public DataType getDataType()
        Return the data type of the complete type
        Returns:
        the DataType
      • toHumanString

        public String toHumanString()
        Return a String describing the type suitable for error messages.

        Assumes no schemas are named.

        Returns:
        a suitable string
        Since:
        6.3
      • canAssignFrom

        public final boolean canAssignFrom​(CompleteDataType other)
        Check if a value of this type can be assigned a value of the other type. That is, is this type a supertype of that type.
        Parameters:
        other - the other type
        Returns:
        type assignment compatibility
      • canAssignFromImpl

        protected boolean canAssignFromImpl​(CompleteDataType other)
        Method for subclasses to override if they have a broader concept of type.
        Parameters:
        other - the other type
        Returns:
        type assignment compatibility
      • rateCoercion

        public long rateCoercion​(CompleteDataType type)
        calculate the coercion score to get coerce this → type - by default returns SCORE_PASS or SCORE_FAIL based on equals
        Parameters:
        type - the CType to converse to
        Returns:
        the score, use COp.java as a reference for score constants
      • toHumanString

        public abstract String toHumanString​(SchemaUtil.SchemaProvider schemaProvider)
        Return a String describing the type suitable for error messages.
        Parameters:
        schemaProvider - A schema provider to identify named schemas
        Returns:
        param a suitable string
        Since:
        6.3
      • equalBaseTypes

        protected boolean equalBaseTypes​(CompleteDataType other)
        Compare wrapped types
        Parameters:
        other - Compare with this type
        Returns:
        true if equal
      • getName

        public String getName()
        Get the name of this complete type
        Returns:
        the name of this CompleteDataType
      • getSchema

        public Schema getSchema()
        For tuple types, return the tuple's schema. For other types null is returned.
        Returns:
        the tuple types's schema
      • getArgumentSchema

        public Schema getArgumentSchema()
        For function types, return the argument schema. For other types null is returned.
        Returns:
        the function type's argument schema
      • getElementType

        public CompleteDataType getElementType()
        For list collection types, return the complete type of the list's elements. For other types null is returned.
        Returns:
        the list type's element type
      • getCaptureName

        public String getCaptureName()
        For capture types, return the capture type name. For other types, null is returned
        Returns:
        the capture name
      • getReturnType

        public CompleteDataType getReturnType()
        For function types, return the return type of the function. For other types, return null.
        Returns:
        the function type's return type
      • rateCoercion

        public static long rateCoercion​(CompleteDataType from,
                                        CompleteDataType to)
        Rate coercion
        Parameters:
        from - From type
        to - To type
        Returns:
        Coercion value
      • forBoolean

        public static CompleteDataType forBoolean()
        Return the complete type for a bool.
        Returns:
        a boolean complete data type
        Since:
        6.3
      • forBlob

        public static CompleteDataType forBlob()
        Return the complete type for a blob.
        Returns:
        a blob complete data type.
        Since:
        6.3
      • forDouble

        public static CompleteDataType forDouble()
        Return the complete type for a double.
        Returns:
        a double complete data type
        Since:
        6.3
      • forInt

        public static CompleteDataType forInt()
        Return the complete type for an int.
        Returns:
        a int complete data type
        Since:
        6.3
      • forLong

        public static CompleteDataType forLong()
        Return the complete type for a long.
        Returns:
        a long complete data type
        Since:
        6.3
      • forString

        public static CompleteDataType forString()
        Return the complete type for a string.
        Returns:
        a string complete data type
        Since:
        6.3
      • forTimestamp

        public static CompleteDataType forTimestamp()
        Return the complete type for a timestamp.
        Returns:
        a timestamp complete data type
        Since:
        6.3
      • forTuple

        public static CompleteDataType forTuple​(Schema schema)
        Return a tuple complete data type with the specified schema.
        Parameters:
        schema - the tuple's schema. This parameter may not be null.
        Returns:
        a tuple complete data type
        Since:
        6.3
      • forList

        public static CompleteDataType forList​(CompleteDataType elementType)
        Return a list complete data type with the specified element type
        Parameters:
        elementType - the list's element type
        Returns:
        a list complete data type
        Since:
        6.3
      • forDoubleList

        public static CompleteDataType forDoubleList()
        Returns:
        the equivalence of calling forList(forDouble())
      • forIntList

        public static CompleteDataType forIntList()
        Returns:
        the equivalence of calling forList(forInt())
      • forLongList

        public static CompleteDataType forLongList()
        Returns:
        the equivalence of calling forList(forLong())
      • forStringList

        public static CompleteDataType forStringList()
        Returns:
        the equivalence of calling forList(forString())
      • forBoolList

        public static CompleteDataType forBoolList()
        Returns:
        the equivalence of calling forList(forBool())
      • forBlobList

        public static CompleteDataType forBlobList()
        Returns:
        the equivalence of calling forList(forBlob())
      • forTimestampList

        public static CompleteDataType forTimestampList()
        Returns:
        the equivalence of calling forList(forTimestamp())
      • forCapture

        public static CompleteDataType forCapture​(String typeName)
        Return a capture complete data type with the specified type parameter name. The type parameter name, to be meaningful in the context of a module, must match a type parameter name that is bound by one of the input streams of the module. (All type parameters at the top level are considered to be bound to an empty set of fields)
        Parameters:
        typeName - the type parameter name to use
        Returns:
        a CaptureType with the given type parameter name
        Since:
        7.2
      • findSuperType

        public static CompleteDataType findSuperType​(CompleteDataType t1,
                                                     CompleteDataType t2)
        Find a type that t1 and t2 can both promote to safely
        Parameters:
        t1 - an input type or null
        t2 - an input type or null
        Returns:
        a type such that both t1.promoteTo() and t2.promoteTo() is safe or null if no such type is available or either argument is null
      • forFunction

        public static CompleteDataType.FunctionType forFunction​(Schema argumentSchema,
                                                                CompleteDataType returnType)
        Return a function's CompleteDataType with the given argument schema and return type
        Parameters:
        argumentSchema - the function's arguments. To represent no arguments, pass an empty schema, not null.
        returnType - the function's return type
        Returns:
        a function's CompleteDataType
        Since:
        7.4