Package org.rocksdb.util
Class IntComparator
- All Implemented Interfaces:
AutoCloseable
This is a Java implementation of a Comparator for Java int
keys.
This comparator assumes keys are (at least) four bytes, so
the caller must guarantee that in accessing other APIs in
combination with this comparator.
The performance of Comparators implemented in Java is always
less than their C++ counterparts due to the bridging overhead,
as such you likely don't want to use this apart from benchmarking
or testing.
-
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 TypeMethodDescriptionintcompare(ByteBuffer a, ByteBuffer b) Three-way key comparison.name()The name of the comparator.Methods inherited from class org.rocksdb.AbstractComparator
findShortestSeparator, findShortSuccessor, initializeNative, usingDirectBuffersMethods inherited from class org.rocksdb.RocksCallbackObject
disposeInternalMethods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
Constructor Details
-
IntComparator
-
-
Method Details
-
name
Description copied from class:AbstractComparatorThe 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.
- Specified by:
namein classAbstractComparator- Returns:
- The name of this comparator implementation
-
compare
Description copied from class:AbstractComparatorThree-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.- Specified by:
comparein classAbstractComparator- 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"
-