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
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Cellprivate Cellprivate longprotected final Segmentprivate booleanprivate CellFields inherited from interface org.apache.hadoop.hbase.regionserver.KeyValueScanner
NO_NEXT_INDEXED_KEY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSegmentScanner(Segment segment, long readPoint) Scanners are ordered from 0 (oldest) to newest in increasing order. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbackwardSeek(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 KeyValuevoidclose()Close the KeyValue scanner.voidThis function should be never called on scanners that always do real seek operations (i.e.org.apache.hadoop.fs.Pathprivate CellgetHighest(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 SegmentPrivate MethodsbooleanReturns 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 scannerbooleanThis 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.voidrecordBlockSize(IntConsumer blockSizeConsumer) Record the size of the current block in bytes, passing as an argument to the blockSizeConsumer.booleanrequestSeek(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.booleanReseek the scanner at or after the specified KeyValue.booleanSeek the scanner at or after the specified Cell.booleanSeek the scanner at the first KeyValue of last rowbooleanseekToPreviousRow(Cell cell) Seek the scanner at the first Cell of the row which is the previous row of specified keyvoidshipped()Called after a batch of rows scanned (RPC) and set to be returned to client.booleanshouldUseScanner(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 voidPrivate 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, waitMethods 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:
peekin interfaceKeyValueScanner- Returns:
- the currently observed Cell
-
next
Return the next Cell in this scanner, iterating the scanner- Specified by:
nextin 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:
seekin 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:
reseekin 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:
backwardSeekin 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:
seekToPreviousRowin 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:
seekToLastRowin interfaceKeyValueScanner- Returns:
- true if scanner has values left, false if the underlying data is empty
- Throws:
IOException
-
close
Close the KeyValue scanner.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein 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:
shouldUseScannerin 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:KeyValueScannerSimilar 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:
requestSeekin interfaceKeyValueScannerforward- 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:
realSeekDonein 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:
enforceSeekin interfaceKeyValueScanner- Throws:
IOException
-
isFileScanner
Returns true if this is a file scanner. Otherwise a memory scanner is assumed.- Specified by:
isFileScannerin interfaceKeyValueScanner
-
recordBlockSize
Description copied from interface:KeyValueScannerRecord 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:
recordBlockSizein interfaceKeyValueScanner- Parameters:
blockSizeConsumer- to be called with block size in bytes, once per block.
-
getFilePath
- Specified by:
getFilePathin interfaceKeyValueScanner- Returns:
- the file path if this is a file scanner, otherwise null.
- See Also:
-
getNextIndexedKey
- Specified by:
getNextIndexedKeyin 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:
shippedin 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
-