]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | // This source code is licensed under both the GPLv2 (found in the | |
3 | // COPYING file in the root directory) and Apache 2.0 License | |
4 | // (found in the LICENSE.Apache file in the root directory). | |
5 | ||
6 | #include <jni.h> | |
7 | #include <string> | |
8 | ||
9 | #include "rocksdb/comparator.h" | |
10 | #include "rocksdb/slice.h" | |
11 | ||
12 | #include "include/org_rocksdb_NativeComparatorWrapperTest_NativeStringComparatorWrapper.h" | |
13 | ||
f67539c2 | 14 | namespace ROCKSDB_NAMESPACE { |
11fdf7f2 TL |
15 | |
16 | class NativeComparatorWrapperTestStringComparator : public Comparator { | |
17 | const char* Name() const { | |
18 | return "NativeComparatorWrapperTestStringComparator"; | |
19 | } | |
20 | ||
21 | int Compare(const Slice& a, const Slice& b) const { | |
22 | return a.ToString().compare(b.ToString()); | |
23 | } | |
24 | ||
25 | void FindShortestSeparator(std::string* /*start*/, | |
26 | const Slice& /*limit*/) const { | |
27 | return; | |
28 | } | |
29 | ||
30 | void FindShortSuccessor(std::string* /*key*/) const { return; } | |
31 | }; | |
f67539c2 | 32 | } // namespace ROCKSDB_NAMESPACE |
11fdf7f2 TL |
33 | |
34 | /* | |
35 | * Class: org_rocksdb_NativeComparatorWrapperTest_NativeStringComparatorWrapper | |
36 | * Method: newStringComparator | |
37 | * Signature: ()J | |
38 | */ | |
39 | jlong Java_org_rocksdb_NativeComparatorWrapperTest_00024NativeStringComparatorWrapper_newStringComparator( | |
40 | JNIEnv* /*env*/, jobject /*jobj*/) { | |
f67539c2 TL |
41 | auto* comparator = |
42 | new ROCKSDB_NAMESPACE::NativeComparatorWrapperTestStringComparator(); | |
11fdf7f2 TL |
43 | return reinterpret_cast<jlong>(comparator); |
44 | } |