org.apache.hadoop.hbase.io
Class HalfHFileReader
java.lang.Object
org.apache.hadoop.hbase.io.hfile.HFile.Reader
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.
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 |
splitkey
protected final byte[] splitkey
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
isTop
protected boolean isTop()
getScanner
public HFileScanner getScanner(boolean cacheBlocks,
boolean pread)
- 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
- Parameters:
cacheBlocks
- True if we should cache blocks read in by this scanner.pread
- Use positional read rather than seek+read if true (pread is
better for random reads, seek+read is better scanning).
- 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 © 2010 The Apache Software Foundation