Class NativeLogicalTypesAvroTypeManager

java.lang.Object
io.trino.hive.formats.avro.NativeLogicalTypesAvroTypeManager
All Implemented Interfaces:
AvroTypeManager

public class NativeLogicalTypesAvroTypeManager extends Object implements AvroTypeManager
An implementation that translates Avro Standard Logical types into Trino SPI types
  • Field Details

    • TIMESTAMP_MILLIS_SCHEMA

      public static final org.apache.avro.Schema TIMESTAMP_MILLIS_SCHEMA
    • TIMESTAMP_MICROS_SCHEMA

      public static final org.apache.avro.Schema TIMESTAMP_MICROS_SCHEMA
    • DATE_SCHEMA

      public static final org.apache.avro.Schema DATE_SCHEMA
    • TIME_MILLIS_SCHEMA

      public static final org.apache.avro.Schema TIME_MILLIS_SCHEMA
    • TIME_MICROS_SCHEMA

      public static final org.apache.avro.Schema TIME_MICROS_SCHEMA
    • UUID_SCHEMA

      public static final org.apache.avro.Schema UUID_SCHEMA
    • DECIMAL

      protected static final String DECIMAL
      See Also:
    • UUID

      protected static final String UUID
      See Also:
    • DATE

      protected static final String DATE
      See Also:
    • TIME_MILLIS

      protected static final String TIME_MILLIS
      See Also:
    • TIME_MICROS

      protected static final String TIME_MICROS
      See Also:
    • TIMESTAMP_MILLIS

      protected static final String TIMESTAMP_MILLIS
      See Also:
    • TIMESTAMP_MICROS

      protected static final String TIMESTAMP_MICROS
      See Also:
    • LOCAL_TIMESTAMP_MILLIS

      protected static final String LOCAL_TIMESTAMP_MILLIS
      See Also:
    • LOCAL_TIMESTAMP_MICROS

      protected static final String LOCAL_TIMESTAMP_MICROS
      See Also:
  • Constructor Details

    • NativeLogicalTypesAvroTypeManager

      public NativeLogicalTypesAvroTypeManager()
  • Method Details

    • configure

      public void configure(Map<String,byte[]> fileMetadata)
      Description copied from interface: AvroTypeManager
      Called when the type manager is reading out data from a data file such as in AvroFileReader
      Specified by:
      configure in interface AvroTypeManager
      Parameters:
      fileMetadata - metadata from the file header
    • overrideTypeForSchema

      public Optional<Type> overrideTypeForSchema(org.apache.avro.Schema schema) throws AvroTypeException
      Specified by:
      overrideTypeForSchema in interface AvroTypeManager
      Throws:
      AvroTypeException
    • overrideBuildingFunctionForSchema

      public Optional<BiConsumer<BlockBuilder,Object>> overrideBuildingFunctionForSchema(org.apache.avro.Schema schema) throws AvroTypeException
      Description copied from interface: AvroTypeManager
      Object provided by FasterReader's deserialization with no conversions. Object class determined by Avro's standard generic data process BlockBuilder provided by Type returned above for the schema Possible to override for each primitive type as well.
      Specified by:
      overrideBuildingFunctionForSchema in interface AvroTypeManager
      Throws:
      AvroTypeException
    • overrideBlockToAvroObject

      public Optional<BiFunction<Block,Integer,Object>> overrideBlockToAvroObject(org.apache.avro.Schema schema, Type type) throws AvroTypeException
      Description copied from interface: AvroTypeManager
      Extract and convert the object from the given block at the given position and return the Avro Generic Data forum. Type is either provided explicitly to the writer or derived from the schema using this interface.
      Specified by:
      overrideBlockToAvroObject in interface AvroTypeManager
      Throws:
      AvroTypeException
    • validateLogicalType

      protected static NativeLogicalTypesAvroTypeManager.ValidateLogicalTypeResult validateLogicalType(org.apache.avro.Schema schema)
    • fromBigEndian

      public static long fromBigEndian(byte[] bytes)
      Decode a long from the two's complement big-endian representation.
      Parameters:
      bytes - the two's complement big-endian encoding of the number. It must contain at least 1 byte. It may contain more than 8 bytes if the leading bytes are not significant (either zeros or -1)
      Throws:
      ArithmeticException - if the bytes represent a number outside the range [-2^63, 2^63 - 1]
    • fitBigEndianValueToByteArraySize

      public static byte[] fitBigEndianValueToByteArraySize(long value, int byteSize)
    • fitBigEndianValueToByteArraySize

      public static byte[] fitBigEndianValueToByteArraySize(Int128 value, int byteSize)
    • fitBigEndianValueToByteArraySize

      public static byte[] fitBigEndianValueToByteArraySize(byte[] value, int byteSize)
      Will resize big endian bytes to a desired array length while preserving the represented value.
      Throws:
      ArithmeticException - if conversion is not possible
    • padBigEndianToSize

      public static byte[] padBigEndianToSize(Int128 toPad, int byteSize)
    • padBigEndianToSize

      public static byte[] padBigEndianToSize(long toPad, int byteSize)
    • padBigEndianToSize

      public static byte[] padBigEndianToSize(byte[] toPad, int byteSize)