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

java.lang.Object
  extended by org.apache.hadoop.hbase.io.hfile.HFile

public class HFile
extends Object

File format for hbase. A file of sorted key/value pairs. Both keys and values are byte arrays.

The memory footprint of a HFile includes the following (below is taken from the TFile documentation but applies also to HFile):

Suggestions on performance optimization. For more on the background behind HFile, see HBASE-61.

File is made of data blocks followed by meta data blocks (if any), a fileinfo block, data block index, meta data block index, and a fixed size trailer which records the offsets at which file changes content type.

<data blocks><meta blocks><fileinfo><data index><meta index><trailer>
Each block has a bit of magic at its start. Block are comprised of key/values. In data blocks, they are both byte arrays. Metadata blocks are a String key and a byte array value. An empty file looks like this:
<fileinfo><trailer>
. That is, there are not data nor meta blocks present.

TODO: Do scanners need to be able to take a start and end row? TODO: Should BlockIndex know the name of its file? Should it have a Path that points at its file say for the case where an index lives apart from an HFile instance?


Nested Class Summary
static class HFile.Reader
          HFile Reader.
static class HFile.Writer
          HFile Writer.
 
Field Summary
static int DEFAULT_BLOCKSIZE
          Default blocksize for hfile.
static String DEFAULT_COMPRESSION
          Default compression name: none.
static Compression.Algorithm DEFAULT_COMPRESSION_ALGORITHM
          Default compression: none.
static int MAXIMUM_KEY_LENGTH
          Maximum length of key in HFile.
 
Constructor Summary
HFile()
           
 
Method Summary
static long getReadOps()
           
static long getReadTime()
           
static String[] getSupportedCompressionAlgorithms()
          Get names of supported compression algorithms.
static long getWriteOps()
           
static long getWriteTime()
           
static boolean isReservedFileInfoKey(byte[] key)
          Return true if the given file info key is reserved for internal use by HFile.
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXIMUM_KEY_LENGTH

public static final int MAXIMUM_KEY_LENGTH
Maximum length of key in HFile.

See Also:
Constant Field Values

DEFAULT_BLOCKSIZE

public static final int DEFAULT_BLOCKSIZE
Default blocksize for hfile.

See Also:
Constant Field Values

DEFAULT_COMPRESSION_ALGORITHM

public static final Compression.Algorithm DEFAULT_COMPRESSION_ALGORITHM
Default compression: none.


DEFAULT_COMPRESSION

public static final String DEFAULT_COMPRESSION
Default compression name: none.

Constructor Detail

HFile

public HFile()
Method Detail

getReadOps

public static final long getReadOps()

getReadTime

public static final long getReadTime()

getWriteOps

public static final long getWriteOps()

getWriteTime

public static final long getWriteTime()

isReservedFileInfoKey

public static boolean isReservedFileInfoKey(byte[] key)
Return true if the given file info key is reserved for internal use by HFile.


getSupportedCompressionAlgorithms

public static String[] getSupportedCompressionAlgorithms()
Get names of supported compression algorithms. The names are acceptable by HFile.Writer.

Returns:
Array of strings, each represents a supported compression algorithm. Currently, the following compression algorithms are supported.
  • "none" - No compression.
  • "gz" - GZIP compression.

main

public static void main(String[] args)
                 throws IOException
Throws:
IOException


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