Class AbstractComparator
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
BytewiseComparator,IntComparator,NativeComparatorWrapper,ReverseBytewiseComparator
-
Field Summary
Fields inherited from class org.rocksdb.RocksCallbackObject
nativeHandle_Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_ -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract intcompare(ByteBuffer a, ByteBuffer b) Three-way key comparison.voidfindShortestSeparator(ByteBuffer start, ByteBuffer limit) Used to reduce the space requirements for internal data structures like index blocks.voidUsed to reduce the space requirements for internal data structures like index blocks.protected longinitializeNative(long... nativeParameterHandles) Construct the Native C++ object which will callback to our object methodsabstract Stringname()The name of the comparator.final booleanMethods inherited from class org.rocksdb.RocksCallbackObject
disposeInternalMethods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
Constructor Details
-
AbstractComparator
-
-
Method Details
-
initializeNative
protected long initializeNative(long... nativeParameterHandles) Description copied from class:RocksCallbackObjectConstruct the Native C++ object which will callback to our object methods- Specified by:
initializeNativein classRocksCallbackObject- Parameters:
nativeParameterHandles- An array of native handles for any parameter objects that are needed during construction- Returns:
- The native handle of the C++ object which will callback to us
-
name
The name of the comparator. Used to check for comparator mismatches (i.e., a DB created with one comparator is accessed using a different comparator).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.
- Returns:
- The name of this comparator implementation
-
compare
Three-way key comparison. Implementations should provide a total order on keys that might be passed to it. The implementation may modify theByteBuffers passed in, though it would be unconventional to modify the "limit" or any of the underlying bytes. As a callback, RocksJava will ensure thatais a different instance fromb.- Parameters:
a- buffer containing the first key in its "remaining" elementsb- buffer containing the second key in its "remaining" elements- Returns:
- Should return either: 1) < 0 if "a" < "b" 2) == 0 if "a" == "b" 3) > 0 if "a" > "b"
-
findShortestSeparator
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.
- Parameters:
start- the startlimit- the limit
-
findShortSuccessor
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.
- Parameters:
key- the key
-
usingDirectBuffers
public final boolean usingDirectBuffers()
-