protected static class HFileReaderImpl.HFileScannerImpl extends Object implements HFileScanner
Modifier and Type | Field and Description |
---|---|
private ByteBuff |
blockBuffer |
protected AtomicInteger |
blockFetches |
private ByteBufferKeyOnlyKeyValue |
bufBackedKeyOnlyKv |
protected boolean |
cacheBlocks |
protected HFileBlock |
curBlock |
private int |
currKeyLen |
private long |
currMemstoreTS |
private int |
currMemstoreTSLen |
private int |
currTagsLen |
private int |
currValueLen |
protected boolean |
isCompaction |
protected Cell |
nextIndexedKey
The next indexed key is to keep track of the indexed key of the next data block.
|
(package private) ObjectIntPair<ByteBuffer> |
pair |
protected boolean |
pread |
protected ArrayList<HFileBlock> |
prevBlocks |
protected HFile.Reader |
reader |
Constructor and Description |
---|
HFileScannerImpl(HFile.Reader reader,
boolean cacheBlocks,
boolean pread,
boolean isCompaction) |
Modifier and Type | Method and Description |
---|---|
private boolean |
_next() |
private void |
_readMvccVersion(int offsetFromPos)
Actually do the mvcc read.
|
protected void |
assertSeeked() |
protected int |
blockSeek(Cell key,
boolean seekBefore)
Within a loaded block, seek looking for the last key that is smaller than
(or equal to?) the key we are interested in.
|
protected boolean |
checkKeyLen(int v) |
protected void |
checkKeyValueLen()
Check key and value lengths are wholesome.
|
protected boolean |
checkLen(int v) |
private void |
checkTagsLen() |
void |
close()
Close this HFile scanner and do necessary cleanup.
|
int |
compareKey(CellComparator comparator,
Cell key) |
Cell |
getCell() |
private int |
getCurCellSerializedSize() |
DataBlockEncoding |
getEffectiveDataBlockEncoding() |
protected Cell |
getFirstKeyCellInBlock(HFileBlock curBlock) |
Cell |
getKey()
Gets the current key in the form of a cell.
|
String |
getKeyString()
Convenience method to get a copy of the key as a string - interpreting the
bytes as UTF8.
|
private int |
getKVBufSize() |
Cell |
getNextIndexedKey() |
HFile.Reader |
getReader() |
ByteBuffer |
getValue()
Gets a buffer view to the current value.
|
String |
getValueString()
Convenience method to get a copy of the value as a string - interpreting
the bytes as UTF8.
|
private boolean |
isNextBlock() |
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.
|
private boolean |
positionForNextBlock()
Set our selves up for the next 'next' invocation, set up next block.
|
private void |
positionThisBlockBuffer()
Set the position on current backing blockBuffer.
|
protected boolean |
processFirstDataBlock() |
protected void |
readAndUpdateNewBlock(long firstDataBlockOffset) |
protected void |
readKeyValueLen() |
protected void |
readMvccVersion(int offsetFromPos)
Read mvcc.
|
protected HFileBlock |
readNextDataBlock()
Scans blocks in the "scanned" section of the
HFile until the next
data block is found. |
protected void |
releaseIfNotCurBlock(HFileBlock block)
The curBlock will be released by shipping or close method, so only need to consider releasing
the block, which was read from HFile before and not referenced by curBlock.
|
int |
reseekTo(Cell key)
Reseek to or just before the passed
cell . |
(package private) void |
reset() |
private void |
returnBlocks(boolean returnAll) |
private void |
returnBlockToCache(HFileBlock block) |
boolean |
seekBefore(Cell key)
Consider the cell stream of all the cells in the file,
c[0] .. |
boolean |
seekTo()
Positions this scanner at the start of the file.
|
int |
seekTo(Cell key)
SeekTo or just before the passed
cell . |
int |
seekTo(Cell key,
boolean rewind)
An internal API function.
|
protected void |
setNonSeekedState() |
void |
shipped()
Called after a batch of rows scanned and set to be returned to client.
|
String |
toString() |
(package private) void |
updateCurrBlockRef(HFileBlock block) |
protected void |
updateCurrentBlock(HFileBlock newBlock)
Updates the current block to be the given
HFileBlock . |
private ByteBuff blockBuffer
protected final boolean cacheBlocks
protected final boolean pread
protected final boolean isCompaction
private int currKeyLen
private int currValueLen
private int currMemstoreTSLen
private long currMemstoreTS
protected AtomicInteger blockFetches
protected final HFile.Reader reader
private int currTagsLen
private ByteBufferKeyOnlyKeyValue bufBackedKeyOnlyKv
final ObjectIntPair<ByteBuffer> pair
protected Cell nextIndexedKey
protected HFileBlock curBlock
protected final ArrayList<HFileBlock> prevBlocks
public HFileScannerImpl(HFile.Reader reader, boolean cacheBlocks, boolean pread, boolean isCompaction)
void updateCurrBlockRef(HFileBlock block)
void reset()
private void returnBlockToCache(HFileBlock block)
private void returnBlocks(boolean returnAll)
public boolean isSeeked()
isSeeked
in interface HFileScanner
HFileScanner.seekBefore(Cell)
or HFileScanner.seekTo()
or HFileScanner.seekTo(Cell)
.
Otherwise returns false.protected void assertSeeked()
public HFile.Reader getReader()
getReader
in interface HFileScanner
private int getKVBufSize()
public void close()
HFileScanner
close
in interface Closeable
close
in interface AutoCloseable
close
in interface HFileScanner
private int getCurCellSerializedSize()
protected void readKeyValueLen()
private final void checkTagsLen()
protected void readMvccVersion(int offsetFromPos)
offsetFromPos
- private void _readMvccVersion(int offsetFromPos)
offsetFromPos
- protected int blockSeek(Cell key, boolean seekBefore)
key
- the key to findseekBefore
- find the key before the given key in case of exact match.public Cell getNextIndexedKey()
getNextIndexedKey
in interface HFileScanner
public int seekTo(Cell key) throws IOException
HFileScanner
cell
. Examine the return
code to figure whether we found the cell or not.
Consider the cell stream of all the cells in the file,
c[0] .. c[n]
, where there are n cells in the file.seekTo
in interface HFileScanner
IOException
public int reseekTo(Cell key) throws IOException
HFileScanner
cell
. Similar to seekTo
except that this can be called even if the scanner is not at the beginning
of a file.
This can be used to seek only to cells which come after the current position
of the scanner.
Consider the cell stream of all the cells in the file,
c[0] .. c[n]
, where there are n cellc in the file after
current position of HFileScanner.
The scanner will position itself between c[i] and c[i+1] where
c[i] < cell <= c[i+1].
If there is no cell c[i+1] greater than or equal to the input cell, then the
scanner will position itself at the end of the file and next() will return
false when it is called.reseekTo
in interface HFileScanner
key
- Cell to find (should be non-null)IOException
public int seekTo(Cell key, boolean rewind) throws IOException
key
- - a cell representing the key that we need to fetchrewind
- whether to rewind to the first key of the block before
doing the seek. If this is false, we are assuming we never go
back, otherwise the result is undefined.IOException
public boolean seekBefore(Cell key) throws IOException
HFileScanner
c[0] .. c[n]
, where there are n cells in the file.seekBefore
in interface HFileScanner
key
- Cell to findIOException
protected void releaseIfNotCurBlock(HFileBlock block)
protected HFileBlock readNextDataBlock() throws IOException
HFile
until the next
data block is found.IOException
public DataBlockEncoding getEffectiveDataBlockEncoding()
public Cell getCell()
getCell
in interface HFileScanner
Cell
.public Cell getKey()
HFileScanner
HFileScanner.seekTo(Cell)
before this method.getKey
in interface HFileScanner
public ByteBuffer getValue()
HFileScanner
HFileScanner.seekTo(Cell)
before this method.getValue
in interface HFileScanner
protected void setNonSeekedState()
private void positionThisBlockBuffer()
private boolean positionForNextBlock() throws IOException
IOException
private boolean isNextBlock() throws IOException
IOException
private final boolean _next() throws IOException
IOException
public boolean next() throws IOException
getKey()
and getValue()
can
be called.next
in interface HFileScanner
IOException
public boolean seekTo() throws IOException
seekTo
in interface HFileScanner
IOException
protected boolean processFirstDataBlock() throws IOException
IOException
protected void readAndUpdateNewBlock(long firstDataBlockOffset) throws IOException, CorruptHFileException
IOException
CorruptHFileException
protected int loadBlockAndSeekToKey(HFileBlock seekToBlock, Cell nextIndexedKey, boolean rewind, Cell key, boolean seekBefore) throws IOException
IOException
protected final boolean checkKeyLen(int v)
v
- protected final boolean checkLen(int v)
v
- protected final void checkKeyValueLen()
protected void updateCurrentBlock(HFileBlock newBlock) throws IOException
HFileBlock
. Seeks to
the the first key/value pair.newBlock
- the block to make currentIOException
protected Cell getFirstKeyCellInBlock(HFileBlock curBlock)
public String getKeyString()
HFileScanner
HFileScanner.seekTo(Cell)
before this method.getKeyString
in interface HFileScanner
public String getValueString()
HFileScanner
HFileScanner.seekTo(Cell)
before this method.getValueString
in interface HFileScanner
public int compareKey(CellComparator comparator, Cell key)
public void shipped() throws IOException
Shipper
shipped
in interface Shipper
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.