public class BytewiseComparator extends Comparator
Slice
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
and you most likely instead wanted
BuiltinComparator.BYTEWISE_COMPARATOR
Constructor and Description |
---|
BytewiseComparator(ComparatorOptions copt) |
Modifier and Type | Method and Description |
---|---|
int |
compare(Slice a,
Slice b)
Three-way key comparison
|
java.lang.String |
findShortestSeparator(java.lang.String start,
Slice limit)
Used to reduce the space requirements
for internal data structures like index blocks.
|
java.lang.String |
findShortSuccessor(java.lang.String key)
Used to reduce the space requirements
for internal data structures like index blocks.
|
java.lang.String |
name()
The name of the comparator.
|
getNativeHandle
disposeInternal
close, disOwnNativeHandle, isOwningHandle
dispose, finalize
public BytewiseComparator(ComparatorOptions copt)
public java.lang.String name()
AbstractComparator
name
in class AbstractComparator<Slice>
public int compare(Slice a, Slice b)
AbstractComparator
compare
in class AbstractComparator<Slice>
a
- Slice access to first keyb
- Slice access to second keypublic java.lang.String findShortestSeparator(java.lang.String start, Slice limit)
AbstractComparator
Used to reduce the space requirements for internal data structures like index blocks.
If start < limit, you may return a new start which is a shorter string in [start, limit).
Simple comparator implementations may return null if they wish to use start unchanged. i.e., an implementation of this method that does nothing is correct.
findShortestSeparator
in class AbstractComparator<Slice>
start
- Stringlimit
- of type Tpublic java.lang.String findShortSuccessor(java.lang.String key)
AbstractComparator
Used to reduce the space requirements for internal data structures like index blocks.
You may return a new short key (key1) where key1 ≥ key.
Simple comparator implementations may return null if they wish to leave the key unchanged. i.e., an implementation of this method that does nothing is correct.
findShortSuccessor
in class AbstractComparator<Slice>
key
- String