Package org.apache.hadoop.hbase.io.hfile
Class HFileReaderImpl.EncodedScanner
java.lang.Object
org.apache.hadoop.hbase.io.hfile.HFileReaderImpl.HFileScannerImpl
org.apache.hadoop.hbase.io.hfile.HFileReaderImpl.EncodedScanner
- All Implemented Interfaces:
Closeable
,AutoCloseable
,HFileScanner
,Shipper
- Enclosing class:
- HFileReaderImpl
Scanner that operates on encoded data blocks.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final DataBlockEncoder
private final HFileBlockDecodingContext
private final DataBlockEncoder.EncodedSeeker
Fields inherited from class org.apache.hadoop.hbase.io.hfile.HFileReaderImpl.HFileScannerImpl
cacheBlocks, curBlock, isCompaction, nextIndexedKey, pair, pread, prevBlocks, reader
-
Constructor Summary
ConstructorDescriptionEncodedScanner
(HFile.Reader reader, boolean cacheBlocks, boolean pread, boolean isCompaction, HFileContext meta, org.apache.hadoop.conf.Configuration conf) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
int
compareKey
(CellComparator comparator, Cell key) getCell()
Returns Instance ofCell
.private ByteBuff
getEncodedBuffer
(HFileBlock newBlock) protected Cell
getFirstKeyCellInBlock
(HFileBlock curBlock) getKey()
Gets the current key in the form of a cell.Convenience method to get a copy of the key as a string - interpreting the bytes as UTF8.getValue()
Gets a buffer view to the current value.Convenience method to get a copy of the value as a string - interpreting the bytes as UTF8.boolean
isSeeked()
protected int
loadBlockAndSeekToKey
(HFileBlock seekToBlock, Cell nextIndexedKey, boolean rewind, Cell key, boolean seekBefore) boolean
next()
Go to the next key/value in the block section.protected boolean
void
protected void
updateCurrentBlock
(HFileBlock newBlock) Updates the current block to be the givenHFileBlock
.Methods inherited from class org.apache.hadoop.hbase.io.hfile.HFileReaderImpl.HFileScannerImpl
assertSeeked, blockSeek, checkKeyLen, checkKeyValueLen, checkLen, close, getEffectiveDataBlockEncoding, getNextIndexedKey, getReader, readAndUpdateNewBlock, readKeyValueLen, readMvccVersion, readNextDataBlock, recordBlockSize, releaseIfNotCurBlock, reseekTo, reset, seekBefore, seekTo, seekTo, seekTo, shipped, toString, updateCurrBlockRef
-
Field Details
-
decodingCtx
-
seeker
-
dataBlockEncoder
-
-
Constructor Details
-
EncodedScanner
public EncodedScanner(HFile.Reader reader, boolean cacheBlocks, boolean pread, boolean isCompaction, HFileContext meta, org.apache.hadoop.conf.Configuration conf)
-
-
Method Details
-
isSeeked
- Specified by:
isSeeked
in interfaceHFileScanner
- Overrides:
isSeeked
in classHFileReaderImpl.HFileScannerImpl
- Returns:
- True is scanner has had one of the seek calls invoked; i.e.
HFileScanner.seekBefore(Cell)
orHFileScanner.seekTo()
orHFileScanner.seekTo(Cell)
. Otherwise returns false.
-
setNonSeekedState
- Overrides:
setNonSeekedState
in classHFileReaderImpl.HFileScannerImpl
-
updateCurrentBlock
Updates the current block to be the givenHFileBlock
. Seeks to the the first key/value pair.- Overrides:
updateCurrentBlock
in classHFileReaderImpl.HFileScannerImpl
- Parameters:
newBlock
- the block to make current, and read byHFileReaderImpl.readBlock(long, long, boolean, boolean, boolean, boolean, org.apache.hadoop.hbase.io.hfile.BlockType, org.apache.hadoop.hbase.io.encoding.DataBlockEncoding)
, it's a totally new block with new allocatedByteBuff
, so if no further reference to this block, we should release it carefully.- Throws:
CorruptHFileException
-
getEncodedBuffer
-
processFirstDataBlock
- Overrides:
processFirstDataBlock
in classHFileReaderImpl.HFileScannerImpl
- Throws:
IOException
-
next
Description copied from class:HFileReaderImpl.HFileScannerImpl
Go to the next key/value in the block section. Loads the next block if necessary. If successful,HFileReaderImpl.HFileScannerImpl.getKey()
andHFileReaderImpl.HFileScannerImpl.getValue()
can be called.- Specified by:
next
in interfaceHFileScanner
- Overrides:
next
in classHFileReaderImpl.HFileScannerImpl
- Returns:
- true if successfully navigated to the next key/value
- Throws:
IOException
-
getKey
Description copied from interface:HFileScanner
Gets the current key in the form of a cell. You must callHFileScanner.seekTo(Cell)
before this method.- Specified by:
getKey
in interfaceHFileScanner
- Overrides:
getKey
in classHFileReaderImpl.HFileScannerImpl
- Returns:
- gets the current key as a Cell.
-
getValue
Description copied from interface:HFileScanner
Gets a buffer view to the current value. You must callHFileScanner.seekTo(Cell)
before this method.- Specified by:
getValue
in interfaceHFileScanner
- Overrides:
getValue
in classHFileReaderImpl.HFileScannerImpl
- Returns:
- byte buffer for the value. The limit is set to the value size, and the position is 0, the start of the buffer view.
-
getCell
Description copied from interface:HFileScanner
Returns Instance ofCell
.- Specified by:
getCell
in interfaceHFileScanner
- Overrides:
getCell
in classHFileReaderImpl.HFileScannerImpl
-
getKeyString
Description copied from interface:HFileScanner
Convenience method to get a copy of the key as a string - interpreting the bytes as UTF8. You must callHFileScanner.seekTo(Cell)
before this method.- Specified by:
getKeyString
in interfaceHFileScanner
- Overrides:
getKeyString
in classHFileReaderImpl.HFileScannerImpl
- Returns:
- key as a string
-
getValueString
Description copied from interface:HFileScanner
Convenience method to get a copy of the value as a string - interpreting the bytes as UTF8. You must callHFileScanner.seekTo(Cell)
before this method.- Specified by:
getValueString
in interfaceHFileScanner
- Overrides:
getValueString
in classHFileReaderImpl.HFileScannerImpl
- Returns:
- value as a string
-
assertValidSeek
-
getFirstKeyCellInBlock
- Overrides:
getFirstKeyCellInBlock
in classHFileReaderImpl.HFileScannerImpl
-
loadBlockAndSeekToKey
protected int loadBlockAndSeekToKey(HFileBlock seekToBlock, Cell nextIndexedKey, boolean rewind, Cell key, boolean seekBefore) throws IOException - Overrides:
loadBlockAndSeekToKey
in classHFileReaderImpl.HFileScannerImpl
- Throws:
IOException
-
compareKey
- Overrides:
compareKey
in classHFileReaderImpl.HFileScannerImpl
-