Class AvroRecordUtils


  • public class AvroRecordUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void clearRecord​(org.apache.avro.generic.GenericRecord record)  
      static <T extends org.apache.avro.specific.SpecificRecord>
      T
      prefillAvroRecordWithDefaultValue​(T recordType)
      This function is used to pre-fill the default value defined in schema.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • prefillAvroRecordWithDefaultValue

        public static <T extends org.apache.avro.specific.SpecificRecord> T prefillAvroRecordWithDefaultValue​(T recordType)
        This function is used to pre-fill the default value defined in schema. So far, it only support the followings: 1. Only top-level fields are supported. 2. All the primitive types are supported. 3. For union, only `null` default is supported. 4. For array/map, only empty list/map are supported. Other than the above, this function will throw exception. TODO: once the whole stack migrates to the modern avro version (avro-1.7+), we could leverage SpecificRecord builder to prefill the default value, which will be much more powerful.
        Type Parameters:
        T -
        Parameters:
        recordType -
        Returns:
      • clearRecord

        public static void clearRecord​(org.apache.avro.generic.GenericRecord record)