Class PrimitiveType


  • public final class PrimitiveType
    extends Type
    Representation of a Primitive type
    • Constructor Detail

      • PrimitiveType

        public PrimitiveType​(Type.Repetition repetition,
                             PrimitiveType.PrimitiveTypeName primitive,
                             int length,
                             String name)
        Parameters:
        repetition - OPTIONAL, REPEATED, REQUIRED
        primitive - STRING, INT64, ...
        length - the length if the type is FIXED_LEN_BYTE_ARRAY, 0 otherwise (XXX)
        name - the name of the type
      • PrimitiveType

        @Deprecated
        public PrimitiveType​(Type.Repetition repetition,
                             PrimitiveType.PrimitiveTypeName primitive,
                             String name,
                             OriginalType originalType)
        Deprecated.
        will be removed in 2.0.0; use builders in Types instead
        Parameters:
        repetition - OPTIONAL, REPEATED, REQUIRED
        primitive - STRING, INT64, ...
        name - the name of the type
        originalType - (optional) the original type to help with cross schema convertion (LIST, MAP, ...)
      • PrimitiveType

        @Deprecated
        public PrimitiveType​(Type.Repetition repetition,
                             PrimitiveType.PrimitiveTypeName primitive,
                             int length,
                             String name,
                             OriginalType originalType)
        Deprecated.
        Parameters:
        repetition - OPTIONAL, REPEATED, REQUIRED
        primitive - STRING, INT64, ...
        name - the name of the type
        length - the length if the type is FIXED_LEN_BYTE_ARRAY, 0 otherwise (XXX)
        originalType - (optional) the original type to help with cross schema conversion (LIST, MAP, ...)
      • PrimitiveType

        @Deprecated
        public PrimitiveType​(Type.Repetition repetition,
                             PrimitiveType.PrimitiveTypeName primitive,
                             int length,
                             String name,
                             OriginalType originalType,
                             DecimalMetadata decimalMeta,
                             Type.ID id)
        Deprecated.
        will be removed in 2.0.0; use builders in Types instead
        Parameters:
        repetition - OPTIONAL, REPEATED, REQUIRED
        primitive - STRING, INT64, ...
        name - the name of the type
        length - the length if the type is FIXED_LEN_BYTE_ARRAY, 0 otherwise
        originalType - (optional) the original type (MAP, DECIMAL, UTF8, ...)
        decimalMeta - (optional) metadata about the decimal type
        id - the id of the field
    • Method Detail

      • withId

        public PrimitiveType withId​(int id)
        Specified by:
        withId in class Type
        Parameters:
        id - the field id
        Returns:
        a new PrimitiveType with the same fields and a new id
      • getTypeLength

        public int getTypeLength()
        Returns:
        the type length
      • isPrimitive

        public boolean isPrimitive()
        Specified by:
        isPrimitive in class Type
        Returns:
        true
      • accept

        public void accept​(TypeVisitor visitor)
        Visits this type with the given visitor
        Specified by:
        accept in class Type
        Parameters:
        visitor - the visitor to visit this type
      • writeToStringBuilder

        public void writeToStringBuilder​(StringBuilder sb,
                                         String indent)
        Writes a string representation to the provided StringBuilder
        Specified by:
        writeToStringBuilder in class Type
        Parameters:
        sb - the StringBuilder to write itself to
        indent - indentation level
      • equals

        protected boolean equals​(Type other)
        Overrides:
        equals in class Type
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Type
      • containsPath

        protected boolean containsPath​(String[] path,
                                       int depth)
        Specified by:
        containsPath in class Type
      • union

        protected Type union​(Type toMerge)
        Specified by:
        union in class Type
        Parameters:
        toMerge - the type to merge into this one
        Returns:
        the union result of merging toMerge into this
      • union

        protected Type union​(Type toMerge,
                             boolean strict)
        Specified by:
        union in class Type
        Parameters:
        toMerge - the type to merge into this one
        strict - should schema primitive types match
        Returns:
        the union result of merging toMerge into this
      • comparator

        public <T> PrimitiveComparator<T> comparator()
        Returns the Type specific comparator for properly comparing values. The natural ordering of the values might not proper in certain cases (e.g. UINT_32 requires unsigned comparison of int values while the natural ordering is signed.)
        Type Parameters:
        T - the type of values compared by the returned PrimitiveComparator
        Returns:
        a PrimitiveComparator for values of this type
      • columnOrder

        public ColumnOrder columnOrder()
        Returns:
        the column order for this type
      • stringifier

        public PrimitiveStringifier stringifier()
        Returns:
        the Type specific stringifier for generating the proper string representation of the values.