Package io.trino.hive.formats.avro
Class NativeLogicalTypesAvroTypeManager
java.lang.Object
io.trino.hive.formats.avro.NativeLogicalTypesAvroTypeManager
- All Implemented Interfaces:
AvroTypeManager
- Direct Known Subclasses:
HiveAvroTypeManager
An implementation that translates Avro Standard Logical types into Trino SPI types
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classprotected static final classprotected static final classstatic classprotected static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.avro.Schemastatic final org.apache.avro.Schemastatic final org.apache.avro.Schemastatic final org.apache.avro.Schemastatic final org.apache.avro.Schemastatic final org.apache.avro.Schema -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]fitBigEndianValueToByteArraySize(byte[] value, int byteSize) Will resize big endian bytes to a desired array length while preserving the represented value.static byte[]fitBigEndianValueToByteArraySize(long value, int byteSize) static byte[]fitBigEndianValueToByteArraySize(Int128 value, int byteSize) static longfromBigEndian(byte[] bytes) Decode a long from the two's complement big-endian representation.overrideBlockToAvroObject(org.apache.avro.Schema schema, Type type) Extract and convert the object from the given block at the given position and return the Avro Generic Data forum.static byte[]padBigEndianToSize(byte[] toPad, int byteSize) static byte[]padBigEndianToSize(long toPad, int byteSize) static byte[]padBigEndianToSize(Int128 toPad, int byteSize) validateLogicalType(org.apache.avro.Schema schema)
-
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, overrideBlockToAvroObjectObject>> (org.apache.avro.Schema schema, Type type) throws AvroTypeException Description copied from interface:AvroTypeManagerExtract 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:
overrideBlockToAvroObjectin interfaceAvroTypeManager- 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
-
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
-
padBigEndianToSize
public static byte[] padBigEndianToSize(long toPad, int byteSize) -
padBigEndianToSize
public static byte[] padBigEndianToSize(byte[] toPad, int byteSize)
-