public class AvroUtil extends Object
Modifier and Type | Field and Description |
---|---|
static int |
AVRO_FINGERPRINT_LENGTH
Length of encoded fingerprint long value.
|
static int |
AVRO_HEADER_LENGTH
Header size of single-object-encoding as defined in Avro
specification.
|
static int |
FORMAT_VERSION
Format version of single-objet-encoding as defined in Avro
specification.
|
static org.apache.avro.generic.GenericData |
genericData
Constant utilities for construction of
GenericRecord preloaded by default Avro
stack. |
static int |
MAGIC_BYTE
Magic marker bytes, indicating single-objet-encoding as defined in Avro
specification.
|
Modifier and Type | Method and Description |
---|---|
static List<org.apache.avro.SchemaCompatibility.Incompatibility> |
checkCompatibility(org.apache.avro.Schema readerSchema,
org.apache.avro.Schema writerSchema)
Checks compatibility between reader and writer schema.
|
static SerializationException |
createExceptionFailedToDeserialize(Class<?> readerType,
org.apache.avro.Schema readerSchema,
org.apache.avro.Schema writerSchema,
Exception cause,
boolean includeSchemasInStackTraces)
Creates a serialization exception for reader type.
|
static SerializationException |
createExceptionFailedToDeserialize(Class<?> readerType,
org.apache.avro.Schema readerSchema,
org.apache.avro.Schema writerSchema,
String message,
boolean includeSchemasInStackTraces) |
static SerializationException |
createExceptionNoSchemaFound(Class<?> readerType,
long fingerprint)
Creates exception if the schema for a given fingerprint could not be found.
|
static long |
fingerprint(byte[] singleObjectEncodedBytes)
Reads fingerprint from single object encoded byte array.
|
static long |
fingerprint(org.apache.avro.Schema schema)
Returns a fingerprint based on the given
schema . |
static org.apache.avro.generic.GenericData |
fromSpecificData(org.apache.avro.specific.SpecificData specificData)
Creates generic data from specific data.
|
static org.apache.avro.Schema |
getClassSchema(Class<org.apache.avro.specific.SpecificRecordBase> clazz)
Retrieves schema from specific record base class.
|
static org.apache.avro.Schema |
getClassSchemaChecked(Class<org.apache.avro.specific.SpecificRecordBase> specificRecordBaseClass)
Retrieves schema from specific record base class.
|
static String |
incompatibilityPrinter(org.apache.avro.SchemaCompatibility.Incompatibility incompatibility)
Creates incompatibility string representation.
|
static byte[] |
payload(byte[] singleObjectEncodedBytes)
Reads payload from single object encoded byte array.
|
public static final int MAGIC_BYTE
public static final int FORMAT_VERSION
public static final int AVRO_FINGERPRINT_LENGTH
public static final int AVRO_HEADER_LENGTH
public static final org.apache.avro.generic.GenericData genericData
GenericRecord
preloaded by default Avro
stack.public static long fingerprint(@Nonnull byte[] singleObjectEncodedBytes)
singleObjectEncodedBytes
- The single object encoded byte array.org.apache.avro.AvroRuntimeException
- if fingerprint can not be read from input bytes.public static byte[] payload(@Nonnull byte[] singleObjectEncodedBytes)
singleObjectEncodedBytes
- The single object encoded byte array.org.apache.avro.AvroRuntimeException
- if payload bytes can not be read from input bytes.public static org.apache.avro.generic.GenericData fromSpecificData(org.apache.avro.specific.SpecificData specificData)
specificData
- specific data.@Nonnull public static org.apache.avro.Schema getClassSchemaChecked(@Nonnull Class<org.apache.avro.specific.SpecificRecordBase> specificRecordBaseClass)
specificRecordBaseClass
- class extending SpecificRecordBase
org.apache.avro.AvroRuntimeException
- on any errors.@Nonnull public static org.apache.avro.Schema getClassSchema(@Nonnull Class<org.apache.avro.specific.SpecificRecordBase> clazz) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
clazz
- class extending SpecificRecordBase
NoSuchMethodException
- on wrong class structure.InvocationTargetException
- on wrong class structure.IllegalAccessException
- on wrong class structure.public static long fingerprint(@Nonnull org.apache.avro.Schema schema)
schema
.schema
- A Schema
to return the fingerprint for.schema
.public static List<org.apache.avro.SchemaCompatibility.Incompatibility> checkCompatibility(@Nonnull org.apache.avro.Schema readerSchema, @Nonnull org.apache.avro.Schema writerSchema)
readerSchema
- reader schema.writerSchema
- writer schema.@Nonnull public static SerializationException createExceptionFailedToDeserialize(@Nonnull Class<?> readerType, @Nonnull org.apache.avro.Schema readerSchema, @Nonnull org.apache.avro.Schema writerSchema, Exception cause, boolean includeSchemasInStackTraces)
readerType
- object type to deserialize.readerSchema
- reader schema.writerSchema
- writer schema.cause
- the cause of exception.public static SerializationException createExceptionFailedToDeserialize(@Nonnull Class<?> readerType, @Nonnull org.apache.avro.Schema readerSchema, @Nonnull org.apache.avro.Schema writerSchema, String message, boolean includeSchemasInStackTraces)
public static String incompatibilityPrinter(@Nonnull org.apache.avro.SchemaCompatibility.Incompatibility incompatibility)
incompatibility
- incompatibility to display.public static SerializationException createExceptionNoSchemaFound(@Nonnull Class<?> readerType, long fingerprint)
readerType
- type of object to deserialize.fingerprint
- fingerprint of writer schema.Copyright © 2010–2025. All rights reserved.