org.apache.hadoop.hbase.io
Class HalfHFileReader

java.lang.Object
  extended by org.apache.hadoop.hbase.io.hfile.HFile.Reader
      extended by org.apache.hadoop.hbase.io.HalfHFileReader
All Implemented Interfaces:
Closeable

public class HalfHFileReader
extends HFile.Reader

A facade for a HFile.Reader that serves up either the top or bottom half of a HFile where 'bottom' is the first half of the file containing the keys that sort lowest and 'top' is the second half of the file with keys that sort greater than those of the bottom half. The top includes the split files midkey, of the key that follows if it does not exist in the file.

This type works in tandem with the Reference type. This class is used reading while Reference is used writing.

This file is not splitable. Calls to midkey() return null.


Field Summary
protected  byte[] splitkey
           
 
Fields inherited from class org.apache.hadoop.hbase.io.hfile.HFile.Reader
blockLoads, cacheHits
 
Constructor Summary
HalfHFileReader(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path p, BlockCache c, Reference r)
           
 
Method Summary
 byte[] getLastKey()
           
 HFileScanner getScanner()
          Create a Scanner on this file.
 HFileScanner getScanner(boolean cacheBlocks)
          Create a Scanner on this file.
protected  boolean isTop()
           
 byte[] midkey()
           
 
Methods inherited from class org.apache.hadoop.hbase.io.hfile.HFile.Reader
blockContainingKey, close, getComparator, getEntries, getFirstKey, getMetaBlock, getTrailerInfo, indexSize, inMemory, length, loadFileInfo, toString, toStringFirstKey, toStringLastKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

splitkey

protected final byte[] splitkey
Constructor Detail

HalfHFileReader

public HalfHFileReader(org.apache.hadoop.fs.FileSystem fs,
                       org.apache.hadoop.fs.Path p,
                       BlockCache c,
                       Reference r)
                throws IOException
Parameters:
fs -
p -
c -
r -
Throws:
IOException
Method Detail

isTop

protected boolean isTop()

getScanner

public HFileScanner getScanner()
Description copied from class: HFile.Reader
Create a Scanner on this file. No seeks or reads are done on creation. Call HFileScanner.seekTo(byte[]) to position an start the read. There is nothing to clean up in a Scanner. Letting go of your references to the scanner is sufficient.

Overrides:
getScanner in class HFile.Reader
Returns:
Scanner on this file.

getScanner

public HFileScanner getScanner(boolean cacheBlocks)
Description copied from class: HFile.Reader
Create a Scanner on this file. No seeks or reads are done on creation. Call HFileScanner.seekTo(byte[]) to position an start the read. There is nothing to clean up in a Scanner. Letting go of your references to the scanner is sufficient.

Overrides:
getScanner in class HFile.Reader
Returns:
Scanner on this file.

getLastKey

public byte[] getLastKey()
Overrides:
getLastKey in class HFile.Reader
Returns:
Last key in the file. May be null if file has no entries.

midkey

public byte[] midkey()
              throws IOException
Overrides:
midkey in class HFile.Reader
Returns:
Midkey for this file. We work with block boundaries only so returned midkey is an approximation only.
Throws:
IOException


Copyright © 2009 The Apache Software Foundation