@InterfaceAudience.Private public class HFileReaderV2 extends AbstractHFileReader
HFile
reader for version 2.Modifier and Type | Class and Description |
---|---|
protected static class |
HFileReaderV2.AbstractScannerV2 |
protected static class |
HFileReaderV2.EncodedScannerV2
ScannerV2 that operates on encoded data blocks.
|
protected static class |
HFileReaderV2.ScannerV2
Implementation of
HFileScanner interface. |
AbstractHFileReader.BlockIndexNotLoadedException, AbstractHFileReader.NotSeekedException, AbstractHFileReader.Scanner
Modifier and Type | Field and Description |
---|---|
protected boolean |
decodeMemstoreTS |
private HFileBlock.FSReader |
fsBlockReader
Filesystem-level block reader.
|
(package private) HFileContext |
hfileContext |
private boolean |
includesMemstoreTS |
static int |
KEY_VALUE_LEN_SIZE
The size of a (key length, value length) tuple that prefixes each entry in
a data block.
|
private List<HFileBlock> |
loadOnOpenBlocks
Blocks read from the load-on-open section, excluding data root index, meta
index, and file info.
|
private static org.apache.commons.logging.Log |
LOG |
(package private) static int |
MAX_MINOR_VERSION
Maximum minor version supported by this HFile format
|
(package private) static int |
MIN_MINOR_VERSION
Minimum minor version supported by this HFile format
|
static int |
MINOR_VERSION_NO_CHECKSUM
In HFile V2 minor version that does not support checksums
|
static int |
MINOR_VERSION_WITH_CHECKSUM
Minor versions in HFile V2 starting with this number have hbase checksums
|
(package private) static int |
MINOR_VERSION_WITH_FAKED_KEY
Minor versions starting with this number have faked index key
|
private IdLock |
offsetLock
A "sparse lock" implementation allowing to lock on a particular block
identified by offset.
|
static int |
PBUF_TRAILER_MINOR_VERSION
HFile minor version that introduced pbuf filetrailer
|
avgKeyLen, avgValueLen, cacheConf, comparator, compressAlgo, conf, dataBlockEncoder, dataBlockIndexReader, fileInfo, fileSize, hfs, lastKey, metaBlockIndexReader, name, path, trailer
Constructor and Description |
---|
HFileReaderV2(org.apache.hadoop.fs.Path path,
FixedFileTrailer trailer,
FSDataInputStreamWrapper fsdis,
long size,
CacheConfig cacheConf,
HFileSystem hfs,
org.apache.hadoop.conf.Configuration conf)
Opens a HFile.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
close(boolean evictOnClose)
Close method with optional evictOnClose
|
protected HFileContext |
createHFileContext(FSDataInputStreamWrapper fsdis,
long fileSize,
HFileSystem hfs,
org.apache.hadoop.fs.Path path,
FixedFileTrailer trailer) |
private DataInput |
getBloomFilterMetadata(BlockType blockType) |
private HFileBlock |
getCachedBlock(BlockCacheKey cacheKey,
boolean cacheBlock,
boolean useLock,
boolean isCompaction,
boolean updateCacheMetrics,
BlockType expectedBlockType,
DataBlockEncoding expectedDataBlockEncoding)
Retrieve block from cache.
|
DataInput |
getDeleteBloomFilterMetadata()
Retrieves delete family Bloom filter metadata as appropriate for each
HFile version. |
DataBlockEncoding |
getEffectiveEncodingInCache(boolean isCompaction) |
HFileContext |
getFileContext()
Return the file context of the HFile this reader belongs to
|
DataInput |
getGeneralBloomFilterMetadata()
Returns a buffer with the Bloom filter metadata.
|
byte[] |
getLastKey() |
int |
getMajorVersion() |
ByteBuffer |
getMetaBlock(String metaBlockName,
boolean cacheBlock) |
private static String |
getPathOffsetEndStr(org.apache.hadoop.fs.Path path,
long offset,
long end) |
HFileScanner |
getScanner(boolean cacheBlocks,
boolean pread,
boolean isCompaction)
Create a Scanner on this file.
|
(package private) HFileBlock.FSReader |
getUncachedBlockReader()
For testing
|
boolean |
hasMVCCInfo() |
boolean |
isFileInfoLoaded() |
byte[] |
midkey() |
(package private) boolean |
prefetchComplete()
Returns false if block prefetching was requested for this file and has
not completed, true otherwise
|
HFileBlock |
readBlock(long dataBlockOffset,
long onDiskBlockSize,
boolean cacheBlock,
boolean pread,
boolean isCompaction,
boolean updateCacheMetrics,
BlockType expectedBlockType,
DataBlockEncoding expectedDataBlockEncoding)
Read in a file block.
|
protected boolean |
shouldIncludeMemstoreTS() |
void |
unbufferStream()
To close the stream's socket.
|
private void |
validateBlockType(HFileBlock block,
BlockType expectedBlockType)
Compares the actual type of a block retrieved from cache or disk with its
expected type and throws an exception in case of a mismatch.
|
private void |
validateMinorVersion(org.apache.hadoop.fs.Path path,
int minorVersion)
Validates that the minor version is within acceptable limits.
|
getComparator, getCompressionAlgorithm, getConf, getDataBlockEncoding, getDataBlockIndexReader, getEntries, getFirstKey, getFirstRowKey, getLastRowKey, getName, getPath, getScanner, getTrailer, indexSize, isPrimaryReplicaReader, length, loadFileInfo, setConf, setPrimaryReplicaReader, toString, toStringFirstKey, toStringLastKey
private static final org.apache.commons.logging.Log LOG
public static final int MINOR_VERSION_WITH_CHECKSUM
public static final int MINOR_VERSION_NO_CHECKSUM
public static final int PBUF_TRAILER_MINOR_VERSION
public static final int KEY_VALUE_LEN_SIZE
private boolean includesMemstoreTS
protected boolean decodeMemstoreTS
private HFileBlock.FSReader fsBlockReader
private IdLock offsetLock
private List<HFileBlock> loadOnOpenBlocks
static final int MIN_MINOR_VERSION
static final int MAX_MINOR_VERSION
static final int MINOR_VERSION_WITH_FAKED_KEY
HFileContext hfileContext
public HFileReaderV2(org.apache.hadoop.fs.Path path, FixedFileTrailer trailer, FSDataInputStreamWrapper fsdis, long size, CacheConfig cacheConf, HFileSystem hfs, org.apache.hadoop.conf.Configuration conf) throws IOException
AbstractHFileReader.loadFileInfo()
.path
- Path to HFile.trailer
- File trailer.fsdis
- input stream.size
- Length of the stream.cacheConf
- Cache configuration.hfs
- conf
- IOException
protected boolean shouldIncludeMemstoreTS()
protected HFileContext createHFileContext(FSDataInputStreamWrapper fsdis, long fileSize, HFileSystem hfs, org.apache.hadoop.fs.Path path, FixedFileTrailer trailer) throws IOException
IOException
private static String getPathOffsetEndStr(org.apache.hadoop.fs.Path path, long offset, long end)
public HFileScanner getScanner(boolean cacheBlocks, boolean pread, boolean isCompaction)
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.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).isCompaction
- is scanner being used for a compaction?private HFileBlock getCachedBlock(BlockCacheKey cacheKey, boolean cacheBlock, boolean useLock, boolean isCompaction, boolean updateCacheMetrics, BlockType expectedBlockType, DataBlockEncoding expectedDataBlockEncoding) throws IOException
expectedBlockType
and its encoding vs. expectedDataBlockEncoding
. Unpacks the block as necessary.IOException
public ByteBuffer getMetaBlock(String metaBlockName, boolean cacheBlock) throws IOException
metaBlockName
- cacheBlock
- Add block to cache, if foundIOException
public HFileBlock readBlock(long dataBlockOffset, long onDiskBlockSize, boolean cacheBlock, boolean pread, boolean isCompaction, boolean updateCacheMetrics, BlockType expectedBlockType, DataBlockEncoding expectedDataBlockEncoding) throws IOException
HFile.CachingBlockReader
dataBlockOffset
- offset to read.onDiskBlockSize
- size of the blockisCompaction
- is this block being read as part of a compactionexpectedBlockType
- the block type we are expecting to read with this read operation,
or null to read whatever block type is available and avoid checking (that might reduce
caching efficiency of encoded data blocks)expectedDataBlockEncoding
- the data block encoding the caller is expecting data blocks
to be in, or null to not perform this check and return the block irrespective of the
encoding. This check only applies to data blocks and can be set to null when the caller is
expecting to read a non-data block and has set expectedBlockType accordingly.IOException
public boolean hasMVCCInfo()
private void validateBlockType(HFileBlock block, BlockType expectedBlockType) throws IOException
BlockType.DATA
is considered to match the actual
block type [@link BlockType.ENCODED_DATA
as well.block
- a block retrieved from cache or diskexpectedBlockType
- the expected block type, or null to skip the
checkIOException
public byte[] getLastKey()
public byte[] midkey() throws IOException
IOException
public void close() throws IOException
IOException
public void close(boolean evictOnClose) throws IOException
HFile.Reader
IOException
public DataBlockEncoding getEffectiveEncodingInCache(boolean isCompaction)
HFileBlock.FSReader getUncachedBlockReader()
getUncachedBlockReader
in class AbstractHFileReader
public DataInput getGeneralBloomFilterMetadata() throws IOException
IOException
public DataInput getDeleteBloomFilterMetadata() throws IOException
HFile.Reader
HFile
version.
Knows nothing about how that metadata is structured.IOException
private DataInput getBloomFilterMetadata(BlockType blockType) throws IOException
IOException
public boolean isFileInfoLoaded()
isFileInfoLoaded
in class AbstractHFileReader
private void validateMinorVersion(org.apache.hadoop.fs.Path path, int minorVersion)
public int getMajorVersion()
getMajorVersion
in class AbstractHFileReader
public HFileContext getFileContext()
HFile.Reader
boolean prefetchComplete()
public void unbufferStream()
HFile.Reader
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.