public abstract class AbstractComparator extends RocksCallbackObject
nativeHandle_
owningHandle_
Modifier | Constructor and Description |
---|---|
protected |
AbstractComparator(ComparatorOptions comparatorOptions) |
Modifier and Type | Method and Description |
---|---|
abstract int |
compare(java.nio.ByteBuffer a,
java.nio.ByteBuffer b)
Three-way key comparison.
|
void |
findShortestSeparator(java.nio.ByteBuffer start,
java.nio.ByteBuffer limit)
Used to reduce the space requirements
for internal data structures like index blocks.
|
void |
findShortSuccessor(java.nio.ByteBuffer key)
Used to reduce the space requirements
for internal data structures like index blocks.
|
protected long |
initializeNative(long... nativeParameterHandles)
Construct the Native C++ object which will callback
to our object methods
|
abstract java.lang.String |
name()
The name of the comparator.
|
boolean |
usingDirectBuffers() |
disposeInternal
close, disOwnNativeHandle, isOwningHandle
protected AbstractComparator(ComparatorOptions comparatorOptions)
protected long initializeNative(long... nativeParameterHandles)
RocksCallbackObject
initializeNative
in class RocksCallbackObject
nativeParameterHandles
- An array of native handles for any parameter
objects that are needed during constructionpublic abstract java.lang.String name()
A new name should be used whenever the comparator implementation changes in a way that will cause the relative ordering of any two keys to change.
Names starting with "rocksdb." are reserved and should not be used.
public abstract int compare(java.nio.ByteBuffer a, java.nio.ByteBuffer b)
ByteBuffer
s passed in, though
it would be unconventional to modify the "limit" or any of the
underlying bytes. As a callback, RocksJava will ensure that a
is a different instance from b
.a
- buffer containing the first key in its "remaining" elementsb
- buffer containing the second key in its "remaining" elementspublic void findShortestSeparator(java.nio.ByteBuffer start, java.nio.ByteBuffer limit)
Used to reduce the space requirements for internal data structures like index blocks.
If start < limit, you may modify start which is a shorter string in [start, limit).
If you modify start, it is expected that you set the byte buffer so that a subsequent read of start.remaining() bytes from start.position() to start.limit() will obtain the new start value.Simple comparator implementations may return with start unchanged. i.e., an implementation of this method that does nothing is correct.
start
- the startlimit
- the limitpublic void findShortSuccessor(java.nio.ByteBuffer key)
Used to reduce the space requirements for internal data structures like index blocks.
You may change key to a shorter key (key1) where key1 ≥ key.
Simple comparator implementations may return the key unchanged. i.e., an implementation of this method that does nothing is correct.
key
- the keypublic final boolean usingDirectBuffers()