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 14 namespace ROCKSDB_NAMESPACE { 15 16 class NativeComparatorWrapperTestStringComparator : public Comparator { Name() const17 const char* Name() const { 18 return "NativeComparatorWrapperTestStringComparator"; 19 } 20 Compare(const Slice & a,const Slice & b) const21 int Compare(const Slice& a, const Slice& b) const { 22 return a.ToString().compare(b.ToString()); 23 } 24 FindShortestSeparator(std::string *,const Slice &) const25 void FindShortestSeparator(std::string* /*start*/, 26 const Slice& /*limit*/) const { 27 return; 28 } 29 FindShortSuccessor(std::string *) const30 void FindShortSuccessor(std::string* /*key*/) const { return; } 31 }; 32 } // namespace ROCKSDB_NAMESPACE 33 34 /* 35 * Class: org_rocksdb_NativeComparatorWrapperTest_NativeStringComparatorWrapper 36 * Method: newStringComparator 37 * Signature: ()J 38 */ Java_org_rocksdb_NativeComparatorWrapperTest_00024NativeStringComparatorWrapper_newStringComparator(JNIEnv *,jobject)39jlong Java_org_rocksdb_NativeComparatorWrapperTest_00024NativeStringComparatorWrapper_newStringComparator( 40 JNIEnv* /*env*/, jobject /*jobj*/) { 41 auto* comparator = 42 new ROCKSDB_NAMESPACE::NativeComparatorWrapperTestStringComparator(); 43 return reinterpret_cast<jlong>(comparator); 44 } 45