2016-09-29 21:04:41 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-15 23:03:42 +00:00
|
|
|
// 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).
|
2016-09-29 21:04:41 +00:00
|
|
|
//
|
|
|
|
// This file implements the "bridge" between Java and C++ and enables
|
2020-02-20 20:07:53 +00:00
|
|
|
// calling C++ ROCKSDB_NAMESPACE::EnvOptions methods
|
2016-09-29 21:04:41 +00:00
|
|
|
// from Java side.
|
|
|
|
|
|
|
|
#include <jni.h>
|
|
|
|
|
|
|
|
#include "include/org_rocksdb_EnvOptions.h"
|
|
|
|
#include "rocksdb/env.h"
|
2022-03-01 17:02:15 +00:00
|
|
|
#include "rocksjni/cplusplus_to_java_convert.h"
|
2016-09-29 21:04:41 +00:00
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
#define ENV_OPTIONS_SET_BOOL(_jhandle, _opt) \
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(_jhandle)->_opt = \
|
2016-09-29 21:04:41 +00:00
|
|
|
static_cast<bool>(_opt)
|
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
#define ENV_OPTIONS_SET_SIZE_T(_jhandle, _opt) \
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(_jhandle)->_opt = \
|
2016-09-29 21:04:41 +00:00
|
|
|
static_cast<size_t>(_opt)
|
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
#define ENV_OPTIONS_SET_UINT64_T(_jhandle, _opt) \
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(_jhandle)->_opt = \
|
2016-09-29 21:04:41 +00:00
|
|
|
static_cast<uint64_t>(_opt)
|
|
|
|
|
|
|
|
#define ENV_OPTIONS_GET(_jhandle, _opt) \
|
2020-02-20 20:07:53 +00:00
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(_jhandle)->_opt
|
2016-09-29 21:04:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: newEnvOptions
|
|
|
|
* Signature: ()J
|
|
|
|
*/
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong Java_org_rocksdb_EnvOptions_newEnvOptions__(JNIEnv *, jclass) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto *env_opt = new ROCKSDB_NAMESPACE::EnvOptions();
|
2022-03-01 17:02:15 +00:00
|
|
|
return GET_CPLUSPLUS_POINTER(env_opt);
|
2016-09-29 21:04:41 +00:00
|
|
|
}
|
|
|
|
|
2019-02-22 22:36:38 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: newEnvOptions
|
|
|
|
* Signature: (J)J
|
|
|
|
*/
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong Java_org_rocksdb_EnvOptions_newEnvOptions__J(JNIEnv *, jclass,
|
|
|
|
jlong jdboptions_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto *db_options =
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions *>(jdboptions_handle);
|
|
|
|
auto *env_opt = new ROCKSDB_NAMESPACE::EnvOptions(*db_options);
|
2022-03-01 17:02:15 +00:00
|
|
|
return GET_CPLUSPLUS_POINTER(env_opt);
|
2019-02-22 22:36:38 +00:00
|
|
|
}
|
|
|
|
|
2016-09-29 21:04:41 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: disposeInternal
|
|
|
|
* Signature: (J)V
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
void Java_org_rocksdb_EnvOptions_disposeInternalJni(JNIEnv *, jclass,
|
|
|
|
jlong jhandle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto *eo = reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(jhandle);
|
2017-02-28 00:26:12 +00:00
|
|
|
assert(eo != nullptr);
|
|
|
|
delete eo;
|
2016-09-29 21:04:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
2019-02-22 22:36:38 +00:00
|
|
|
* Method: setUseMmapReads
|
2016-09-29 21:04:41 +00:00
|
|
|
* Signature: (JZ)V
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
void Java_org_rocksdb_EnvOptions_setUseMmapReads(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle,
|
|
|
|
jboolean use_mmap_reads) {
|
2019-02-22 22:36:38 +00:00
|
|
|
ENV_OPTIONS_SET_BOOL(jhandle, use_mmap_reads);
|
2016-09-29 21:04:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
2019-02-22 22:36:38 +00:00
|
|
|
* Method: useMmapReads
|
2016-09-29 21:04:41 +00:00
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
jboolean Java_org_rocksdb_EnvOptions_useMmapReads(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle) {
|
2019-02-22 22:36:38 +00:00
|
|
|
return ENV_OPTIONS_GET(jhandle, use_mmap_reads);
|
2016-12-22 20:51:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
2019-02-22 22:36:38 +00:00
|
|
|
* Method: setUseMmapWrites
|
2016-12-22 20:51:29 +00:00
|
|
|
* Signature: (JZ)V
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
void Java_org_rocksdb_EnvOptions_setUseMmapWrites(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle,
|
|
|
|
jboolean use_mmap_writes) {
|
2019-02-22 22:36:38 +00:00
|
|
|
ENV_OPTIONS_SET_BOOL(jhandle, use_mmap_writes);
|
2016-12-22 20:51:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
2019-02-22 22:36:38 +00:00
|
|
|
* Method: useMmapWrites
|
2016-12-22 20:51:29 +00:00
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
jboolean Java_org_rocksdb_EnvOptions_useMmapWrites(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle) {
|
2019-02-22 22:36:38 +00:00
|
|
|
return ENV_OPTIONS_GET(jhandle, use_mmap_writes);
|
2016-09-29 21:04:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
2019-02-22 22:36:38 +00:00
|
|
|
* Method: setUseDirectReads
|
2016-09-29 21:04:41 +00:00
|
|
|
* Signature: (JZ)V
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
void Java_org_rocksdb_EnvOptions_setUseDirectReads(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle,
|
|
|
|
jboolean use_direct_reads) {
|
2019-02-22 22:36:38 +00:00
|
|
|
ENV_OPTIONS_SET_BOOL(jhandle, use_direct_reads);
|
2016-09-29 21:04:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
2019-02-22 22:36:38 +00:00
|
|
|
* Method: useDirectReads
|
2016-09-29 21:04:41 +00:00
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
jboolean Java_org_rocksdb_EnvOptions_useDirectReads(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle) {
|
2019-02-22 22:36:38 +00:00
|
|
|
return ENV_OPTIONS_GET(jhandle, use_direct_reads);
|
2016-09-29 21:04:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
2019-02-22 22:36:38 +00:00
|
|
|
* Method: setUseDirectWrites
|
2016-09-29 21:04:41 +00:00
|
|
|
* Signature: (JZ)V
|
|
|
|
*/
|
2019-02-22 22:36:38 +00:00
|
|
|
void Java_org_rocksdb_EnvOptions_setUseDirectWrites(
|
2024-01-25 20:36:30 +00:00
|
|
|
JNIEnv *, jclass, jlong jhandle, jboolean use_direct_writes) {
|
2019-02-22 22:36:38 +00:00
|
|
|
ENV_OPTIONS_SET_BOOL(jhandle, use_direct_writes);
|
2016-09-29 21:04:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
2019-02-22 22:36:38 +00:00
|
|
|
* Method: useDirectWrites
|
2016-09-29 21:04:41 +00:00
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
jboolean Java_org_rocksdb_EnvOptions_useDirectWrites(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle) {
|
2019-02-22 22:36:38 +00:00
|
|
|
return ENV_OPTIONS_GET(jhandle, use_direct_writes);
|
2016-09-29 21:04:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: setAllowFallocate
|
|
|
|
* Signature: (JZ)V
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
void Java_org_rocksdb_EnvOptions_setAllowFallocate(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle,
|
|
|
|
jboolean allow_fallocate) {
|
2016-09-29 21:04:41 +00:00
|
|
|
ENV_OPTIONS_SET_BOOL(jhandle, allow_fallocate);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: allowFallocate
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
jboolean Java_org_rocksdb_EnvOptions_allowFallocate(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle) {
|
2016-09-29 21:04:41 +00:00
|
|
|
return ENV_OPTIONS_GET(jhandle, allow_fallocate);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: setSetFdCloexec
|
|
|
|
* Signature: (JZ)V
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
void Java_org_rocksdb_EnvOptions_setSetFdCloexec(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle,
|
|
|
|
jboolean set_fd_cloexec) {
|
2016-09-29 21:04:41 +00:00
|
|
|
ENV_OPTIONS_SET_BOOL(jhandle, set_fd_cloexec);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: setFdCloexec
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
jboolean Java_org_rocksdb_EnvOptions_setFdCloexec(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle) {
|
2016-09-29 21:04:41 +00:00
|
|
|
return ENV_OPTIONS_GET(jhandle, set_fd_cloexec);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: setBytesPerSync
|
|
|
|
* Signature: (JJ)V
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
void Java_org_rocksdb_EnvOptions_setBytesPerSync(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle,
|
|
|
|
jlong bytes_per_sync) {
|
2016-09-29 21:04:41 +00:00
|
|
|
ENV_OPTIONS_SET_UINT64_T(jhandle, bytes_per_sync);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: bytesPerSync
|
|
|
|
* Signature: (J)J
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
jlong Java_org_rocksdb_EnvOptions_bytesPerSync(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle) {
|
2016-09-29 21:04:41 +00:00
|
|
|
return ENV_OPTIONS_GET(jhandle, bytes_per_sync);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: setFallocateWithKeepSize
|
|
|
|
* Signature: (JZ)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_EnvOptions_setFallocateWithKeepSize(
|
2024-01-25 20:36:30 +00:00
|
|
|
JNIEnv *, jclass, jlong jhandle, jboolean fallocate_with_keep_size) {
|
2016-09-29 21:04:41 +00:00
|
|
|
ENV_OPTIONS_SET_BOOL(jhandle, fallocate_with_keep_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: fallocateWithKeepSize
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
jboolean Java_org_rocksdb_EnvOptions_fallocateWithKeepSize(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle) {
|
2016-09-29 21:04:41 +00:00
|
|
|
return ENV_OPTIONS_GET(jhandle, fallocate_with_keep_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: setCompactionReadaheadSize
|
|
|
|
* Signature: (JJ)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_EnvOptions_setCompactionReadaheadSize(
|
2024-01-25 20:36:30 +00:00
|
|
|
JNIEnv *, jclass, jlong jhandle, jlong compaction_readahead_size) {
|
2016-09-29 21:04:41 +00:00
|
|
|
ENV_OPTIONS_SET_SIZE_T(jhandle, compaction_readahead_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: compactionReadaheadSize
|
|
|
|
* Signature: (J)J
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
jlong Java_org_rocksdb_EnvOptions_compactionReadaheadSize(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle) {
|
2016-09-29 21:04:41 +00:00
|
|
|
return ENV_OPTIONS_GET(jhandle, compaction_readahead_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: setRandomAccessMaxBufferSize
|
|
|
|
* Signature: (JJ)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_EnvOptions_setRandomAccessMaxBufferSize(
|
2024-01-25 20:36:30 +00:00
|
|
|
JNIEnv *, jclass, jlong jhandle, jlong random_access_max_buffer_size) {
|
2016-09-29 21:04:41 +00:00
|
|
|
ENV_OPTIONS_SET_SIZE_T(jhandle, random_access_max_buffer_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: randomAccessMaxBufferSize
|
|
|
|
* Signature: (J)J
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
jlong Java_org_rocksdb_EnvOptions_randomAccessMaxBufferSize(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle) {
|
2016-09-29 21:04:41 +00:00
|
|
|
return ENV_OPTIONS_GET(jhandle, random_access_max_buffer_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: setWritableFileMaxBufferSize
|
|
|
|
* Signature: (JJ)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_EnvOptions_setWritableFileMaxBufferSize(
|
2024-01-25 20:36:30 +00:00
|
|
|
JNIEnv *, jclass, jlong jhandle, jlong writable_file_max_buffer_size) {
|
2016-09-29 21:04:41 +00:00
|
|
|
ENV_OPTIONS_SET_SIZE_T(jhandle, writable_file_max_buffer_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: writableFileMaxBufferSize
|
|
|
|
* Signature: (J)J
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
jlong Java_org_rocksdb_EnvOptions_writableFileMaxBufferSize(JNIEnv *, jclass,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong jhandle) {
|
2016-09-29 21:04:41 +00:00
|
|
|
return ENV_OPTIONS_GET(jhandle, writable_file_max_buffer_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_EnvOptions
|
|
|
|
* Method: setRateLimiter
|
|
|
|
* Signature: (JJ)V
|
|
|
|
*/
|
2024-01-25 20:36:30 +00:00
|
|
|
void Java_org_rocksdb_EnvOptions_setRateLimiter(JNIEnv *, jclass, jlong jhandle,
|
2022-10-25 16:26:51 +00:00
|
|
|
jlong rl_handle) {
|
2018-04-13 00:55:14 +00:00
|
|
|
auto *sptr_rate_limiter =
|
2020-02-20 20:07:53 +00:00
|
|
|
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::RateLimiter> *>(
|
|
|
|
rl_handle);
|
|
|
|
auto *env_opt = reinterpret_cast<ROCKSDB_NAMESPACE::EnvOptions *>(jhandle);
|
2017-02-28 00:26:12 +00:00
|
|
|
env_opt->rate_limiter = sptr_rate_limiter->get();
|
2016-09-29 21:04:41 +00:00
|
|
|
}
|