2018-03-08 19:16:46 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
|
|
|
|
#include <jni.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "rocksdb/comparator.h"
|
|
|
|
#include "rocksdb/slice.h"
|
|
|
|
|
|
|
|
#include "include/org_rocksdb_NativeComparatorWrapperTest_NativeStringComparatorWrapper.h"
|
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2018-03-08 19:16:46 +00:00
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
class NativeComparatorWrapperTestStringComparator : public Comparator {
|
2018-03-08 19:16:46 +00:00
|
|
|
const char* Name() const {
|
|
|
|
return "NativeComparatorWrapperTestStringComparator";
|
|
|
|
}
|
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
int Compare(const Slice& a, const Slice& b) const {
|
2018-03-08 19:16:46 +00:00
|
|
|
return a.ToString().compare(b.ToString());
|
|
|
|
}
|
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
void FindShortestSeparator(std::string* /*start*/,
|
|
|
|
const Slice& /*limit*/) const {
|
2018-03-08 19:16:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-13 00:55:14 +00:00
|
|
|
void FindShortSuccessor(std::string* /*key*/) const { return; }
|
2018-03-08 19:16:46 +00:00
|
|
|
};
|
2020-02-20 20:07:53 +00:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|
2018-03-08 19:16:46 +00:00
|
|
|
|
|
|
|
/*
|
2018-04-13 00:55:14 +00:00
|
|
|
* Class: org_rocksdb_NativeComparatorWrapperTest_NativeStringComparatorWrapper
|
2018-03-08 19:16:46 +00:00
|
|
|
* Method: newStringComparator
|
|
|
|
* Signature: ()J
|
|
|
|
*/
|
|
|
|
jlong Java_org_rocksdb_NativeComparatorWrapperTest_00024NativeStringComparatorWrapper_newStringComparator(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* /*env*/, jobject /*jobj*/) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* comparator =
|
|
|
|
new ROCKSDB_NAMESPACE::NativeComparatorWrapperTestStringComparator();
|
2018-03-08 19:16:46 +00:00
|
|
|
return reinterpret_cast<jlong>(comparator);
|
|
|
|
}
|