org.apache.avro.hadoop.io
Class AvroSequenceFile

java.lang.Object
  extended by org.apache.avro.hadoop.io.AvroSequenceFile

public class AvroSequenceFile
extends Object

A wrapper around a Hadoop SequenceFile that also supports reading and writing Avro data.

The vanilla Hadoop SequenceFile contains a header followed by a sequence of records. A record consists of a key and a value. The key and value must either:

Since Avro data are Plain Old Java Objects (e.g., Integer for data with schema "int"), they do not implement Writable. Furthermore, a org.apache.hadoop.io.Serialization implementation cannot determine whether an object instance of type CharSequence that also implements Writable should be serialized using Avro or WritableSerialization.

The solution implemented in AvroSequenceFile is to:


Nested Class Summary
static class AvroSequenceFile.Reader
          A reader for SequenceFiles that may contain Avro data.
static class AvroSequenceFile.Writer
          A writer for an uncompressed SequenceFile that supports Avro data.
 
Field Summary
static org.apache.hadoop.io.Text METADATA_FIELD_KEY_SCHEMA
          The SequencFile.Metadata field for the Avro key writer schema.
static org.apache.hadoop.io.Text METADATA_FIELD_VALUE_SCHEMA
          The SequencFile.Metadata field for the Avro value writer schema.
 
Method Summary
static org.apache.hadoop.io.SequenceFile.Writer createWriter(AvroSequenceFile.Writer.Options options)
          Creates a writer from a set of options.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

METADATA_FIELD_KEY_SCHEMA

public static final org.apache.hadoop.io.Text METADATA_FIELD_KEY_SCHEMA
The SequencFile.Metadata field for the Avro key writer schema.


METADATA_FIELD_VALUE_SCHEMA

public static final org.apache.hadoop.io.Text METADATA_FIELD_VALUE_SCHEMA
The SequencFile.Metadata field for the Avro value writer schema.

Method Detail

createWriter

public static org.apache.hadoop.io.SequenceFile.Writer createWriter(AvroSequenceFile.Writer.Options options)
                                                             throws IOException
Creates a writer from a set of options.

Since there are different implementations of Writer depending on the compression type, this method constructs the appropriate subclass depending on the compression type given in the options.

Parameters:
options - The options for the writer.
Returns:
A new writer instance.
Throws:
IOException - If the writer cannot be created.


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