Class PrimitiveType

java.lang.Object
org.apache.parquet.schema.Type
org.apache.parquet.schema.PrimitiveType

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

    • PrimitiveType

      public PrimitiveType(Type.Repetition repetition, PrimitiveType.PrimitiveTypeName primitive, String name)
      Parameters:
      repetition - OPTIONAL, REPEATED, REQUIRED
      primitive - STRING, INT64, ...
      name - the name of the type
    • 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 Details

    • 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
    • withLogicalTypeAnnotation

      public PrimitiveType withLogicalTypeAnnotation(LogicalTypeAnnotation logicalType)
      Parameters:
      logicalType - LogicalTypeAnnotation
      Returns:
      a new PrimitiveType with the same fields and the given logical type annotation
    • withColumnOrder

      public Type withColumnOrder(ColumnOrder columnOrder)
      Parameters:
      columnOrder - the column order
      Returns:
      the same type with the column order set
    • getPrimitiveTypeName

      public PrimitiveType.PrimitiveTypeName getPrimitiveTypeName()
      Returns:
      the primitive type
    • getTypeLength

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

      @Deprecated public DecimalMetadata getDecimalMetadata()
      Deprecated.
      Returns:
      the decimal type metadata
    • 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
    • typeHashCode

      @Deprecated protected int typeHashCode()
      Deprecated.
      Specified by:
      typeHashCode in class Type
    • typeEquals

      @Deprecated protected boolean typeEquals(Type other)
      Deprecated.
      Specified by:
      typeEquals in class Type
    • equals

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

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

      public int getMaxRepetitionLevel(String[] path, int i)
      Specified by:
      getMaxRepetitionLevel in class Type
    • getMaxDefinitionLevel

      public int getMaxDefinitionLevel(String[] path, int i)
      Specified by:
      getMaxDefinitionLevel in class Type
    • getType

      public Type getType(String[] path, int i)
      Specified by:
      getType in class Type
    • getPaths

      protected List<String[]> getPaths(int depth)
      Specified by:
      getPaths in class Type
    • convert

      public <T> T convert(List<GroupType> path, TypeConverter<T> converter)
    • 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.