T
- The Java type of the Avro data.public class AvroSerializer<T> extends Object implements Serializer<AvroWrapper<T>>
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 and Description |
---|
AvroSerializer(Schema writerSchema)
Constructor.
|
AvroSerializer(Schema writerSchema,
DatumWriter<T> datumWriter)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
Schema |
getWriterSchema()
Gets the writer schema being used for serialization.
|
void |
open(OutputStream outputStream) |
void |
serialize(AvroWrapper<T> avroWrapper) |
public AvroSerializer(Schema writerSchema)
writerSchema
- The writer schema for the Avro data being serialized.public AvroSerializer(Schema writerSchema, DatumWriter<T> datumWriter)
writerSchema
- The writer schema for the Avro data being serialized.datumWriter
- The datum writer to use for serialization.public Schema getWriterSchema()
public void open(OutputStream outputStream) throws IOException
open
in interface Serializer<AvroWrapper<T>>
IOException
public void serialize(AvroWrapper<T> avroWrapper) throws IOException
serialize
in interface Serializer<AvroWrapper<T>>
IOException
public void close() throws IOException
close
in interface Serializer<AvroWrapper<T>>
IOException
Copyright © 2009–2016 The Apache Software Foundation. All rights reserved.