Package io.trino.hive.formats.avro
Class NativeLogicalTypesAvroTypeManager
java.lang.Object
io.trino.hive.formats.avro.NativeLogicalTypesAvroTypeManager
- All Implemented Interfaces:
AvroTypeManager
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 classprotected static classprotected static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringstatic final org.apache.avro.Schemaprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringstatic final org.apache.avro.Schemaprotected static final Stringstatic final org.apache.avro.Schemaprotected static final Stringstatic final org.apache.avro.Schemaprotected static final Stringstatic final org.apache.avro.Schemaprotected static final Stringstatic final org.apache.avro.Schema -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when the type manager is reading out data from a data file such as inAvroFileReaderstatic 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.overrideBuildingFunctionForSchema(org.apache.avro.Schema schema) Object provided by FasterReader's deserialization with no conversions.overrideTypeForSchema(org.apache.avro.Schema schema) static byte[]padBigEndianToSize(byte[] toPad, int byteSize) static byte[]padBigEndianToSize(long toPad, int byteSize) static byte[]padBigEndianToSize(Int128 toPad, int byteSize) protected static NativeLogicalTypesAvroTypeManager.ValidateLogicalTypeResultvalidateLogicalType(org.apache.avro.Schema schema)
-
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
- See Also:
-
UUID
- See Also:
-
DATE
- See Also:
-
TIME_MILLIS
- See Also:
-
TIME_MICROS
- See Also:
-
TIMESTAMP_MILLIS
- See Also:
-
TIMESTAMP_MICROS
- See Also:
-
LOCAL_TIMESTAMP_MILLIS
- See Also:
-
LOCAL_TIMESTAMP_MICROS
- See Also:
-
-
Constructor Details
-
NativeLogicalTypesAvroTypeManager
public NativeLogicalTypesAvroTypeManager()
-
-
Method Details
-
configure
Description copied from interface:AvroTypeManagerCalled when the type manager is reading out data from a data file such as inAvroFileReader- Specified by:
configurein interfaceAvroTypeManager- Parameters:
fileMetadata- metadata from the file header
-
overrideTypeForSchema
- Specified by:
overrideTypeForSchemain interfaceAvroTypeManager- Throws:
AvroTypeException
-
overrideBuildingFunctionForSchema
public Optional<BiConsumer<BlockBuilder,Object>> overrideBuildingFunctionForSchema(org.apache.avro.Schema schema) throws AvroTypeException Description copied from interface:AvroTypeManagerObject 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:
overrideBuildingFunctionForSchemain interfaceAvroTypeManager- Throws:
AvroTypeException
-
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
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
-
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)
-