2018-03-08 20:16:46 +01: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"
|
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
2018-04-13 02:55:14 +02:00
|
|
|
class NativeComparatorWrapperTestStringComparator : public Comparator {
|
2018-03-08 20:16:46 +01:00
|
|
|
const char* Name() const {
|
|
|
|
return "NativeComparatorWrapperTestStringComparator";
|
|
|
|
}
|
|
|
|
|
2018-04-13 02:55:14 +02:00
|
|
|
int Compare(const Slice& a, const Slice& b) const {
|
2018-03-08 20:16:46 +01:00
|
|
|
return a.ToString().compare(b.ToString());
|
|
|
|
}
|
|
|
|
|
2018-04-13 02:55:14 +02:00
|
|
|
void FindShortestSeparator(std::string* /*start*/,
|
|
|
|
const Slice& /*limit*/) const {
|
2018-03-08 20:16:46 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-13 02:55:14 +02:00
|
|
|
void FindShortSuccessor(std::string* /*key*/) const { return; }
|
2018-03-08 20:16:46 +01:00
|
|
|
};
|
2018-04-13 02:55:14 +02:00
|
|
|
} // namespace rocksdb
|
2018-03-08 20:16:46 +01:00
|
|
|
|
|
|
|
/*
|
2018-04-13 02:55:14 +02:00
|
|
|
* Class: org_rocksdb_NativeComparatorWrapperTest_NativeStringComparatorWrapper
|
2018-03-08 20:16:46 +01:00
|
|
|
* Method: newStringComparator
|
|
|
|
* Signature: ()J
|
|
|
|
*/
|
|
|
|
jlong Java_org_rocksdb_NativeComparatorWrapperTest_00024NativeStringComparatorWrapper_newStringComparator(
|
2018-04-13 02:55:14 +02:00
|
|
|
JNIEnv* /*env*/, jobject /*jobj*/) {
|
|
|
|
auto* comparator = new rocksdb::NativeComparatorWrapperTestStringComparator();
|
2018-03-08 20:16:46 +01:00
|
|
|
return reinterpret_cast<jlong>(comparator);
|
|
|
|
}
|