Package org.apache.avro.hadoop.io
Class AvroSerializer<T>
java.lang.Object
org.apache.avro.hadoop.io.AvroSerializer<T>
- Type Parameters:
T- The Java type of the Avro data.
- All Implemented Interfaces:
Serializer<AvroWrapper<T>>
Serializes AvroWrapper objects within Hadoop.
Keys and values containing Avro types are more efficiently serialized outside
of the WritableSerialization model, so they are wrapped in
AvroWrapper objects and serialization is
handled by this class.
MapReduce jobs that use AvroWrapper objects as keys or values need to be
configured with AvroSerialization. Use
AvroJob to help with Job configuration.
-
Constructor Summary
ConstructorsConstructorDescriptionAvroSerializer(Schema writerSchema) Constructor.AvroSerializer(Schema writerSchema, DatumWriter<T> datumWriter) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Gets the writer schema being used for serialization.voidopen(OutputStream outputStream) voidserialize(AvroWrapper<T> avroWrapper)
-
Constructor Details
-
AvroSerializer
Constructor.- Parameters:
writerSchema- The writer schema for the Avro data being serialized.
-
AvroSerializer
Constructor.- Parameters:
writerSchema- The writer schema for the Avro data being serialized.datumWriter- The datum writer to use for serialization.
-
-
Method Details
-
getWriterSchema
Gets the writer schema being used for serialization.- Returns:
- The writer schema.
-
open
- Specified by:
openin interfaceSerializer<T>- Throws:
IOException
-
serialize
- Specified by:
serializein interfaceSerializer<T>- Throws:
IOException
-
close
- Specified by:
closein interfaceSerializer<T>- Throws:
IOException
-