@InterfaceAudience.Private public class PrefixTreeSeeker extends Object implements DataBlockEncoder.EncodedSeeker
Modifier and Type | Field and Description |
---|---|
protected ByteBuffer |
block |
protected boolean |
includeMvccVersion |
protected PrefixTreeArraySearcher |
ptSearcher |
Constructor and Description |
---|
PrefixTreeSeeker(boolean includeMvccVersion) |
Modifier and Type | Method and Description |
---|---|
boolean |
advance() |
int |
compareKey(KeyValue.KVComparator comparator,
byte[] key,
int offset,
int length)
Compare the given key against the current key
|
int |
compareKey(KeyValue.KVComparator comparator,
Cell key) |
Cell |
get()
Currently unused.
|
ByteBuffer |
getKeyDeepCopy()
Does a deep copy of the key at the current position.
|
Cell |
getKeyValue()
currently must do deep copy into new array
|
ByteBuffer |
getValueShallowCopy()
Does a shallow copy of the value at the current position.
|
boolean |
next()
Move to next position
|
void |
releaseCurrentSearcher()
Currently unused.
|
void |
rewind()
Set position to beginning of given block
|
int |
seekToKeyInBlock(byte[] keyOnlyBytes,
int offset,
int length,
boolean forceBeforeOnExactMatch)
Seek forward only (should be called reseekToKeyInBlock?).
|
int |
seekToKeyInBlock(Cell key,
boolean forceBeforeOnExactMatch)
Moves the seeker position within the current block to:
the last key that that is less than or equal to the given key if
seekBefore is false
the last key that is strictly less than the given key if
seekBefore is true. |
protected int |
seekToOrBeforeUsingPositionAtOrAfter(byte[] keyOnlyBytes,
int offset,
int length,
boolean seekBefore) |
protected int |
seekToOrBeforeUsingPositionAtOrAfter(Cell kv,
boolean seekBefore) |
protected int |
seekToOrBeforeUsingPositionAtOrBefore(byte[] keyOnlyBytes,
int offset,
int length,
boolean seekBefore) |
protected int |
seekToOrBeforeUsingPositionAtOrBefore(Cell kv,
boolean seekBefore) |
void |
setCurrentBuffer(ByteBuffer fullBlockBuffer)
Set on which buffer there will be done seeking.
|
protected ByteBuffer block
protected boolean includeMvccVersion
protected PrefixTreeArraySearcher ptSearcher
public void setCurrentBuffer(ByteBuffer fullBlockBuffer)
DataBlockEncoder.EncodedSeeker
setCurrentBuffer
in interface DataBlockEncoder.EncodedSeeker
fullBlockBuffer
- Used for seeking.public void releaseCurrentSearcher()
Currently unused.
TODO performance leak. should reuse the searchers. hbase does not currently have a hook where this can be calledpublic ByteBuffer getKeyDeepCopy()
DataBlockEncoder.EncodedSeeker
getKeyDeepCopy
in interface DataBlockEncoder.EncodedSeeker
public ByteBuffer getValueShallowCopy()
DataBlockEncoder.EncodedSeeker
getValueShallowCopy
in interface DataBlockEncoder.EncodedSeeker
public Cell getKeyValue()
getKeyValue
in interface DataBlockEncoder.EncodedSeeker
public Cell get()
Currently unused.
A nice, lightweight reference, though the underlying cell is transient. This method may return the same reference to the backing PrefixTreeCell repeatedly, while other implementations may return a different reference for each Cell.
The goal will be to transition the upper layers of HBase, like Filters and KeyValueHeap, to use this method instead of the getKeyValue() methods above.public void rewind()
DataBlockEncoder.EncodedSeeker
rewind
in interface DataBlockEncoder.EncodedSeeker
public boolean next()
DataBlockEncoder.EncodedSeeker
next
in interface DataBlockEncoder.EncodedSeeker
public boolean advance()
public int seekToKeyInBlock(byte[] keyOnlyBytes, int offset, int length, boolean forceBeforeOnExactMatch)
If the exact key is found look at the seekBefore variable and:
- if true: go to the previous key if it's true
- if false: stay on the exact key
If the exact key is not found, then go to the previous key *if possible*, but remember to leave the scanner in a valid state if possible.
seekToKeyInBlock
in interface DataBlockEncoder.EncodedSeeker
keyOnlyBytes
- KeyValue format of a Cell's key at which to position the seekeroffset
- offset into the keyOnlyBytes arraylength
- number of bytes of the keyOnlyBytes array to useforceBeforeOnExactMatch
- if an exact match is found and seekBefore=true, back up 1 Cellprotected int seekToOrBeforeUsingPositionAtOrBefore(byte[] keyOnlyBytes, int offset, int length, boolean seekBefore)
protected int seekToOrBeforeUsingPositionAtOrBefore(Cell kv, boolean seekBefore)
protected int seekToOrBeforeUsingPositionAtOrAfter(byte[] keyOnlyBytes, int offset, int length, boolean seekBefore)
protected int seekToOrBeforeUsingPositionAtOrAfter(Cell kv, boolean seekBefore)
public int compareKey(KeyValue.KVComparator comparator, byte[] key, int offset, int length)
DataBlockEncoder.EncodedSeeker
compareKey
in interface DataBlockEncoder.EncodedSeeker
public int seekToKeyInBlock(Cell key, boolean forceBeforeOnExactMatch)
DataBlockEncoder.EncodedSeeker
seekBefore
is false
seekBefore
is true. The caller is responsible for loading the
previous block if the requested key turns out to be the first key of the
current block.seekToKeyInBlock
in interface DataBlockEncoder.EncodedSeeker
key
- - Cell to which the seek should happenforceBeforeOnExactMatch
- find the key strictly less than the given key in case
of an exact match. Does not matter in case of an inexact match.public int compareKey(KeyValue.KVComparator comparator, Cell key)
compareKey
in interface DataBlockEncoder.EncodedSeeker
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.