Package org.apache.avro.hadoop.io
Class AvroDeserializer<T extends AvroWrapper<D>,D>
java.lang.Object
org.apache.avro.hadoop.io.AvroDeserializer<T,D>
- Type Parameters:
T
- The type of Avro wrapper.D
- The Java type of the Avro data being wrapped.
- All Implemented Interfaces:
Deserializer<T>
- Direct Known Subclasses:
AvroKeyDeserializer
,AvroValueDeserializer
public abstract class AvroDeserializer<T extends AvroWrapper<D>,D>
extends Object
implements Deserializer<T>
Deserializes AvroWrapper objects within Hadoop.
Keys and values containing Avro types are more efficiently serialized outside
of the WritableSerialization model, so they are wrapper in
AvroWrapper
objects and deserialization 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
ModifierConstructorDescriptionprotected
AvroDeserializer
(Schema writerSchema, Schema readerSchema, ClassLoader classLoader) Constructor.protected
AvroDeserializer
(Schema writerSchema, Schema readerSchema, DatumReader<D> datumReader) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected abstract T
Creates a new emptyT
(extends AvroWrapper) instance.deserialize
(T avroWrapperToReuse) Gets the reader schema used for deserializing.Gets the writer schema used for deserializing.void
open
(InputStream inputStream)
-
Constructor Details
-
AvroDeserializer
Constructor.- Parameters:
writerSchema
- The Avro writer schema for the data to deserialize.readerSchema
- The Avro reader schema for the data to deserialize (may be null).
-
AvroDeserializer
Constructor.- Parameters:
writerSchema
- The Avro writer schema for the data to deserialize.readerSchema
- The Avro reader schema for the data to deserialize (may be null).datumReader
- The Avro datum reader to use for deserialization.
-
-
Method Details
-
getWriterSchema
Gets the writer schema used for deserializing.- Returns:
- The writer schema;
-
getReaderSchema
Gets the reader schema used for deserializing.- Returns:
- The reader schema.
-
open
- Specified by:
open
in interfaceDeserializer<T extends AvroWrapper<D>>
- Throws:
IOException
-
deserialize
- Specified by:
deserialize
in interfaceDeserializer<T extends AvroWrapper<D>>
- Throws:
IOException
-
close
- Specified by:
close
in interfaceDeserializer<T extends AvroWrapper<D>>
- Throws:
IOException
-
createAvroWrapper
Creates a new emptyT
(extends AvroWrapper) instance.- Returns:
- A new empty
T
instance.
-