Class 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.
    • Constructor Detail

      • AvroUtils

        public AvroUtils()
    • Method Detail

      • getAvroUtils

        public static AvroUtils getAvroUtils()
        Returns either the default AvroUtils 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 either Optional#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 from flink-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 an AvroSerializer if flink-avro is present, otherwise throws an exception.
      • createAvroTypeInfo

        public abstract <T> TypeInformation<T> createAvroTypeInfo​(Class<T> type)
        Creates an AvroTypeInfo if flink-avro is present, otherwise throws an exception.