org.apache.avro.hadoop.io
Class AvroDeserializer<T extends AvroWrapper<D>,D>

java.lang.Object
  extended by 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:
org.apache.hadoop.io.serializer.Deserializer<T>
Direct Known Subclasses:
AvroKeyDeserializer, AvroValueDeserializer

public abstract class AvroDeserializer<T extends AvroWrapper<D>,D>
extends Object
implements org.apache.hadoop.io.serializer.Deserializer<T>

Deserializes AvroWrapper objects within Hadoop.

Keys and values containing Avro tyeps 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 org.apache.avro.io.AvroSerialization. Use AvroJob to help with Job configuration.


Constructor Summary
protected AvroDeserializer(org.apache.avro.Schema writerSchema, org.apache.avro.Schema readerSchema, ClassLoader classLoader)
          Constructor.
 
Method Summary
 void close()
          
protected abstract  T createAvroWrapper()
          Creates a new empty T (extends AvroWrapper) instance.
 T deserialize(T avroWrapperToReuse)
          
 org.apache.avro.Schema getReaderSchema()
          Gets the reader schema used for deserializing.
 org.apache.avro.Schema getWriterSchema()
          Gets the writer schema used for deserializing.
 void open(InputStream inputStream)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AvroDeserializer

protected AvroDeserializer(org.apache.avro.Schema writerSchema,
                           org.apache.avro.Schema readerSchema,
                           ClassLoader classLoader)
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).
Method Detail

getWriterSchema

public org.apache.avro.Schema getWriterSchema()
Gets the writer schema used for deserializing.

Returns:
The writer schema;

getReaderSchema

public org.apache.avro.Schema getReaderSchema()
Gets the reader schema used for deserializing.

Returns:
The reader schema.

open

public void open(InputStream inputStream)
          throws IOException

Specified by:
open in interface org.apache.hadoop.io.serializer.Deserializer<T extends AvroWrapper<D>>
Throws:
IOException

deserialize

public T deserialize(T avroWrapperToReuse)
                                     throws IOException

Specified by:
deserialize in interface org.apache.hadoop.io.serializer.Deserializer<T extends AvroWrapper<D>>
Throws:
IOException

close

public void close()
           throws IOException

Specified by:
close in interface org.apache.hadoop.io.serializer.Deserializer<T extends AvroWrapper<D>>
Throws:
IOException

createAvroWrapper

protected abstract T createAvroWrapper()
Creates a new empty T (extends AvroWrapper) instance.

Returns:
A new empty T instance.


Copyright © 2009-2013 The Apache Software Foundation. All Rights Reserved.