org.apache.hadoop.hbase.io.hfile
Class HFile.Writer

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

public static class HFile.Writer
extends Object
implements Closeable

HFile Writer.


Field Summary
protected  String name
           
 
Constructor Summary
HFile.Writer(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path)
          Constructor that uses all defaults for compression and block size.
HFile.Writer(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, int blocksize, Compression.Algorithm compress, KeyValue.KeyComparator comparator)
          Constructor that takes a Path.
HFile.Writer(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, int blocksize, String compress, KeyValue.KeyComparator comparator)
          Constructor that takes a Path.
HFile.Writer(org.apache.hadoop.fs.FSDataOutputStream ostream, int blocksize, Compression.Algorithm compress, KeyValue.KeyComparator c)
          Constructor that takes a stream.
HFile.Writer(org.apache.hadoop.fs.FSDataOutputStream ostream, int blocksize, String compress, KeyValue.KeyComparator c)
          Constructor that takes a stream.
 
Method Summary
 void append(byte[] key, byte[] value)
          Add key/value to file.
 void append(KeyValue kv)
          Add key/value to file.
 void appendFileInfo(byte[] k, byte[] v)
          Add to the file info.
 void appendMetaBlock(String metaBlockName, org.apache.hadoop.io.Writable content)
          Add a meta block to the end of the file.
 void close()
           
 org.apache.hadoop.fs.Path getPath()
           
 long getTotalBytes()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected String name
Constructor Detail

HFile.Writer

public HFile.Writer(org.apache.hadoop.fs.FileSystem fs,
                    org.apache.hadoop.fs.Path path)
             throws IOException
Constructor that uses all defaults for compression and block size.

Parameters:
fs -
path -
Throws:
IOException

HFile.Writer

public HFile.Writer(org.apache.hadoop.fs.FileSystem fs,
                    org.apache.hadoop.fs.Path path,
                    int blocksize,
                    String compress,
                    KeyValue.KeyComparator comparator)
             throws IOException
Constructor that takes a Path.

Parameters:
fs -
path -
blocksize -
compress -
comparator -
Throws:
IOException
IOException

HFile.Writer

public HFile.Writer(org.apache.hadoop.fs.FileSystem fs,
                    org.apache.hadoop.fs.Path path,
                    int blocksize,
                    Compression.Algorithm compress,
                    KeyValue.KeyComparator comparator)
             throws IOException
Constructor that takes a Path.

Parameters:
fs -
path -
blocksize -
compress -
comparator -
Throws:
IOException

HFile.Writer

public HFile.Writer(org.apache.hadoop.fs.FSDataOutputStream ostream,
                    int blocksize,
                    String compress,
                    KeyValue.KeyComparator c)
             throws IOException
Constructor that takes a stream.

Parameters:
ostream - Stream to use.
blocksize -
compress -
c - RawComparator to use.
Throws:
IOException

HFile.Writer

public HFile.Writer(org.apache.hadoop.fs.FSDataOutputStream ostream,
                    int blocksize,
                    Compression.Algorithm compress,
                    KeyValue.KeyComparator c)
             throws IOException
Constructor that takes a stream.

Parameters:
ostream - Stream to use.
blocksize -
compress -
c -
Throws:
IOException
Method Detail

appendMetaBlock

public void appendMetaBlock(String metaBlockName,
                            org.apache.hadoop.io.Writable content)
Add a meta block to the end of the file. Call before close(). Metadata blocks are expensive. Fill one with a bunch of serialized data rather than do a metadata block per metadata instance. If metadata is small, consider adding to file info using appendFileInfo(byte[], byte[])

Parameters:
metaBlockName - name of the block
content - will call readFields to get data later (DO NOT REUSE)

appendFileInfo

public void appendFileInfo(byte[] k,
                           byte[] v)
                    throws IOException
Add to the file info. Added key value can be gotten out of the return from HFile.Reader.loadFileInfo().

Parameters:
k - Key
v - Value
Throws:
IOException

getPath

public org.apache.hadoop.fs.Path getPath()
Returns:
Path or null if we were passed a stream rather than a Path.

toString

public String toString()
Overrides:
toString in class Object

append

public void append(KeyValue kv)
            throws IOException
Add key/value to file. Keys must be added in an order that agrees with the Comparator passed on construction.

Parameters:
kv - KeyValue to add. Cannot be empty nor null.
Throws:
IOException

append

public void append(byte[] key,
                   byte[] value)
            throws IOException
Add key/value to file. Keys must be added in an order that agrees with the Comparator passed on construction.

Parameters:
key - Key to add. Cannot be empty nor null.
value - Value to add. Cannot be empty nor null.
Throws:
IOException

getTotalBytes

public long getTotalBytes()

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.