]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/util/ReverseBytewiseComparator.java
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rocksdb / java / src / main / java / org / rocksdb / util / ReverseBytewiseComparator.java
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
5
6 package org.rocksdb.util;
7
8 import org.rocksdb.BuiltinComparator;
9 import org.rocksdb.ComparatorOptions;
10 import org.rocksdb.Slice;
11
12 /**
13 * This is a Java Native implementation of the C++
14 * equivalent ReverseBytewiseComparatorImpl using {@link Slice}
15 *
16 * The performance of Comparators implemented in Java is always
17 * less than their C++ counterparts due to the bridging overhead,
18 * as such you likely don't want to use this apart from benchmarking
19 * and you most likely instead wanted
20 * {@link BuiltinComparator#REVERSE_BYTEWISE_COMPARATOR}
21 */
22 public class ReverseBytewiseComparator extends BytewiseComparator {
23
24 public ReverseBytewiseComparator(final ComparatorOptions copt) {
25 super(copt);
26 }
27
28 @Override
29 public String name() {
30 return "rocksdb.java.ReverseBytewiseComparator";
31 }
32
33 @Override
34 public int compare(final Slice a, final Slice b) {
35 return -super.compare(a, b);
36 }
37 }