Class StoreFileReader
java.lang.Object
org.apache.hadoop.hbase.regionserver.StoreFileReader
- Direct Known Subclasses:
HalfStoreFileReader
Reader for a StoreFile.
-
Field Summary
Modifier and TypeFieldDescriptionprivate BloomFilterMetrics
protected BloomType
private boolean
protected org.apache.hadoop.conf.Configuration
private final ReaderContext
protected BloomFilter
private long
protected BloomFilter
private byte[]
private KeyValue.KeyOnlyKeyValue
private static final org.slf4j.Logger
private int
private final HFile.Reader
protected long
private boolean
private final StoreFileInfo
AllStoreFileReader
for the same StoreFile will share theStoreFileInfo.refCount
.protected TimeRange
-
Constructor Summary
ModifierConstructorDescription(package private)
ONLY USE DEFAULT CONSTRUCTOR FOR UNIT TESTSprivate
StoreFileReader
(HFile.Reader reader, StoreFileInfo storeFileInfo, ReaderContext context, org.apache.hadoop.conf.Configuration conf) StoreFileReader
(ReaderContext context, HFileInfo fileInfo, CacheConfig cacheConf, StoreFileInfo storeFileInfo, org.apache.hadoop.conf.Configuration conf) -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
checkGeneralBloomFilter
(byte[] key, Cell kvKey, BloomFilter bloomFilter) void
close
(boolean evictOnClose) (package private) void
copyFields
(StoreFileReader storeFileReader) (package private) void
long
long
long
The number of Bloom filter entries in this store file, or an estimate thereof, if the Bloom filter is not loaded.(package private) BloomFilter
int
int
Optional<byte[]>
long
int
(package private) int
Return the ref count associated with the reader whenever a scanner associated with the reader is opened.getScanner
(boolean cacheBlocks, boolean pread) Deprecated.since 2.0.0 and will be removed in 3.0.0.getScanner
(boolean cacheBlocks, boolean pread, boolean isCompaction) Deprecated.since 2.0.0 and will be removed in 3.0.0.long
getStoreFileScanner
(boolean cacheBlocks, boolean pread, boolean isCompaction, long readPt, long scannerOrder, boolean canOptimizeForNonNullColumn) Get a scanner to scan over this StoreFile.long
long
(package private) long
(package private) void
Indicate that the scanner has started reading with this reader.long
boolean
boolean
(package private) boolean
long
length()
(package private) void
void
loadBloomfilter
(BlockType blockType, BloomFilterMetrics metrics) Map<byte[],
byte[]> midKey()
(package private) boolean
passesBloomFilter
(Scan scan, SortedSet<byte[]> columns) Checks whether the given scan passes the Bloom filter (if present).boolean
passesDeleteFamilyBloomFilter
(byte[] row, int rowOffset, int rowLen) private boolean
passesGeneralRowBloomFilter
(byte[] row, int rowOffset, int rowLen) A method for checking Bloom filters.boolean
A method for checking Bloom filters.private boolean
A method for checking Bloom filters.boolean
passesKeyRangeFilter
(Scan scan) Checks whether the given scan rowkey range overlaps with the current storefile's(package private) boolean
passesTimerangeFilter
(TimeRange tr, long oldestUnexpiredTS) Check if this storeFile may contain keys within the TimeRange that have not expired (i.e.(package private) void
Indicate that the scanner has finished reading with this reader.(package private) void
setBloomFilterFaulty
(BlockType blockType) void
setBulkLoaded
(boolean bulkLoadResult) private void
private void
void
setSequenceID
(long sequenceID) (package private) void
setSkipResetSeqId
(boolean skipResetSeqId)
-
Field Details
-
LOG
-
generalBloomFilter
-
deleteFamilyBloomFilter
-
bloomFilterMetrics
-
bloomFilterType
-
reader
-
sequenceID
-
timeRange
-
lastBloomKey
-
deleteFamilyCnt
-
bulkLoadResult
-
lastBloomKeyOnlyKV
-
skipResetSeqId
-
prefixLength
-
conf
-
storeFileInfo
AllStoreFileReader
for the same StoreFile will share theStoreFileInfo.refCount
. Counter that is incremented every time a scanner is created on the store file. It is decremented when the scan on the store file is done. -
context
-
-
Constructor Details
-
StoreFileReader
private StoreFileReader(HFile.Reader reader, StoreFileInfo storeFileInfo, ReaderContext context, org.apache.hadoop.conf.Configuration conf) -
StoreFileReader
public StoreFileReader(ReaderContext context, HFileInfo fileInfo, CacheConfig cacheConf, StoreFileInfo storeFileInfo, org.apache.hadoop.conf.Configuration conf) throws IOException - Throws:
IOException
-
StoreFileReader
@Private StoreFileReader()ONLY USE DEFAULT CONSTRUCTOR FOR UNIT TESTS
-
-
Method Details
-
copyFields
- Throws:
IOException
-
isPrimaryReplicaReader
-
getComparator
-
getStoreFileScanner
public StoreFileScanner getStoreFileScanner(boolean cacheBlocks, boolean pread, boolean isCompaction, long readPt, long scannerOrder, boolean canOptimizeForNonNullColumn) Get a scanner to scan over this StoreFile.- Parameters:
cacheBlocks
- should this scanner cache blocks?pread
- use pread (for highly concurrent small readers)isCompaction
- is scanner being used for compaction?scannerOrder
- Order of this scanner relative to other scanners. SeeKeyValueScanner.getScannerOrder()
.canOptimizeForNonNullColumn
-true
if we can make sure there is no null column, otherwisefalse
. This is a hint for optimization.- Returns:
- a scanner
-
getRefCount
int getRefCount()Return the ref count associated with the reader whenever a scanner associated with the reader is opened. -
incrementRefCount
void incrementRefCount()Indicate that the scanner has started reading with this reader. We need to increment the ref count so reader is not close until some object is holding the lock -
readCompleted
void readCompleted()Indicate that the scanner has finished reading with this reader. We need to decrement the ref count, and also, if this is not the common pread reader, we should close it. -
getScanner
Deprecated.since 2.0.0 and will be removed in 3.0.0. Do not write further code which depends on this call. Instead use getStoreFileScanner() which uses the StoreFileScanner class/interface which is the preferred way to scan a store with higher level concepts.- Parameters:
cacheBlocks
- should we cache the blocks?pread
- use pread (for concurrent small readers)- Returns:
- the underlying HFileScanner
- See Also:
-
getScanner
@Deprecated public HFileScanner getScanner(boolean cacheBlocks, boolean pread, boolean isCompaction) Deprecated.since 2.0.0 and will be removed in 3.0.0. Do not write further code which depends on this call. Instead use getStoreFileScanner() which uses the StoreFileScanner class/interface which is the preferred way to scan a store with higher level concepts. should we cache the blocks? use pread (for concurrent small readers) is scanner being used for compaction?- Returns:
- the underlying HFileScanner
- See Also:
-
close
- Throws:
IOException
-
passesTimerangeFilter
Check if this storeFile may contain keys within the TimeRange that have not expired (i.e. not older than oldestUnexpiredTS).- Parameters:
tr
- the timeRange to restrictoldestUnexpiredTS
- the oldest timestamp that is not expired, as determined by the column family's TTL- Returns:
- false if queried keys definitely don't exist in this StoreFile
-
passesBloomFilter
Checks whether the given scan passes the Bloom filter (if present). Only checks Bloom filters for single-row or single-row-column scans. Bloom filter checking for multi-gets is implemented as part of the store scanner system (seeStoreFileScanner.seek(Cell)
and uses the lower-level APIpassesGeneralRowBloomFilter(byte[], int, int)
andpassesGeneralRowColBloomFilter(Cell)
.- Parameters:
scan
- the scan specification. Used to determine the row, and to check whether this is a single-row ("get") scan.columns
- the set of columns. Only used for row-column Bloom filters.- Returns:
- true if the scan with the given column set passes the Bloom filter, or if the Bloom filter is not applicable for the scan. False if the Bloom filter is applicable and the scan fails it.
-
passesDeleteFamilyBloomFilter
-
passesGeneralRowBloomFilter
A method for checking Bloom filters. Called directly from StoreFileScanner in case of a multi-column query.- Returns:
- True if passes
-
passesGeneralRowColBloomFilter
A method for checking Bloom filters. Called directly from StoreFileScanner in case of a multi-column query. the cell to check if present in BloomFilter- Returns:
- True if passes
-
passesGeneralRowPrefixBloomFilter
A method for checking Bloom filters. Called directly from StoreFileScanner in case of a multi-column query.- Returns:
- True if passes
-
checkGeneralBloomFilter
-
passesKeyRangeFilter
Checks whether the given scan rowkey range overlaps with the current storefile's- Parameters:
scan
- the scan specification. Used to determine the rowkey range.- Returns:
- true if there is overlap, false otherwise
-
loadFileInfo
- Throws:
IOException
-
loadBloomfilter
void loadBloomfilter() -
loadBloomfilter
-
setBloomFilterFaulty
-
getFilterEntries
The number of Bloom filter entries in this store file, or an estimate thereof, if the Bloom filter is not loaded. This always returns an upper bound of the number of Bloom filter entries.- Returns:
- an estimate of the number of Bloom filter entries in this file
-
setGeneralBloomFilterFaulty
-
setDeleteFamilyBloomFilterFaulty
-
getLastKey
-
getLastRowKey
-
midKey
- Throws:
IOException
-
length
-
getTotalUncompressedBytes
-
getEntries
-
getDeleteFamilyCnt
-
getFirstKey
-
indexSize
-
getBloomFilterType
-
getSequenceID
-
setSequenceID
-
setBulkLoaded
-
isBulkLoaded
-
getGeneralBloomFilter
-
getUncompressedDataIndexSize
long getUncompressedDataIndexSize() -
getTotalBloomSize
-
getHFileVersion
-
getHFileMinorVersion
-
getHFileReader
-
disableBloomFilterForTesting
void disableBloomFilterForTesting() -
getMaxTimestamp
-
isSkipResetSeqId
boolean isSkipResetSeqId() -
setSkipResetSeqId
-
getPrefixLength
-
getReaderContext
-