fork of https://github.com/oxigraph/rocksdb and https://github.com/facebook/rocksdb for nextgraph and oxigraph
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.
366 lines
12 KiB
366 lines
12 KiB
9 years ago
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
||
8 years ago
|
// 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).
|
||
11 years ago
|
//
|
||
|
// This file implements the "bridge" between Java and C++ and enables
|
||
5 years ago
|
// calling c++ ROCKSDB_NAMESPACE::BackupEnginge and
|
||
3 years ago
|
// ROCKSDB_NAMESPACE::BackupEngineOptions methods from Java side.
|
||
11 years ago
|
|
||
7 years ago
|
#include <jni.h>
|
||
11 years ago
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
3 years ago
|
|
||
11 years ago
|
#include <string>
|
||
10 years ago
|
#include <vector>
|
||
11 years ago
|
|
||
3 years ago
|
#include "include/org_rocksdb_BackupEngineOptions.h"
|
||
|
#include "rocksdb/utilities/backup_engine.h"
|
||
3 years ago
|
#include "rocksjni/cplusplus_to_java_convert.h"
|
||
7 years ago
|
#include "rocksjni/portal.h"
|
||
11 years ago
|
|
||
|
///////////////////////////////////////////////////////////////////////////
|
||
|
// BackupDBOptions
|
||
|
|
||
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
|
* Method: newBackupEngineOptions
|
||
9 years ago
|
* Signature: (Ljava/lang/String;)J
|
||
11 years ago
|
*/
|
||
3 years ago
|
jlong Java_org_rocksdb_BackupEngineOptions_newBackupEngineOptions(
|
||
7 years ago
|
JNIEnv* env, jclass /*jcls*/, jstring jpath) {
|
||
8 years ago
|
const char* cpath = env->GetStringUTFChars(jpath, nullptr);
|
||
7 years ago
|
if (cpath == nullptr) {
|
||
8 years ago
|
// exception thrown: OutOfMemoryError
|
||
|
return 0;
|
||
|
}
|
||
3 years ago
|
auto* bopt = new ROCKSDB_NAMESPACE::BackupEngineOptions(cpath);
|
||
11 years ago
|
env->ReleaseStringUTFChars(jpath, cpath);
|
||
3 years ago
|
return GET_CPLUSPLUS_POINTER(bopt);
|
||
11 years ago
|
}
|
||
|
|
||
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
11 years ago
|
* Method: backupDir
|
||
|
* Signature: (J)Ljava/lang/String;
|
||
|
*/
|
||
3 years ago
|
jstring Java_org_rocksdb_BackupEngineOptions_backupDir(JNIEnv* env,
|
||
7 years ago
|
jobject /*jopt*/,
|
||
|
jlong jhandle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
11 years ago
|
return env->NewStringUTF(bopt->backup_dir.c_str());
|
||
|
}
|
||
|
|
||
8 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
8 years ago
|
* Method: setBackupEnv
|
||
|
* Signature: (JJ)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_setBackupEnv(
|
||
7 years ago
|
JNIEnv* /*env*/, jobject /*jopt*/, jlong jhandle, jlong jrocks_env_handle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
5 years ago
|
auto* rocks_env =
|
||
|
reinterpret_cast<ROCKSDB_NAMESPACE::Env*>(jrocks_env_handle);
|
||
8 years ago
|
bopt->backup_env = rocks_env;
|
||
|
}
|
||
|
|
||
10 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: setShareTableFiles
|
||
|
* Signature: (JZ)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_setShareTableFiles(JNIEnv* /*env*/,
|
||
7 years ago
|
jobject /*jobj*/,
|
||
|
jlong jhandle,
|
||
|
jboolean flag) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
bopt->share_table_files = flag;
|
||
|
}
|
||
|
|
||
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: shareTableFiles
|
||
|
* Signature: (J)Z
|
||
|
*/
|
||
3 years ago
|
jboolean Java_org_rocksdb_BackupEngineOptions_shareTableFiles(JNIEnv* /*env*/,
|
||
7 years ago
|
jobject /*jobj*/,
|
||
|
jlong jhandle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
return bopt->share_table_files;
|
||
|
}
|
||
|
|
||
8 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
8 years ago
|
* Method: setInfoLog
|
||
|
* Signature: (JJ)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_setInfoLog(JNIEnv* /*env*/,
|
||
7 years ago
|
jobject /*jobj*/,
|
||
|
jlong jhandle,
|
||
|
jlong /*jlogger_handle*/) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
8 years ago
|
auto* sptr_logger =
|
||
5 years ago
|
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::LoggerJniCallback>*>(
|
||
|
jhandle);
|
||
8 years ago
|
bopt->info_log = sptr_logger->get();
|
||
|
}
|
||
|
|
||
10 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: setSync
|
||
|
* Signature: (JZ)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_setSync(JNIEnv* /*env*/,
|
||
7 years ago
|
jobject /*jobj*/,
|
||
|
jlong jhandle,
|
||
|
jboolean flag) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
bopt->sync = flag;
|
||
|
}
|
||
|
|
||
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: sync
|
||
|
* Signature: (J)Z
|
||
|
*/
|
||
3 years ago
|
jboolean Java_org_rocksdb_BackupEngineOptions_sync(JNIEnv* /*env*/,
|
||
7 years ago
|
jobject /*jobj*/,
|
||
|
jlong jhandle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
return bopt->sync;
|
||
|
}
|
||
|
|
||
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: setDestroyOldData
|
||
|
* Signature: (JZ)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_setDestroyOldData(JNIEnv* /*env*/,
|
||
7 years ago
|
jobject /*jobj*/,
|
||
|
jlong jhandle,
|
||
|
jboolean flag) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
bopt->destroy_old_data = flag;
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: destroyOldData
|
||
|
* Signature: (J)Z
|
||
|
*/
|
||
3 years ago
|
jboolean Java_org_rocksdb_BackupEngineOptions_destroyOldData(JNIEnv* /*env*/,
|
||
7 years ago
|
jobject /*jobj*/,
|
||
|
jlong jhandle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
return bopt->destroy_old_data;
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: setBackupLogFiles
|
||
|
* Signature: (JZ)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_setBackupLogFiles(JNIEnv* /*env*/,
|
||
7 years ago
|
jobject /*jobj*/,
|
||
|
jlong jhandle,
|
||
|
jboolean flag) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
bopt->backup_log_files = flag;
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: backupLogFiles
|
||
|
* Signature: (J)Z
|
||
|
*/
|
||
3 years ago
|
jboolean Java_org_rocksdb_BackupEngineOptions_backupLogFiles(JNIEnv* /*env*/,
|
||
7 years ago
|
jobject /*jobj*/,
|
||
|
jlong jhandle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
return bopt->backup_log_files;
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: setBackupRateLimit
|
||
|
* Signature: (JJ)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_setBackupRateLimit(
|
||
7 years ago
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
|
||
|
jlong jbackup_rate_limit) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
bopt->backup_rate_limit = jbackup_rate_limit;
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: backupRateLimit
|
||
|
* Signature: (J)J
|
||
|
*/
|
||
3 years ago
|
jlong Java_org_rocksdb_BackupEngineOptions_backupRateLimit(JNIEnv* /*env*/,
|
||
7 years ago
|
jobject /*jobj*/,
|
||
|
jlong jhandle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
return bopt->backup_rate_limit;
|
||
|
}
|
||
10 years ago
|
|
||
8 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
8 years ago
|
* Method: setBackupRateLimiter
|
||
|
* Signature: (JJ)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_setBackupRateLimiter(
|
||
7 years ago
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
|
||
|
jlong jrate_limiter_handle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
8 years ago
|
auto* sptr_rate_limiter =
|
||
5 years ago
|
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::RateLimiter>*>(
|
||
7 years ago
|
jrate_limiter_handle);
|
||
8 years ago
|
bopt->backup_rate_limiter = *sptr_rate_limiter;
|
||
|
}
|
||
|
|
||
10 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: setRestoreRateLimit
|
||
|
* Signature: (JJ)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_setRestoreRateLimit(
|
||
7 years ago
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
|
||
|
jlong jrestore_rate_limit) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
bopt->restore_rate_limit = jrestore_rate_limit;
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: restoreRateLimit
|
||
|
* Signature: (J)J
|
||
|
*/
|
||
3 years ago
|
jlong Java_org_rocksdb_BackupEngineOptions_restoreRateLimit(JNIEnv* /*env*/,
|
||
7 years ago
|
jobject /*jobj*/,
|
||
|
jlong jhandle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
return bopt->restore_rate_limit;
|
||
|
}
|
||
10 years ago
|
|
||
8 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
8 years ago
|
* Method: setRestoreRateLimiter
|
||
|
* Signature: (JJ)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_setRestoreRateLimiter(
|
||
7 years ago
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
|
||
|
jlong jrate_limiter_handle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
8 years ago
|
auto* sptr_rate_limiter =
|
||
5 years ago
|
reinterpret_cast<std::shared_ptr<ROCKSDB_NAMESPACE::RateLimiter>*>(
|
||
7 years ago
|
jrate_limiter_handle);
|
||
8 years ago
|
bopt->restore_rate_limiter = *sptr_rate_limiter;
|
||
|
}
|
||
|
|
||
10 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: setShareFilesWithChecksum
|
||
|
* Signature: (JZ)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_setShareFilesWithChecksum(
|
||
7 years ago
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle, jboolean flag) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
bopt->share_files_with_checksum = flag;
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
10 years ago
|
* Method: shareFilesWithChecksum
|
||
|
* Signature: (J)Z
|
||
|
*/
|
||
3 years ago
|
jboolean Java_org_rocksdb_BackupEngineOptions_shareFilesWithChecksum(
|
||
7 years ago
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
10 years ago
|
return bopt->share_files_with_checksum;
|
||
|
}
|
||
10 years ago
|
|
||
8 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
8 years ago
|
* Method: setMaxBackgroundOperations
|
||
|
* Signature: (JI)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_setMaxBackgroundOperations(
|
||
7 years ago
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
|
||
|
jint max_background_operations) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
7 years ago
|
bopt->max_background_operations = static_cast<int>(max_background_operations);
|
||
8 years ago
|
}
|
||
|
|
||
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
8 years ago
|
* Method: maxBackgroundOperations
|
||
|
* Signature: (J)I
|
||
|
*/
|
||
3 years ago
|
jint Java_org_rocksdb_BackupEngineOptions_maxBackgroundOperations(
|
||
7 years ago
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
8 years ago
|
return static_cast<jint>(bopt->max_background_operations);
|
||
|
}
|
||
|
|
||
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
8 years ago
|
* Method: setCallbackTriggerIntervalSize
|
||
|
* Signature: (JJ)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_setCallbackTriggerIntervalSize(
|
||
7 years ago
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle,
|
||
8 years ago
|
jlong jcallback_trigger_interval_size) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
8 years ago
|
bopt->callback_trigger_interval_size =
|
||
|
static_cast<uint64_t>(jcallback_trigger_interval_size);
|
||
|
}
|
||
|
|
||
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
8 years ago
|
* Method: callbackTriggerIntervalSize
|
||
|
* Signature: (J)J
|
||
|
*/
|
||
3 years ago
|
jlong Java_org_rocksdb_BackupEngineOptions_callbackTriggerIntervalSize(
|
||
7 years ago
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jhandle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
8 years ago
|
return static_cast<jlong>(bopt->callback_trigger_interval_size);
|
||
|
}
|
||
|
|
||
11 years ago
|
/*
|
||
3 years ago
|
* Class: org_rocksdb_BackupEngineOptions
|
||
11 years ago
|
* Method: disposeInternal
|
||
11 years ago
|
* Signature: (J)V
|
||
|
*/
|
||
3 years ago
|
void Java_org_rocksdb_BackupEngineOptions_disposeInternal(JNIEnv* /*env*/,
|
||
7 years ago
|
jobject /*jopt*/,
|
||
|
jlong jhandle) {
|
||
5 years ago
|
auto* bopt =
|
||
3 years ago
|
reinterpret_cast<ROCKSDB_NAMESPACE::BackupEngineOptions*>(jhandle);
|
||
8 years ago
|
assert(bopt != nullptr);
|
||
11 years ago
|
delete bopt;
|
||
|
}
|