Package org.apache.avro.generic
Class DeterministicMapOrderGenericDatumWriter<T>
java.lang.Object
org.apache.avro.generic.GenericDatumWriter<T>
org.apache.avro.generic.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-
Field Summary
Fields inherited from interface org.apache.avro.generic.DeterministicMapOrderDatumWriter
COMPARATOR
-
Constructor Summary
ConstructorDescriptionDeterministicMapOrderGenericDatumWriter
(org.apache.avro.generic.GenericData data) DeterministicMapOrderGenericDatumWriter
(org.apache.avro.Schema root) DeterministicMapOrderGenericDatumWriter
(org.apache.avro.Schema root, org.apache.avro.generic.GenericData data) -
Method Summary
Modifier and TypeMethodDescriptionvoid
internalWrite
(org.apache.avro.Schema schema, Object datum, org.apache.avro.io.Encoder out) protected void
Methods inherited from class org.apache.avro.generic.GenericDatumWriter
addAvroTypeMsg, addClassCastMsg, convert, getArrayElements, getArraySize, getData, getMapEntries, getMapSize, npe, resolveUnion, setSchema, write, write, writeArray, writeBytes, writeEnum, writeField, writeFixed, writeRecord, writeString, writeString, writeWithoutConversion
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.avro.generic.DeterministicMapOrderDatumWriter
writeMapWithDeterministicOrder
-
Constructor Details
-
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 Details
-
internalWrite
public void internalWrite(org.apache.avro.Schema schema, Object datum, org.apache.avro.io.Encoder out) throws IOException - Specified by:
internalWrite
in interfaceDeterministicMapOrderDatumWriter
- Throws:
IOException
-
writeMap
protected void writeMap(org.apache.avro.Schema schema, Object datum, org.apache.avro.io.Encoder out) throws IOException - Overrides:
writeMap
in classorg.apache.avro.generic.GenericDatumWriter<T>
- Throws:
IOException
-