Class AvroUtils
- java.lang.Object
-
- org.apache.flink.api.java.typeutils.AvroUtils
-
- Direct Known Subclasses:
AvroKryoSerializerUtils
public abstract class AvroUtils extends Object
Utility methods for dealing with Avro types. This has a default implementation for the case that Avro is not present on the classpath and an actual implementation in flink-avro that is dynamically loaded when present.
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
AVRO_SPECIFIC_RECORD_BASE_CLASS
-
Constructor Summary
Constructors Constructor Description AvroUtils()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
addAvroGenericDataArrayRegistration(LinkedHashMap<String,KryoRegistration> kryoRegistrations)
Registers a special Serializer for GenericData.Array.abstract void
addAvroSerializersIfRequired(SerializerConfig reg, Class<?> type)
Loads the utility class fromflink-avro
and adds Avro-specific serializers.abstract <T> TypeSerializer<T>
createAvroSerializer(Class<T> type)
Creates anAvroSerializer
if flink-avro is present, otherwise throws an exception.abstract <T> TypeInformation<T>
createAvroTypeInfo(Class<T> type)
Creates anAvroTypeInfo
if flink-avro is present, otherwise throws an exception.static AvroUtils
getAvroUtils()
Returns either the defaultAvroUtils
which throw an exception in cases where Avro would be needed or loads the specific utils for Avro from flink-avro.static boolean
isAvroSpecificRecord(Class<?> clazz)
static Optional<AvroUtils>
tryGetAvroUtils()
Returns eitherOptional#EMPTY
which throw an exception in cases where Avro would be needed or loads the specific utils for Avro from flink-avro.
-
-
-
Field Detail
-
AVRO_SPECIFIC_RECORD_BASE_CLASS
protected static final String AVRO_SPECIFIC_RECORD_BASE_CLASS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAvroUtils
public static AvroUtils getAvroUtils()
Returns either the defaultAvroUtils
which throw an exception in cases where Avro would be needed or loads the specific utils for Avro from flink-avro.
-
tryGetAvroUtils
public static Optional<AvroUtils> tryGetAvroUtils()
Returns eitherOptional#EMPTY
which throw an exception in cases where Avro would be needed or loads the specific utils for Avro from flink-avro.
-
isAvroSpecificRecord
public static boolean isAvroSpecificRecord(Class<?> clazz)
-
addAvroSerializersIfRequired
public abstract void addAvroSerializersIfRequired(SerializerConfig reg, Class<?> type)
Loads the utility class fromflink-avro
and adds Avro-specific serializers. This method will throw an exception if we see an Avro type but flink-avro is not in the classpath.
-
addAvroGenericDataArrayRegistration
public abstract void addAvroGenericDataArrayRegistration(LinkedHashMap<String,KryoRegistration> kryoRegistrations)
Registers a special Serializer for GenericData.Array.
-
createAvroSerializer
public abstract <T> TypeSerializer<T> createAvroSerializer(Class<T> type)
Creates anAvroSerializer
if flink-avro is present, otherwise throws an exception.
-
createAvroTypeInfo
public abstract <T> TypeInformation<T> createAvroTypeInfo(Class<T> type)
Creates anAvroTypeInfo
if flink-avro is present, otherwise throws an exception.
-
-