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
ConstructorDescriptionAvroSerializer
(Schema writerSchema) Constructor.AvroSerializer
(Schema writerSchema, DatumWriter<T> datumWriter) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Gets the writer schema being used for serialization.void
open
(OutputStream outputStream) void
serialize
(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:
open
in interfaceSerializer<T>
- Throws:
IOException
-
serialize
- Specified by:
serialize
in interfaceSerializer<T>
- Throws:
IOException
-
close
- Specified by:
close
in interfaceSerializer<T>
- Throws:
IOException
-