org.apache.hadoop.io
Class SequenceFile.Writer

java.lang.Object
  extended by org.apache.hadoop.io.SequenceFile.Writer
All Implemented Interfaces:
Closeable
Enclosing class:
SequenceFile

public static class SequenceFile.Writer
extends Object
implements Closeable

Write key/value pairs to a sequence-format file.


Field Summary
protected  Serializer compressedValSerializer
           
protected  Serializer keySerializer
           
protected  Serializer uncompressedValSerializer
           
 
Constructor Summary
SequenceFile.Writer(FileSystem fs, Configuration conf, Path name, Class keyClass, Class valClass)
          Create the named file.
SequenceFile.Writer(FileSystem fs, Configuration conf, Path name, Class keyClass, Class valClass, int bufferSize, short replication, long blockSize, Progressable progress, SequenceFile.Metadata metadata)
          Create the named file with write-progress reporter.
SequenceFile.Writer(FileSystem fs, Configuration conf, Path name, Class keyClass, Class valClass, Progressable progress, SequenceFile.Metadata metadata)
          Create the named file with write-progress reporter.
 
Method Summary
 void append(Object key, Object val)
          Append a key/value pair.
 void append(Writable key, Writable val)
          Append a key/value pair.
 void appendRaw(byte[] keyData, int keyOffset, int keyLength, SequenceFile.ValueBytes val)
           
 void close()
          Close the file.
 CompressionCodec getCompressionCodec()
          Returns the compression codec of data in this file.
 Class getKeyClass()
          Returns the class of keys in this file.
 long getLength()
          Returns the current length of the output file.
 Class getValueClass()
          Returns the class of values in this file.
 void sync()
          create a sync point
 void syncFs()
          flush all currently written data to the file system
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keySerializer

protected Serializer keySerializer

uncompressedValSerializer

protected Serializer uncompressedValSerializer

compressedValSerializer

protected Serializer compressedValSerializer
Constructor Detail

SequenceFile.Writer

public SequenceFile.Writer(FileSystem fs,
                           Configuration conf,
                           Path name,
                           Class keyClass,
                           Class valClass)
                    throws IOException
Create the named file.

Throws:
IOException

SequenceFile.Writer

public SequenceFile.Writer(FileSystem fs,
                           Configuration conf,
                           Path name,
                           Class keyClass,
                           Class valClass,
                           Progressable progress,
                           SequenceFile.Metadata metadata)
                    throws IOException
Create the named file with write-progress reporter.

Throws:
IOException

SequenceFile.Writer

public SequenceFile.Writer(FileSystem fs,
                           Configuration conf,
                           Path name,
                           Class keyClass,
                           Class valClass,
                           int bufferSize,
                           short replication,
                           long blockSize,
                           Progressable progress,
                           SequenceFile.Metadata metadata)
                    throws IOException
Create the named file with write-progress reporter.

Throws:
IOException
Method Detail

getKeyClass

public Class getKeyClass()
Returns the class of keys in this file.


getValueClass

public Class getValueClass()
Returns the class of values in this file.


getCompressionCodec

public CompressionCodec getCompressionCodec()
Returns the compression codec of data in this file.


sync

public void sync()
          throws IOException
create a sync point

Throws:
IOException

syncFs

public void syncFs()
            throws IOException
flush all currently written data to the file system

Throws:
IOException

close

public void close()
           throws IOException
Close the file.

Specified by:
close in interface Closeable
Throws:
IOException

append

public void append(Writable key,
                   Writable val)
            throws IOException
Append a key/value pair.

Throws:
IOException

append

public void append(Object key,
                   Object val)
            throws IOException
Append a key/value pair.

Throws:
IOException

appendRaw

public void appendRaw(byte[] keyData,
                      int keyOffset,
                      int keyLength,
                      SequenceFile.ValueBytes val)
               throws IOException
Throws:
IOException

getLength

public long getLength()
               throws IOException
Returns the current length of the output file.

This always returns a synchronized position. In other words, immediately after calling SequenceFile.Reader.seek(long) with a position returned by this method, SequenceFile.Reader.next(Writable) may be called. However the key may be earlier in the file than key last written when this method was called (e.g., with block-compression, it may be the first key in the block that was being written when this method was called).

Throws:
IOException


Copyright © 2009 The Apache Software Foundation