Class ReverseBytewiseComparator

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public final class ReverseBytewiseComparator
    extends AbstractComparator
    This is a Java Native implementation of the C++ equivalent ReverseBytewiseComparatorImpl using 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.REVERSE_BYTEWISE_COMPARATOR
    • Constructor Detail

      • ReverseBytewiseComparator

        public ReverseBytewiseComparator​(ComparatorOptions copt)
    • Method Detail

      • name

        public java.lang.String name()
        Description copied from class: AbstractComparator
        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.
        Specified by:
        name in class AbstractComparator
        Returns:
        The name of this comparator implementation
      • compare

        public int compare​(java.nio.ByteBuffer a,
                           java.nio.ByteBuffer b)
        Description copied from class: AbstractComparator
        Three-way key comparison. Implementations should provide a total order on keys that might be passed to it. The implementation may modify the ByteBuffers 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.
        Specified by:
        compare in class AbstractComparator
        Parameters:
        a - buffer containing the first key in its "remaining" elements
        b - 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

        public void findShortestSeparator​(java.nio.ByteBuffer start,
                                          java.nio.ByteBuffer limit)
        Description copied from class: AbstractComparator

        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.

        Overrides:
        findShortestSeparator in class AbstractComparator
        Parameters:
        start - the start
        limit - the limit