Class SegmentScanner
java.lang.Object
org.apache.hadoop.hbase.regionserver.SegmentScanner
- All Implemented Interfaces:
Closeable
,AutoCloseable
,KeyValueScanner
,Shipper
A scanner of a single memstore segment.
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected Cell
private Cell
private long
protected final Segment
private boolean
private Cell
Fields inherited from interface org.apache.hadoop.hbase.regionserver.KeyValueScanner
NO_NEXT_INDEXED_KEY
-
Constructor Summary
ModifierConstructorDescriptionprotected
SegmentScanner
(Segment segment, long readPoint) Scanners are ordered from 0 (oldest) to newest in increasing order. -
Method Summary
Modifier and TypeMethodDescriptionboolean
backwardSeek
(Cell key) Seek the scanner at or before the row of specified Cell, it firstly tries to seek the scanner at or after the specified Cell, return if peek KeyValue of scanner has the same row with specified Cell, otherwise seek the scanner at the first Cell of the row which is the previous row of specified KeyValuevoid
close()
Close the KeyValue scanner.void
This function should be never called on scanners that always do real seek operations (i.e.org.apache.hadoop.fs.Path
private Cell
getHighest
(Cell first, Cell second) Private internal method that returns the higher of the two key values, or null if they are both nullgetIterator
(Cell cell) private Segment
Private Methodsboolean
Returns true if this is a file scanner.next()
Return the next Cell in this scanner, iterating the scannerpeek()
Look at the next Cell in this scanner, but do not iterate the scannerboolean
This scanner is working solely on the in-memory MemStore and doesn't work on store files, MutableCellSetSegmentScanner always does the seek, therefore always returning true.void
recordBlockSize
(IntConsumer blockSizeConsumer) Record the size of the current block in bytes, passing as an argument to the blockSizeConsumer.boolean
requestSeek
(Cell c, boolean forward, boolean useBloom) Similar toKeyValueScanner.seek(org.apache.hadoop.hbase.Cell)
(orKeyValueScanner.reseek(org.apache.hadoop.hbase.Cell)
if forward is true) but only does a seek operation after checking that it is really necessary for the row/column combination specified by the kv parameter.boolean
Reseek the scanner at or after the specified KeyValue.boolean
Seek the scanner at or after the specified Cell.boolean
Seek the scanner at the first KeyValue of last rowboolean
seekToPreviousRow
(Cell cell) Seek the scanner at the first Cell of the row which is the previous row of specified keyvoid
shipped()
Called after a batch of rows scanned (RPC) and set to be returned to client.boolean
shouldUseScanner
(Scan scan, HStore store, long oldestUnexpiredTS) This functionality should be resolved in the higher level which is MemStoreScanner, currently returns true as default.toString()
protected void
Private internal method for iterating over the segment, skipping the cells with irrelevant MVCCMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.regionserver.KeyValueScanner
getScannerOrder
-
Field Details
-
segment
-
readPoint
-
iter
-
current
-
stopSkippingKVsIfNextRow
-
stopSkippingKVsRow
-
last
-
closed
-
-
Constructor Details
-
SegmentScanner
Scanners are ordered from 0 (oldest) to newest in increasing order.
-
-
Method Details
-
peek
Look at the next Cell in this scanner, but do not iterate the scanner- Specified by:
peek
in interfaceKeyValueScanner
- Returns:
- the currently observed Cell
-
next
Return the next Cell in this scanner, iterating the scanner- Specified by:
next
in interfaceKeyValueScanner
- Returns:
- the next Cell or null if end of scanner
- Throws:
IOException
-
seek
Seek the scanner at or after the specified Cell.- Specified by:
seek
in interfaceKeyValueScanner
- Parameters:
cell
- seek value- Returns:
- true if scanner has values left, false if end of scanner
- Throws:
IOException
-
getIterator
-
reseek
Reseek the scanner at or after the specified KeyValue. This method is guaranteed to seek at or after the required key only if the key comes after the current position of the scanner. Should not be used to seek to a key which may come before the current position.- Specified by:
reseek
in interfaceKeyValueScanner
- Parameters:
cell
- seek value (should be non-null)- Returns:
- true if scanner has values left, false if end of scanner
- Throws:
IOException
-
backwardSeek
Seek the scanner at or before the row of specified Cell, it firstly tries to seek the scanner at or after the specified Cell, return if peek KeyValue of scanner has the same row with specified Cell, otherwise seek the scanner at the first Cell of the row which is the previous row of specified KeyValue- Specified by:
backwardSeek
in interfaceKeyValueScanner
- Parameters:
key
- seek Cell- Returns:
- true if the scanner is at the valid KeyValue, false if such Cell does not exist
- Throws:
IOException
-
seekToPreviousRow
Seek the scanner at the first Cell of the row which is the previous row of specified key- Specified by:
seekToPreviousRow
in interfaceKeyValueScanner
- Parameters:
cell
- seek value- Returns:
- true if the scanner at the first valid Cell of previous row, false if not existing such Cell
- Throws:
IOException
-
seekToLastRow
Seek the scanner at the first KeyValue of last row- Specified by:
seekToLastRow
in interfaceKeyValueScanner
- Returns:
- true if scanner has values left, false if the underlying data is empty
- Throws:
IOException
-
close
Close the KeyValue scanner.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceKeyValueScanner
-
shouldUseScanner
This functionality should be resolved in the higher level which is MemStoreScanner, currently returns true as default. Doesn't throw IllegalStateException in order not to change the signature of the overridden method- Specified by:
shouldUseScanner
in interfaceKeyValueScanner
- Parameters:
scan
- the scan that we are selecting scanners forstore
- the store we are performing the scan on.oldestUnexpiredTS
- the oldest timestamp we are interested in for this query, based on TTL- Returns:
- true if the scanner should be included in the query
-
requestSeek
Description copied from interface:KeyValueScanner
Similar toKeyValueScanner.seek(org.apache.hadoop.hbase.Cell)
(orKeyValueScanner.reseek(org.apache.hadoop.hbase.Cell)
if forward is true) but only does a seek operation after checking that it is really necessary for the row/column combination specified by the kv parameter. This function was added to avoid unnecessary disk seeks by checking row-column Bloom filters before a seek on multi-column get/scan queries, and to optimize by looking up more recent files first.- Specified by:
requestSeek
in interfaceKeyValueScanner
forward
- do a forward-only "reseek" instead of a random-access seekuseBloom
- whether to enable multi-column Bloom filter optimization- Throws:
IOException
-
realSeekDone
This scanner is working solely on the in-memory MemStore and doesn't work on store files, MutableCellSetSegmentScanner always does the seek, therefore always returning true.- Specified by:
realSeekDone
in interfaceKeyValueScanner
-
enforceSeek
This function should be never called on scanners that always do real seek operations (i.e. most of the scanners and also this one). The easiest way to achieve this is to callrealSeekDone()
first.- Specified by:
enforceSeek
in interfaceKeyValueScanner
- Throws:
IOException
-
isFileScanner
Returns true if this is a file scanner. Otherwise a memory scanner is assumed.- Specified by:
isFileScanner
in interfaceKeyValueScanner
-
recordBlockSize
Description copied from interface:KeyValueScanner
Record the size of the current block in bytes, passing as an argument to the blockSizeConsumer. Implementations should ensure that blockSizeConsumer is only called once per block.- Specified by:
recordBlockSize
in interfaceKeyValueScanner
- Parameters:
blockSizeConsumer
- to be called with block size in bytes, once per block.
-
getFilePath
- Specified by:
getFilePath
in interfaceKeyValueScanner
- Returns:
- the file path if this is a file scanner, otherwise null.
- See Also:
-
getNextIndexedKey
- Specified by:
getNextIndexedKey
in interfaceKeyValueScanner
- Returns:
- the next key in the index (the key to seek to the next block) if known, or null otherwise Not relevant for in-memory scanner
-
shipped
Called after a batch of rows scanned (RPC) and set to be returned to client. Any in between cleanup can be done here. Nothing to be done for MutableCellSetSegmentScanner.- Specified by:
shipped
in interfaceShipper
- Throws:
IOException
-
toString
-
getSegment
Private Methods -
updateCurrent
Private internal method for iterating over the segment, skipping the cells with irrelevant MVCC -
getHighest
Private internal method that returns the higher of the two key values, or null if they are both null
-