You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rocksdb/java/rocksjni/compact_range_options.cc

339 lines
12 KiB

// 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).
//
// This file implements the "bridge" between Java and C++ for
// ROCKSDB_NAMESPACE::CompactRangeOptions.
#include <jni.h>
#include "include/org_rocksdb_CompactRangeOptions.h"
#include "rocksdb/options.h"
#include "rocksjni/cplusplus_to_java_convert.h"
#include "rocksjni/portal.h"
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
#include "util/coding.h"
/**
* @brief Class containing compact range options for Java API
*
* An object of this class is returned as the native handle for
* ROCKSDB_NAMESPACE::CompactRangeOptions It contains objects for various
* parameters which are passed by reference/pointer in CompactRangeOptions. We
* maintain the lifetime of these parameters (`full_history_ts_low`, `canceled`)
* by including their values in this class.
*/
class Java_org_rocksdb_CompactRangeOptions {
public:
ROCKSDB_NAMESPACE::CompactRangeOptions compactRangeOptions;
private:
std::string full_history_ts_low;
std::atomic<bool> canceled;
public:
void set_full_history_ts_low(uint64_t start, uint64_t range) {
full_history_ts_low = "";
ROCKSDB_NAMESPACE::PutFixed64(&full_history_ts_low, start);
ROCKSDB_NAMESPACE::PutFixed64(&full_history_ts_low, range);
compactRangeOptions.full_history_ts_low =
new ROCKSDB_NAMESPACE::Slice(full_history_ts_low);
}
bool read_full_history_ts_low(uint64_t* start, uint64_t* range) {
if (compactRangeOptions.full_history_ts_low == nullptr) return false;
ROCKSDB_NAMESPACE::Slice read_slice(
compactRangeOptions.full_history_ts_low->ToStringView());
if (!ROCKSDB_NAMESPACE::GetFixed64(&read_slice, start)) return false;
return ROCKSDB_NAMESPACE::GetFixed64(&read_slice, range);
}
void set_canceled(bool value) {
if (compactRangeOptions.canceled == nullptr) {
canceled.store(value, std::memory_order_seq_cst);
compactRangeOptions.canceled = &canceled;
} else {
compactRangeOptions.canceled->store(value, std::memory_order_seq_cst);
}
}
bool get_canceled() {
return compactRangeOptions.canceled &&
compactRangeOptions.canceled->load(std::memory_order_seq_cst);
}
};
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: newCompactRangeOptions
* Signature: ()J
*/
jlong Java_org_rocksdb_CompactRangeOptions_newCompactRangeOptions(
JNIEnv* /*env*/, jclass /*jclazz*/) {
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
auto* options = new Java_org_rocksdb_CompactRangeOptions();
return GET_CPLUSPLUS_POINTER(&options->compactRangeOptions);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: exclusiveManualCompaction
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_CompactRangeOptions_exclusiveManualCompaction(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
return static_cast<jboolean>(
options->compactRangeOptions.exclusive_manual_compaction);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: setExclusiveManualCompaction
* Signature: (JZ)V
*/
void Java_org_rocksdb_CompactRangeOptions_setExclusiveManualCompaction(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jboolean exclusive_manual_compaction) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
options->compactRangeOptions.exclusive_manual_compaction =
static_cast<bool>(exclusive_manual_compaction);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: bottommostLevelCompaction
* Signature: (J)I
*/
jint Java_org_rocksdb_CompactRangeOptions_bottommostLevelCompaction(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
return ROCKSDB_NAMESPACE::BottommostLevelCompactionJni::
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
toJavaBottommostLevelCompaction(
options->compactRangeOptions.bottommost_level_compaction);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: setBottommostLevelCompaction
* Signature: (JI)V
*/
void Java_org_rocksdb_CompactRangeOptions_setBottommostLevelCompaction(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jint bottommost_level_compaction) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
options->compactRangeOptions.bottommost_level_compaction =
ROCKSDB_NAMESPACE::BottommostLevelCompactionJni::
toCppBottommostLevelCompaction(bottommost_level_compaction);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: changeLevel
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_CompactRangeOptions_changeLevel(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
return static_cast<jboolean>(options->compactRangeOptions.change_level);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: setChangeLevel
* Signature: (JZ)V
*/
void Java_org_rocksdb_CompactRangeOptions_setChangeLevel(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jboolean change_level) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
options->compactRangeOptions.change_level = static_cast<bool>(change_level);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: targetLevel
* Signature: (J)I
*/
jint Java_org_rocksdb_CompactRangeOptions_targetLevel(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
return static_cast<jint>(options->compactRangeOptions.target_level);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: setTargetLevel
* Signature: (JI)V
*/
void Java_org_rocksdb_CompactRangeOptions_setTargetLevel(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jint target_level) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
options->compactRangeOptions.target_level = static_cast<int>(target_level);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: targetPathId
* Signature: (J)I
*/
jint Java_org_rocksdb_CompactRangeOptions_targetPathId(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
return static_cast<jint>(options->compactRangeOptions.target_path_id);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: setTargetPathId
* Signature: (JI)V
*/
void Java_org_rocksdb_CompactRangeOptions_setTargetPathId(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle,
jint target_path_id) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
options->compactRangeOptions.target_path_id =
static_cast<uint32_t>(target_path_id);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: allowWriteStall
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_CompactRangeOptions_allowWriteStall(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
return static_cast<jboolean>(options->compactRangeOptions.allow_write_stall);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: setAllowWriteStall
* Signature: (JZ)V
*/
void Java_org_rocksdb_CompactRangeOptions_setAllowWriteStall(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
jboolean allow_write_stall) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
options->compactRangeOptions.allow_write_stall =
static_cast<bool>(allow_write_stall);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: maxSubcompactions
* Signature: (J)I
*/
jint Java_org_rocksdb_CompactRangeOptions_maxSubcompactions(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
return static_cast<jint>(options->compactRangeOptions.max_subcompactions);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: setMaxSubcompactions
* Signature: (JI)V
*/
void Java_org_rocksdb_CompactRangeOptions_setMaxSubcompactions(
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jint max_subcompactions) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
options->compactRangeOptions.max_subcompactions =
static_cast<uint32_t>(max_subcompactions);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: setFullHistoryTSLow
* Signature: (JJJ)V
*/
void Java_org_rocksdb_CompactRangeOptions_setFullHistoryTSLow(JNIEnv*, jobject,
jlong jhandle,
jlong start,
jlong range) {
auto* options =
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
options->set_full_history_ts_low(start, range);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: fullHistoryTSLow
* Signature: (J)Lorg/rocksdb/CompactRangeOptions/Timestamp;
*/
jobject Java_org_rocksdb_CompactRangeOptions_fullHistoryTSLow(JNIEnv* env,
jobject,
jlong jhandle) {
auto* options =
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
uint64_t start;
uint64_t range;
jobject result = nullptr;
if (options->read_full_history_ts_low(&start, &range)) {
result =
ROCKSDB_NAMESPACE::CompactRangeOptionsTimestampJni::fromCppTimestamp(
env, start, range);
}
return result;
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: setCanceled
* Signature: (JZ)V
*/
void Java_org_rocksdb_CompactRangeOptions_setCanceled(JNIEnv*, jobject,
jlong jhandle,
jboolean jcanceled) {
auto* options =
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
options->set_canceled(jcanceled);
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: canceled
* Signature: (J)Z
*/
jboolean Java_org_rocksdb_CompactRangeOptions_canceled(JNIEnv*, jobject,
jlong jhandle) {
auto* options =
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
return options->get_canceled();
}
/*
* Class: org_rocksdb_CompactRangeOptions
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_CompactRangeOptions_disposeInternal(JNIEnv* /*env*/,
jobject /*jobj*/,
jlong jhandle) {
auto* options =
Implement missing compactrangeoptions from Java API (#10880) Summary: Add the following missing options to `src/main/java/org/rocksdb/CompactRangeOptions.java` and in `java/rocksjni/options.cc` in RocksJava. For the descriptions and API see the C++ file `include/rocksdb/options.h`, specifically the struct `CompactRangeOptions` * full_history_ts_low * canceled We changed the handle to return an object (of class `Java_org_rocksdb_CompactRangeOptions`) containing a `ROCKSDB_NAMESPACE::CompactRangeOptions` at (almost certainly) 0-offset, rather than a raw `ROCKSDB_NAMESPACE::CompactRangeOptions`. The `Java_org_rocksdb_CompactRangeOptions` contains as supplementary fields objects (std::string, std::atomic<bool>) which are passed as pointers to the `ROCKSDB_NAMESPACE::CompactRangeOptions` and which must therefore live for as long as the `ROCKSDB_NAMESPACE::CompactRangeOptions`. By placing them in a `Java_org_rocksdb_CompactRangeOptions` we achieve this. Because the field offset of the `ROCKSDB_NAMESPACE::CompactRangeOptions` member is (very probably) 0, casting the handle to ROCKSDB_NAMESPACE::CompactRangeOptions works (i.e. old methods didn’t have to be changed), but really that’s a minefield and the correct answer is to cast to the correct type (Java_org_rocksdb_CompactRangeOptions) and then use the ROCKSDB_NAMESPACE::CompactRangeOptions field in that. So the get/set methods for existing parameters have this change. Testing ------- We added unit tests for getting and setting the newly implemented fields to `CompactRangeOptionsTest` Pull Request resolved: https://github.com/facebook/rocksdb/pull/10880 Reviewed By: ajkr Differential Revision: D41482476 Pulled By: anand1976 fbshipit-source-id: c70795e790436fb3544655920adf6fca62ed34e2
2 years ago
reinterpret_cast<Java_org_rocksdb_CompactRangeOptions*>(jhandle);
delete options;
}