org.apache.hadoop.hbase.io.hfile
Class HFile.Reader
java.lang.Object
org.apache.hadoop.hbase.io.hfile.HFile.Reader
- All Implemented Interfaces:
- Closeable
- Enclosing class:
- HFile
public static class HFile.Reader
- extends Object
- implements Closeable
HFile Reader.
Constructor Summary |
HFile.Reader(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path,
BlockCache cache,
boolean inMemory)
Opens a HFile. |
HFile.Reader(org.apache.hadoop.fs.FSDataInputStream fsdis,
long size,
BlockCache cache,
boolean inMemory)
Opens a HFile. |
cacheHits
public int cacheHits
blockLoads
public int blockLoads
metaLoads
public int metaLoads
name
protected String name
HFile.Reader
public HFile.Reader(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path,
BlockCache cache,
boolean inMemory)
throws IOException
- Opens a HFile. You must load the file info before you can
use it by calling
loadFileInfo()
.
- Parameters:
fs
- filesystem to load frompath
- path within said filesystemcache
- block cache. Pass null if none.
- Throws:
IOException
HFile.Reader
public HFile.Reader(org.apache.hadoop.fs.FSDataInputStream fsdis,
long size,
BlockCache cache,
boolean inMemory)
- Opens a HFile. You must load the index before you can
use it by calling
loadFileInfo()
.
- Parameters:
fsdis
- input stream. Caller is responsible for closing the passed
stream.size
- Length of the stream.cache
- block cache. Pass null if none.
- Throws:
IOException
toString
public String toString()
- Overrides:
toString
in class Object
toStringFirstKey
protected String toStringFirstKey()
toStringLastKey
protected String toStringLastKey()
length
public long length()
inMemory
public boolean inMemory()
loadFileInfo
public Map<byte[],byte[]> loadFileInfo()
throws IOException
- Read in the index and file info.
- Returns:
- A map of fileinfo data.
See
HFile.Writer.appendFileInfo(byte[], byte[])
.
- Throws:
IOException
getScanner
public HFileScanner getScanner(boolean cacheBlocks,
boolean pread)
- 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.
- Parameters:
pread
- Use positional read rather than seek+read if true (pread is
better for random reads, seek+read is better scanning).cacheBlocks
- True if we should cache blocks read in by this scanner.
- Returns:
- Scanner on this file.
blockContainingKey
protected int blockContainingKey(byte[] key,
int offset,
int length)
- Parameters:
key
- Key to search.
- Returns:
- Block number of the block containing the key or -1 if not in this
file.
getMetaBlock
public ByteBuffer getMetaBlock(String metaBlockName,
boolean cacheBlock)
throws IOException
- Parameters:
metaBlockName
- cacheBlock
- Add block to cache, if found
- Returns:
- Block wrapped in a ByteBuffer
- Throws:
IOException
getFirstKey
public byte[] getFirstKey()
- Returns:
- First key in the file. May be null if file has no entries.
Note that this is not the first rowkey, but rather the byte form of
the first KeyValue.
getFirstRowKey
public byte[] getFirstRowKey()
- Returns:
- the first row key, or null if the file is empty.
TODO move this to StoreFile after Ryan's patch goes in
to eliminate KeyValue here
getEntries
public int getEntries()
- Returns:
- number of KV entries in this HFile
getLastKey
public byte[] getLastKey()
- Returns:
- Last key in the file. May be null if file has no entries.
Note that this is not the last rowkey, but rather the byte form of
the last KeyValue.
getLastRowKey
public byte[] getLastRowKey()
- Returns:
- the last row key, or null if the file is empty.
TODO move this to StoreFile after Ryan's patch goes in
to eliminate KeyValue here
getFilterEntries
public int getFilterEntries()
- Returns:
- number of K entries in this HFile's filter. Returns KV count if no filter.
getComparator
public org.apache.hadoop.io.RawComparator<byte[]> getComparator()
- Returns:
- Comparator.
indexSize
public long indexSize()
- Returns:
- index size
midkey
public byte[] midkey()
throws IOException
- Returns:
- Midkey for this file. We work with block boundaries only so
returned midkey is an approximation only.
- Throws:
IOException
close
public void close()
throws IOException
- Specified by:
close
in interface Closeable
- Throws:
IOException
getName
public String getName()
getTrailerInfo
public String getTrailerInfo()
Copyright © 2011 The Apache Software Foundation. All Rights Reserved.