2014-04-01 23:59:05 +00:00
|
|
|
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
|
|
|
// This source code is licensed under the BSD-style license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
//
|
|
|
|
// This file implements the "bridge" between Java and C++ for rocksdb::Options.
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <jni.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "include/org_rocksdb_Options.h"
|
2014-04-02 20:14:55 +00:00
|
|
|
#include "include/org_rocksdb_WriteOptions.h"
|
2014-04-01 23:59:05 +00:00
|
|
|
#include "rocksjni/portal.h"
|
|
|
|
#include "rocksdb/db.h"
|
2014-04-02 20:14:55 +00:00
|
|
|
#include "rocksdb/options.h"
|
2014-04-01 23:59:05 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: newOptions
|
|
|
|
* Signature: ()V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_Options_newOptions(JNIEnv* env, jobject jobj) {
|
|
|
|
rocksdb::Options* op = new rocksdb::Options();
|
|
|
|
rocksdb::OptionsJni::setHandle(env, jobj, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: dispose0
|
|
|
|
* Signature: ()V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_Options_dispose0(JNIEnv* env, jobject jobj) {
|
|
|
|
rocksdb::Options* op = rocksdb::OptionsJni::getHandle(env, jobj);
|
|
|
|
delete op;
|
|
|
|
|
|
|
|
rocksdb::OptionsJni::setHandle(env, jobj, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: setCreateIfMissing
|
|
|
|
* Signature: (JZ)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_Options_setCreateIfMissing(
|
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle, jboolean flag) {
|
|
|
|
reinterpret_cast<rocksdb::Options*>(jhandle)->create_if_missing = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: createIfMissing
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
|
|
|
jboolean Java_org_rocksdb_Options_createIfMissing(
|
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle) {
|
|
|
|
return reinterpret_cast<rocksdb::Options*>(jhandle)->create_if_missing;
|
|
|
|
}
|
2014-04-02 20:14:55 +00:00
|
|
|
|
2014-04-06 16:33:31 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: setWriteBufferSize
|
2014-04-14 21:03:43 +00:00
|
|
|
* Signature: (JJ)I
|
2014-04-06 16:33:31 +00:00
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_Options_setWriteBufferSize(
|
2014-04-14 21:03:43 +00:00
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle, jlong jwrite_buffer_size) {
|
2014-04-08 01:32:09 +00:00
|
|
|
reinterpret_cast<rocksdb::Options*>(jhandle)->write_buffer_size =
|
2014-04-06 16:33:31 +00:00
|
|
|
static_cast<size_t>(jwrite_buffer_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: writeBufferSize
|
2014-04-14 21:03:43 +00:00
|
|
|
* Signature: (J)J
|
2014-04-06 16:33:31 +00:00
|
|
|
*/
|
2014-04-14 21:03:43 +00:00
|
|
|
jlong Java_org_rocksdb_Options_writeBufferSize(
|
2014-04-06 16:33:31 +00:00
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle) {
|
2014-04-08 01:32:09 +00:00
|
|
|
return reinterpret_cast<rocksdb::Options*>(jhandle)->write_buffer_size;
|
2014-04-06 16:33:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: setMaxWriteBufferNumber
|
|
|
|
* Signature: (JI)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_Options_setMaxWriteBufferNumber(
|
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle, jint jmax_write_buffer_number) {
|
2014-04-08 01:32:09 +00:00
|
|
|
reinterpret_cast<rocksdb::Options*>(jhandle)->max_write_buffer_number =
|
|
|
|
jmax_write_buffer_number;
|
2014-04-06 16:33:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: maxWriteBufferNumber
|
|
|
|
* Signature: (J)I
|
|
|
|
*/
|
|
|
|
jint Java_org_rocksdb_Options_maxWriteBufferNumber(
|
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle) {
|
2014-04-08 01:32:09 +00:00
|
|
|
return reinterpret_cast<rocksdb::Options*>(jhandle)->max_write_buffer_number;
|
2014-04-06 16:33:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: setBlockSize
|
2014-04-14 21:03:43 +00:00
|
|
|
* Signature: (JJ)V
|
2014-04-06 16:33:31 +00:00
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_Options_setBlockSize(
|
2014-04-14 21:03:43 +00:00
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle, jlong jblock_size) {
|
2014-04-08 01:32:09 +00:00
|
|
|
reinterpret_cast<rocksdb::Options*>(jhandle)->block_size =
|
2014-04-06 16:33:31 +00:00
|
|
|
static_cast<size_t>(jblock_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: blockSize
|
2014-04-14 21:03:43 +00:00
|
|
|
* Signature: (J)J
|
2014-04-06 16:33:31 +00:00
|
|
|
*/
|
2014-04-14 21:03:43 +00:00
|
|
|
jlong Java_org_rocksdb_Options_blockSize(
|
2014-04-06 16:33:31 +00:00
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle) {
|
2014-04-08 01:32:09 +00:00
|
|
|
return reinterpret_cast<rocksdb::Options*>(jhandle)->block_size;
|
2014-04-06 16:33:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: setDisableSeekCompaction
|
|
|
|
* Signature: (JZ)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_Options_setDisableSeekCompaction(
|
2014-04-08 01:32:09 +00:00
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle,
|
2014-04-08 16:27:24 +00:00
|
|
|
jboolean jdisable_seek_compaction) {
|
2014-04-08 01:32:09 +00:00
|
|
|
reinterpret_cast<rocksdb::Options*>(jhandle)->disable_seek_compaction =
|
|
|
|
jdisable_seek_compaction;
|
2014-04-06 16:33:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: disableSeekCompaction
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
|
|
|
jboolean Java_org_rocksdb_Options_disableSeekCompaction(
|
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle) {
|
|
|
|
return reinterpret_cast<rocksdb::Options*>(jhandle)->disable_seek_compaction;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: setMaxBackgroundCompactions
|
|
|
|
* Signature: (JI)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_Options_setMaxBackgroundCompactions(
|
2014-04-08 01:32:09 +00:00
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle,
|
2014-04-08 16:27:24 +00:00
|
|
|
jint jmax_background_compactions) {
|
2014-04-08 01:32:09 +00:00
|
|
|
reinterpret_cast<rocksdb::Options*>(jhandle)->max_background_compactions =
|
|
|
|
jmax_background_compactions;
|
2014-04-06 16:33:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Options
|
|
|
|
* Method: maxBackgroundCompactions
|
|
|
|
* Signature: (J)I
|
|
|
|
*/
|
|
|
|
jint Java_org_rocksdb_Options_maxBackgroundCompactions(
|
|
|
|
JNIEnv* env, jobject jobj, jlong jhandle) {
|
2014-04-08 01:32:09 +00:00
|
|
|
return
|
|
|
|
reinterpret_cast<rocksdb::Options*>(jhandle)->max_background_compactions;
|
2014-04-06 16:33:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-02 20:14:55 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// WriteOptions
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteOptions
|
|
|
|
* Method: newWriteOptions
|
|
|
|
* Signature: ()V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_WriteOptions_newWriteOptions(
|
|
|
|
JNIEnv* env, jobject jwrite_options) {
|
|
|
|
rocksdb::WriteOptions* op = new rocksdb::WriteOptions();
|
|
|
|
rocksdb::WriteOptionsJni::setHandle(env, jwrite_options, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteOptions
|
|
|
|
* Method: dispose0
|
|
|
|
* Signature: ()V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_WriteOptions_dispose0(
|
|
|
|
JNIEnv* env, jobject jwrite_options, jlong jhandle) {
|
|
|
|
auto write_options = reinterpret_cast<rocksdb::WriteOptions*>(jhandle);
|
|
|
|
delete write_options;
|
|
|
|
|
|
|
|
rocksdb::WriteOptionsJni::setHandle(env, jwrite_options, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteOptions
|
|
|
|
* Method: setSync
|
|
|
|
* Signature: (JZ)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_WriteOptions_setSync(
|
|
|
|
JNIEnv* env, jobject jwrite_options, jlong jhandle, jboolean jflag) {
|
|
|
|
reinterpret_cast<rocksdb::WriteOptions*>(jhandle)->sync = jflag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteOptions
|
|
|
|
* Method: sync
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
|
|
|
jboolean Java_org_rocksdb_WriteOptions_sync(
|
|
|
|
JNIEnv* env, jobject jwrite_options, jlong jhandle) {
|
|
|
|
return reinterpret_cast<rocksdb::WriteOptions*>(jhandle)->sync;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteOptions
|
|
|
|
* Method: setDisableWAL
|
|
|
|
* Signature: (JZ)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_WriteOptions_setDisableWAL(
|
|
|
|
JNIEnv* env, jobject jwrite_options, jlong jhandle, jboolean jflag) {
|
|
|
|
reinterpret_cast<rocksdb::WriteOptions*>(jhandle)->disableWAL = jflag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteOptions
|
|
|
|
* Method: disableWAL
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
|
|
|
jboolean Java_org_rocksdb_WriteOptions_disableWAL(
|
|
|
|
JNIEnv* env, jobject jwrite_options, jlong jhandle) {
|
|
|
|
return reinterpret_cast<rocksdb::WriteOptions*>(jhandle)->disableWAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|