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 implementationGenericDatumWriter
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. SeeDeterministicMapOrderSpecificDatumWriter
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
Constructors Constructor Description DeterministicMapOrderGenericDatumWriter(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
internalWrite(org.apache.avro.Schema schema, java.lang.Object datum, org.apache.avro.io.Encoder out)
protected void
writeMap(org.apache.avro.Schema schema, java.lang.Object datum, org.apache.avro.io.Encoder out)
-
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 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 interfaceDeterministicMapOrderDatumWriter
- 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 classorg.apache.avro.generic.GenericDatumWriter<T>
- Throws:
java.io.IOException
-
-