org.apache.avro.hadoop.io
Class AvroSerializer<T>

java.lang.Object
  extended by org.apache.avro.hadoop.io.AvroSerializer<T>
Type Parameters:
T - The Java type of the Avro data.
All Implemented Interfaces:
org.apache.hadoop.io.serializer.Serializer<AvroWrapper<T>>

public class AvroSerializer<T>
extends Object
implements org.apache.hadoop.io.serializer.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 org.apache.avro.io.AvroSerialization. Use AvroJob to help with Job configuration.


Constructor Summary
AvroSerializer(org.apache.avro.Schema writerSchema)
          Constructor.
 
Method Summary
 void close()
          
 org.apache.avro.Schema getWriterSchema()
          Gets the writer schema being used for serialization.
 void open(OutputStream outputStream)
          
 void serialize(AvroWrapper<T> avroWrapper)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AvroSerializer

public AvroSerializer(org.apache.avro.Schema writerSchema)
Constructor.

Parameters:
writerSchema - The writer schema for the Avro data being serialized.
Method Detail

getWriterSchema

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

Returns:
The writer schema.

open

public void open(OutputStream outputStream)
          throws IOException

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

serialize

public void serialize(AvroWrapper<T> avroWrapper)
               throws IOException

Specified by:
serialize in interface org.apache.hadoop.io.serializer.Serializer<AvroWrapper<T>>
Throws:
IOException

close

public void close()
           throws IOException

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


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