Class NativeLogicalTypesAvroTypeManager

java.lang.Object
io.trino.hive.formats.avro.NativeLogicalTypesAvroTypeManager
All Implemented Interfaces:
AvroTypeManager
Direct Known Subclasses:
HiveAvroTypeManager

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

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

      public static final org.apache.avro.Schema UUID_SCHEMA
  • Constructor Details

    • NativeLogicalTypesAvroTypeManager

      public NativeLogicalTypesAvroTypeManager()
  • Method Details

    • 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

      public 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)