Class DeterministicMapOrderGenericDatumWriter<T>

  • All Implemented Interfaces:
    DeterministicMapOrderDatumWriter, org.apache.avro.io.DatumWriter<T>

    public class DeterministicMapOrderGenericDatumWriter<T>
    extends org.apache.avro.generic.GenericDatumWriter<T>
    implements DeterministicMapOrderDatumWriter
    An Avro generic datum writer that sorts the map entries by keys before serializing the map. In original Avro implementation GenericDatumWriter Avro gets all entries from the Map and serializes the entries right away. This may generate inconsistent results if 2 maps have the same entry set but are constructed in the different orders. A specific datum writer is also provided. See DeterministicMapOrderSpecificDatumWriter for more details. TODO: consider putting the class to Fast Avro library
    • Constructor Detail

      • DeterministicMapOrderGenericDatumWriter

        public DeterministicMapOrderGenericDatumWriter​(org.apache.avro.Schema root)
      • DeterministicMapOrderGenericDatumWriter

        public DeterministicMapOrderGenericDatumWriter​(org.apache.avro.generic.GenericData data)
      • DeterministicMapOrderGenericDatumWriter

        public DeterministicMapOrderGenericDatumWriter​(org.apache.avro.Schema root,
                                                       org.apache.avro.generic.GenericData data)
    • Method Detail

      • internalWrite

        public void internalWrite​(org.apache.avro.Schema schema,
                                  java.lang.Object datum,
                                  org.apache.avro.io.Encoder out)
                           throws java.io.IOException
        Specified by:
        internalWrite in interface DeterministicMapOrderDatumWriter
        Throws:
        java.io.IOException
      • writeMap

        protected void writeMap​(org.apache.avro.Schema schema,
                                java.lang.Object datum,
                                org.apache.avro.io.Encoder out)
                         throws java.io.IOException
        Overrides:
        writeMap in class org.apache.avro.generic.GenericDatumWriter<T>
        Throws:
        java.io.IOException