2016-02-09 23:12:00 +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).
|
2014-04-02 20:14:55 +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::WriteBatch methods from Java side.
|
2022-03-01 17:02:15 +00:00
|
|
|
#include "rocksdb/write_batch.h"
|
|
|
|
|
2014-04-02 20:14:55 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2016-06-21 01:01:03 +00:00
|
|
|
#include "db/memtable.h"
|
|
|
|
#include "db/write_batch_internal.h"
|
2014-04-02 20:14:55 +00:00
|
|
|
#include "include/org_rocksdb_WriteBatch.h"
|
2014-10-23 15:19:38 +00:00
|
|
|
#include "include/org_rocksdb_WriteBatch_Handler.h"
|
2019-06-01 00:19:43 +00:00
|
|
|
#include "logging/logging.h"
|
2014-04-02 20:14:55 +00:00
|
|
|
#include "rocksdb/db.h"
|
|
|
|
#include "rocksdb/env.h"
|
|
|
|
#include "rocksdb/memtablerep.h"
|
2016-06-21 01:01:03 +00:00
|
|
|
#include "rocksdb/status.h"
|
|
|
|
#include "rocksdb/write_buffer_manager.h"
|
2022-03-01 17:02:15 +00:00
|
|
|
#include "rocksjni/cplusplus_to_java_convert.h"
|
2016-06-21 01:01:03 +00:00
|
|
|
#include "rocksjni/portal.h"
|
|
|
|
#include "rocksjni/writebatchhandlerjnicallback.h"
|
2015-10-12 22:06:38 +00:00
|
|
|
#include "table/scoped_arena_iterator.h"
|
2014-04-02 20:14:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: newWriteBatch
|
2016-01-20 17:05:41 +00:00
|
|
|
* Signature: (I)J
|
2014-04-02 20:14:55 +00:00
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
jlong Java_org_rocksdb_WriteBatch_newWriteBatch__I(JNIEnv* /*env*/,
|
|
|
|
jclass /*jcls*/,
|
|
|
|
jint jreserved_bytes) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb =
|
|
|
|
new ROCKSDB_NAMESPACE::WriteBatch(static_cast<size_t>(jreserved_bytes));
|
2022-03-01 17:02:15 +00:00
|
|
|
return GET_CPLUSPLUS_POINTER(wb);
|
2014-04-02 20:14:55 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 23:33:08 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: newWriteBatch
|
|
|
|
* Signature: ([BI)J
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
jlong Java_org_rocksdb_WriteBatch_newWriteBatch___3BI(JNIEnv* env,
|
|
|
|
jclass /*jcls*/,
|
|
|
|
jbyteArray jserialized,
|
|
|
|
jint jserialized_length) {
|
2018-03-02 23:33:08 +00:00
|
|
|
jboolean has_exception = JNI_FALSE;
|
2020-02-20 20:07:53 +00:00
|
|
|
std::string serialized = ROCKSDB_NAMESPACE::JniUtil::byteString<std::string>(
|
2018-04-13 00:55:14 +00:00
|
|
|
env, jserialized, jserialized_length,
|
|
|
|
[](const char* str, const size_t len) { return std::string(str, len); },
|
|
|
|
&has_exception);
|
|
|
|
if (has_exception == JNI_TRUE) {
|
2018-03-02 23:33:08 +00:00
|
|
|
// exception occurred
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = new ROCKSDB_NAMESPACE::WriteBatch(serialized);
|
2022-03-01 17:02:15 +00:00
|
|
|
return GET_CPLUSPLUS_POINTER(wb);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
|
|
|
|
2014-04-02 20:14:55 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
2015-01-03 18:36:59 +00:00
|
|
|
* Method: count0
|
2016-02-01 20:00:40 +00:00
|
|
|
* Signature: (J)I
|
2014-04-02 20:14:55 +00:00
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
jint Java_org_rocksdb_WriteBatch_count0(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2014-04-02 20:14:55 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
return static_cast<jint>(wb->Count());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
2015-01-03 18:36:59 +00:00
|
|
|
* Method: clear0
|
2016-02-01 20:00:40 +00:00
|
|
|
* Signature: (J)V
|
2014-04-02 20:14:55 +00:00
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_clear0(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2014-04-02 20:14:55 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
wb->Clear();
|
|
|
|
}
|
|
|
|
|
2016-06-14 16:51:14 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: setSavePoint0
|
|
|
|
* Signature: (J)V
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_setSavePoint0(JNIEnv* /*env*/,
|
|
|
|
jobject /*jobj*/,
|
|
|
|
jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2016-06-14 16:51:14 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
wb->SetSavePoint();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: rollbackToSavePoint0
|
|
|
|
* Signature: (J)V
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_rollbackToSavePoint0(JNIEnv* env,
|
|
|
|
jobject /*jobj*/,
|
|
|
|
jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2016-06-14 16:51:14 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
auto s = wb->RollbackToSavePoint();
|
|
|
|
|
|
|
|
if (s.ok()) {
|
|
|
|
return;
|
|
|
|
}
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
|
2016-06-14 16:51:14 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 23:33:08 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: popSavePoint
|
|
|
|
* Signature: (J)V
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_popSavePoint(JNIEnv* env, jobject /*jobj*/,
|
|
|
|
jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
auto s = wb->PopSavePoint();
|
|
|
|
|
|
|
|
if (s.ok()) {
|
|
|
|
return;
|
|
|
|
}
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: setMaxBytes
|
|
|
|
* Signature: (JJ)V
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_setMaxBytes(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong jwb_handle,
|
|
|
|
jlong jmax_bytes) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
wb->SetMaxBytes(static_cast<size_t>(jmax_bytes));
|
|
|
|
}
|
|
|
|
|
2014-04-02 20:14:55 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
2014-10-13 08:34:52 +00:00
|
|
|
* Method: put
|
2016-02-01 20:00:40 +00:00
|
|
|
* Signature: (J[BI[BI)V
|
2014-04-02 20:14:55 +00:00
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_put__J_3BI_3BI(JNIEnv* env, jobject jobj,
|
|
|
|
jlong jwb_handle,
|
|
|
|
jbyteArray jkey, jint jkey_len,
|
|
|
|
jbyteArray jentry_value,
|
|
|
|
jint jentry_value_len) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2015-01-03 17:52:17 +00:00
|
|
|
assert(wb != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto put = [&wb](ROCKSDB_NAMESPACE::Slice key,
|
|
|
|
ROCKSDB_NAMESPACE::Slice value) {
|
2018-03-02 23:33:08 +00:00
|
|
|
return wb->Put(key, value);
|
2015-01-03 17:52:17 +00:00
|
|
|
};
|
2020-02-20 20:07:53 +00:00
|
|
|
std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::kv_op(put, env, jobj, jkey, jkey_len,
|
|
|
|
jentry_value, jentry_value_len);
|
2018-03-02 23:33:08 +00:00
|
|
|
if (status != nullptr && !status->ok()) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
2014-10-13 08:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: put
|
2016-02-01 20:00:40 +00:00
|
|
|
* Signature: (J[BI[BIJ)V
|
2014-10-13 08:34:52 +00:00
|
|
|
*/
|
2016-02-01 20:00:40 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_put__J_3BI_3BIJ(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* env, jobject jobj, jlong jwb_handle, jbyteArray jkey, jint jkey_len,
|
2014-11-06 22:12:36 +00:00
|
|
|
jbyteArray jentry_value, jint jentry_value_len, jlong jcf_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2014-04-02 20:14:55 +00:00
|
|
|
assert(wb != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* cf_handle =
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
|
2015-01-03 17:52:17 +00:00
|
|
|
assert(cf_handle != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto put = [&wb, &cf_handle](ROCKSDB_NAMESPACE::Slice key,
|
|
|
|
ROCKSDB_NAMESPACE::Slice value) {
|
2018-03-02 23:33:08 +00:00
|
|
|
return wb->Put(cf_handle, key, value);
|
2015-01-03 17:52:17 +00:00
|
|
|
};
|
2020-02-20 20:07:53 +00:00
|
|
|
std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::kv_op(put, env, jobj, jkey, jkey_len,
|
|
|
|
jentry_value, jentry_value_len);
|
2018-03-02 23:33:08 +00:00
|
|
|
if (status != nullptr && !status->ok()) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
2014-04-02 20:14:55 +00:00
|
|
|
}
|
|
|
|
|
2020-02-11 22:45:15 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: putDirect
|
|
|
|
* Signature: (JLjava/nio/ByteBuffer;IILjava/nio/ByteBuffer;IIJ)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_WriteBatch_putDirect(JNIEnv* env, jobject /*jobj*/,
|
|
|
|
jlong jwb_handle, jobject jkey,
|
|
|
|
jint jkey_offset, jint jkey_len,
|
|
|
|
jobject jval, jint jval_offset,
|
|
|
|
jint jval_len, jlong jcf_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2020-02-11 22:45:15 +00:00
|
|
|
assert(wb != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* cf_handle =
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
|
|
|
|
auto put = [&wb, &cf_handle](ROCKSDB_NAMESPACE::Slice& key,
|
|
|
|
ROCKSDB_NAMESPACE::Slice& value) {
|
2020-02-11 22:45:15 +00:00
|
|
|
if (cf_handle == nullptr) {
|
|
|
|
wb->Put(key, value);
|
|
|
|
} else {
|
|
|
|
wb->Put(cf_handle, key, value);
|
|
|
|
}
|
|
|
|
};
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::JniUtil::kv_op_direct(
|
|
|
|
put, env, jkey, jkey_offset, jkey_len, jval, jval_offset, jval_len);
|
2020-02-11 22:45:15 +00:00
|
|
|
}
|
|
|
|
|
2014-04-02 20:14:55 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
2014-10-13 08:34:52 +00:00
|
|
|
* Method: merge
|
2016-02-01 20:00:40 +00:00
|
|
|
* Signature: (J[BI[BI)V
|
2014-04-02 20:14:55 +00:00
|
|
|
*/
|
2016-02-01 20:00:40 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_merge__J_3BI_3BI(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* env, jobject jobj, jlong jwb_handle, jbyteArray jkey, jint jkey_len,
|
2014-11-06 22:12:36 +00:00
|
|
|
jbyteArray jentry_value, jint jentry_value_len) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2015-01-03 17:52:17 +00:00
|
|
|
assert(wb != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto merge = [&wb](ROCKSDB_NAMESPACE::Slice key,
|
|
|
|
ROCKSDB_NAMESPACE::Slice value) {
|
2018-03-02 23:33:08 +00:00
|
|
|
return wb->Merge(key, value);
|
2015-01-03 17:52:17 +00:00
|
|
|
};
|
2020-02-20 20:07:53 +00:00
|
|
|
std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::kv_op(merge, env, jobj, jkey, jkey_len,
|
|
|
|
jentry_value, jentry_value_len);
|
2018-03-02 23:33:08 +00:00
|
|
|
if (status != nullptr && !status->ok()) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
2014-10-13 08:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: merge
|
2016-02-01 20:00:40 +00:00
|
|
|
* Signature: (J[BI[BIJ)V
|
2014-10-13 08:34:52 +00:00
|
|
|
*/
|
2016-02-01 20:00:40 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_merge__J_3BI_3BIJ(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* env, jobject jobj, jlong jwb_handle, jbyteArray jkey, jint jkey_len,
|
2014-11-06 22:12:36 +00:00
|
|
|
jbyteArray jentry_value, jint jentry_value_len, jlong jcf_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2014-04-02 20:14:55 +00:00
|
|
|
assert(wb != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* cf_handle =
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
|
2015-01-03 17:52:17 +00:00
|
|
|
assert(cf_handle != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto merge = [&wb, &cf_handle](ROCKSDB_NAMESPACE::Slice key,
|
|
|
|
ROCKSDB_NAMESPACE::Slice value) {
|
2018-03-02 23:33:08 +00:00
|
|
|
return wb->Merge(cf_handle, key, value);
|
2015-01-03 17:52:17 +00:00
|
|
|
};
|
2020-02-20 20:07:53 +00:00
|
|
|
std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::kv_op(merge, env, jobj, jkey, jkey_len,
|
|
|
|
jentry_value, jentry_value_len);
|
2018-03-02 23:33:08 +00:00
|
|
|
if (status != nullptr && !status->ok()) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
2014-04-02 20:14:55 +00:00
|
|
|
}
|
|
|
|
|
2014-10-13 08:34:52 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
2018-03-02 23:33:08 +00:00
|
|
|
* Method: delete
|
2016-02-01 20:00:40 +00:00
|
|
|
* Signature: (J[BI)V
|
2014-10-13 08:34:52 +00:00
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_delete__J_3BI(JNIEnv* env, jobject jobj,
|
|
|
|
jlong jwb_handle,
|
|
|
|
jbyteArray jkey, jint jkey_len) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2015-01-03 17:52:17 +00:00
|
|
|
assert(wb != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto remove = [&wb](ROCKSDB_NAMESPACE::Slice key) { return wb->Delete(key); };
|
|
|
|
std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::k_op(remove, env, jobj, jkey, jkey_len);
|
2018-03-02 23:33:08 +00:00
|
|
|
if (status != nullptr && !status->ok()) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
2014-10-13 08:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
2018-03-02 23:33:08 +00:00
|
|
|
* Method: delete
|
2016-02-01 20:00:40 +00:00
|
|
|
* Signature: (J[BIJ)V
|
2014-10-13 08:34:52 +00:00
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_delete__J_3BIJ(JNIEnv* env, jobject jobj,
|
|
|
|
jlong jwb_handle,
|
|
|
|
jbyteArray jkey, jint jkey_len,
|
|
|
|
jlong jcf_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2015-01-03 17:52:17 +00:00
|
|
|
assert(wb != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* cf_handle =
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
|
2015-01-03 17:52:17 +00:00
|
|
|
assert(cf_handle != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto remove = [&wb, &cf_handle](ROCKSDB_NAMESPACE::Slice key) {
|
2018-03-02 23:33:08 +00:00
|
|
|
return wb->Delete(cf_handle, key);
|
|
|
|
};
|
2020-02-20 20:07:53 +00:00
|
|
|
std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::k_op(remove, env, jobj, jkey, jkey_len);
|
2018-03-02 23:33:08 +00:00
|
|
|
if (status != nullptr && !status->ok()) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: singleDelete
|
|
|
|
* Signature: (J[BI)V
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_singleDelete__J_3BI(JNIEnv* env, jobject jobj,
|
|
|
|
jlong jwb_handle,
|
|
|
|
jbyteArray jkey,
|
|
|
|
jint jkey_len) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto single_delete = [&wb](ROCKSDB_NAMESPACE::Slice key) {
|
2018-03-02 23:33:08 +00:00
|
|
|
return wb->SingleDelete(key);
|
|
|
|
};
|
2020-02-20 20:07:53 +00:00
|
|
|
std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::k_op(single_delete, env, jobj, jkey,
|
|
|
|
jkey_len);
|
2018-03-02 23:33:08 +00:00
|
|
|
if (status != nullptr && !status->ok()) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: singleDelete
|
|
|
|
* Signature: (J[BIJ)V
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_singleDelete__J_3BIJ(JNIEnv* env, jobject jobj,
|
|
|
|
jlong jwb_handle,
|
|
|
|
jbyteArray jkey,
|
|
|
|
jint jkey_len,
|
|
|
|
jlong jcf_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* cf_handle =
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(cf_handle != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto single_delete = [&wb, &cf_handle](ROCKSDB_NAMESPACE::Slice key) {
|
2018-03-02 23:33:08 +00:00
|
|
|
return wb->SingleDelete(cf_handle, key);
|
2015-01-03 17:52:17 +00:00
|
|
|
};
|
2020-02-20 20:07:53 +00:00
|
|
|
std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::k_op(single_delete, env, jobj, jkey,
|
|
|
|
jkey_len);
|
2018-03-02 23:33:08 +00:00
|
|
|
if (status != nullptr && !status->ok()) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
2014-10-13 08:34:52 +00:00
|
|
|
}
|
|
|
|
|
2020-02-11 22:45:15 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
2021-12-10 17:16:47 +00:00
|
|
|
* Method: deleteDirect
|
2020-02-11 22:45:15 +00:00
|
|
|
* Signature: (JLjava/nio/ByteBuffer;IIJ)V
|
|
|
|
*/
|
2021-12-10 17:16:47 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_deleteDirect(JNIEnv* env, jobject /*jobj*/,
|
2020-02-11 22:45:15 +00:00
|
|
|
jlong jwb_handle, jobject jkey,
|
|
|
|
jint jkey_offset, jint jkey_len,
|
|
|
|
jlong jcf_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2020-02-11 22:45:15 +00:00
|
|
|
assert(wb != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* cf_handle =
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
|
|
|
|
auto remove = [&wb, &cf_handle](ROCKSDB_NAMESPACE::Slice& key) {
|
2020-02-11 22:45:15 +00:00
|
|
|
if (cf_handle == nullptr) {
|
|
|
|
wb->Delete(key);
|
|
|
|
} else {
|
|
|
|
wb->Delete(cf_handle, key);
|
|
|
|
}
|
|
|
|
};
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::JniUtil::k_op_direct(remove, env, jkey, jkey_offset,
|
|
|
|
jkey_len);
|
2020-02-11 22:45:15 +00:00
|
|
|
}
|
|
|
|
|
2017-03-07 06:13:53 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: deleteRange
|
|
|
|
* Signature: (J[BI[BI)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_WriteBatch_deleteRange__J_3BI_3BI(
|
|
|
|
JNIEnv* env, jobject jobj, jlong jwb_handle, jbyteArray jbegin_key,
|
|
|
|
jint jbegin_key_len, jbyteArray jend_key, jint jend_key_len) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2017-03-07 06:13:53 +00:00
|
|
|
assert(wb != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto deleteRange = [&wb](ROCKSDB_NAMESPACE::Slice beginKey,
|
|
|
|
ROCKSDB_NAMESPACE::Slice endKey) {
|
2018-03-02 23:33:08 +00:00
|
|
|
return wb->DeleteRange(beginKey, endKey);
|
2017-03-07 06:13:53 +00:00
|
|
|
};
|
2020-02-20 20:07:53 +00:00
|
|
|
std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::kv_op(deleteRange, env, jobj, jbegin_key,
|
|
|
|
jbegin_key_len, jend_key, jend_key_len);
|
2018-03-02 23:33:08 +00:00
|
|
|
if (status != nullptr && !status->ok()) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
2017-03-07 06:13:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: deleteRange
|
|
|
|
* Signature: (J[BI[BIJ)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_WriteBatch_deleteRange__J_3BI_3BIJ(
|
|
|
|
JNIEnv* env, jobject jobj, jlong jwb_handle, jbyteArray jbegin_key,
|
|
|
|
jint jbegin_key_len, jbyteArray jend_key, jint jend_key_len,
|
|
|
|
jlong jcf_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2017-03-07 06:13:53 +00:00
|
|
|
assert(wb != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* cf_handle =
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
|
2017-03-07 06:13:53 +00:00
|
|
|
assert(cf_handle != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto deleteRange = [&wb, &cf_handle](ROCKSDB_NAMESPACE::Slice beginKey,
|
|
|
|
ROCKSDB_NAMESPACE::Slice endKey) {
|
2018-03-02 23:33:08 +00:00
|
|
|
return wb->DeleteRange(cf_handle, beginKey, endKey);
|
2017-03-07 06:13:53 +00:00
|
|
|
};
|
2020-02-20 20:07:53 +00:00
|
|
|
std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::kv_op(deleteRange, env, jobj, jbegin_key,
|
|
|
|
jbegin_key_len, jend_key, jend_key_len);
|
2018-03-02 23:33:08 +00:00
|
|
|
if (status != nullptr && !status->ok()) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
2017-03-07 06:13:53 +00:00
|
|
|
}
|
|
|
|
|
2014-04-02 20:14:55 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: putLogData
|
2016-02-01 20:00:40 +00:00
|
|
|
* Signature: (J[BI)V
|
2014-04-02 20:14:55 +00:00
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_putLogData(JNIEnv* env, jobject jobj,
|
|
|
|
jlong jwb_handle, jbyteArray jblob,
|
|
|
|
jint jblob_len) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2014-04-02 20:14:55 +00:00
|
|
|
assert(wb != nullptr);
|
2020-02-20 20:07:53 +00:00
|
|
|
auto putLogData = [&wb](ROCKSDB_NAMESPACE::Slice blob) {
|
|
|
|
return wb->PutLogData(blob);
|
|
|
|
};
|
|
|
|
std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
|
|
|
|
ROCKSDB_NAMESPACE::JniUtil::k_op(putLogData, env, jobj, jblob, jblob_len);
|
2018-03-02 23:33:08 +00:00
|
|
|
if (status != nullptr && !status->ok()) {
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
2014-04-02 20:14:55 +00:00
|
|
|
}
|
|
|
|
|
2014-10-23 15:19:38 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: iterate
|
2016-02-01 20:00:40 +00:00
|
|
|
* Signature: (JJ)V
|
2014-10-23 15:19:38 +00:00
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_iterate(JNIEnv* env, jobject /*jobj*/,
|
|
|
|
jlong jwb_handle,
|
|
|
|
jlong handlerHandle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2014-10-23 15:19:38 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::Status s = wb->Iterate(
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchHandlerJniCallback*>(
|
|
|
|
handlerHandle));
|
2014-10-23 15:19:38 +00:00
|
|
|
|
|
|
|
if (s.ok()) {
|
|
|
|
return;
|
|
|
|
}
|
2020-02-20 20:07:53 +00:00
|
|
|
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
|
2014-10-23 15:19:38 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 23:33:08 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: data
|
|
|
|
* Signature: (J)[B
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
jbyteArray Java_org_rocksdb_WriteBatch_data(JNIEnv* env, jobject /*jobj*/,
|
|
|
|
jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
auto data = wb->Data();
|
2020-02-20 20:07:53 +00:00
|
|
|
return ROCKSDB_NAMESPACE::JniUtil::copyBytes(env, data);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: getDataSize
|
|
|
|
* Signature: (J)J
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
jlong Java_org_rocksdb_WriteBatch_getDataSize(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
auto data_size = wb->GetDataSize();
|
|
|
|
return static_cast<jlong>(data_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: hasPut
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
jboolean Java_org_rocksdb_WriteBatch_hasPut(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
return wb->HasPut();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: hasDelete
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
jboolean Java_org_rocksdb_WriteBatch_hasDelete(JNIEnv* /*env*/,
|
|
|
|
jobject /*jobj*/,
|
|
|
|
jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
return wb->HasDelete();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: hasSingleDelete
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
|
|
|
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasSingleDelete(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
return wb->HasSingleDelete();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: hasDeleteRange
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
|
|
|
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasDeleteRange(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
return wb->HasDeleteRange();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: hasMerge
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
|
|
|
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasMerge(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
return wb->HasMerge();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: hasBeginPrepare
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
|
|
|
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasBeginPrepare(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
return wb->HasBeginPrepare();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: hasEndPrepare
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
|
|
|
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasEndPrepare(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
return wb->HasEndPrepare();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: hasCommit
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
|
|
|
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasCommit(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
return wb->HasCommit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: hasRollback
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
|
|
|
JNIEXPORT jboolean JNICALL Java_org_rocksdb_WriteBatch_hasRollback(
|
2018-04-13 00:55:14 +00:00
|
|
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
return wb->HasRollback();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: markWalTerminationPoint
|
|
|
|
* Signature: (J)V
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_markWalTerminationPoint(JNIEnv* /*env*/,
|
|
|
|
jobject /*jobj*/,
|
|
|
|
jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
wb->MarkWalTerminationPoint();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
|
|
|
* Method: getWalTerminationPoint
|
|
|
|
* Signature: (J)Lorg/rocksdb/WriteBatch/SavePoint;
|
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
jobject Java_org_rocksdb_WriteBatch_getWalTerminationPoint(JNIEnv* env,
|
|
|
|
jobject /*jobj*/,
|
|
|
|
jlong jwb_handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
|
2018-03-02 23:33:08 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
|
|
|
|
auto save_point = wb->GetWalTerminationPoint();
|
2020-02-20 20:07:53 +00:00
|
|
|
return ROCKSDB_NAMESPACE::WriteBatchSavePointJni::construct(env, save_point);
|
2018-03-02 23:33:08 +00:00
|
|
|
}
|
|
|
|
|
2014-04-02 20:14:55 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch
|
[Java] Generalize dis-own native handle and refine dispose framework.
Summary:
1. Move disOwnNativeHandle() function from RocksDB to RocksObject
to allow other RocksObject to use disOwnNativeHandle() when its
ownership of native handle has been transferred.
2. RocksObject now has an abstract implementation of dispose(),
which does the following two things. First, it checks whether
both isOwningNativeHandle() and isInitialized() return true.
If so, it will call the protected abstract function dispose0(),
which all the subclasses of RocksObject should implement. Second,
it sets nativeHandle_ = 0. This redesign ensure all subclasses
of RocksObject have the same dispose behavior.
3. All subclasses of RocksObject now should implement dispose0()
instead of dispose(), and dispose0() will be called only when
isInitialized() returns true.
Test Plan:
make rocksdbjava
make jtest
Reviewers: dhruba, sdong, ankgup87, rsumbaly, swapnilghike, zzbennett, haobo
Reviewed By: haobo
Subscribers: leveldb
Differential Revision: https://reviews.facebook.net/D18801
2014-05-29 01:16:29 +00:00
|
|
|
* Method: disposeInternal
|
|
|
|
* Signature: (J)V
|
2014-04-02 20:14:55 +00:00
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
void Java_org_rocksdb_WriteBatch_disposeInternal(JNIEnv* /*env*/,
|
|
|
|
jobject /*jobj*/,
|
|
|
|
jlong handle) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(handle);
|
2017-02-28 00:26:12 +00:00
|
|
|
assert(wb != nullptr);
|
|
|
|
delete wb;
|
2014-04-02 20:14:55 +00:00
|
|
|
}
|
|
|
|
|
2014-10-23 15:19:38 +00:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_WriteBatch_Handler
|
|
|
|
* Method: createNewHandler0
|
2016-01-20 17:05:41 +00:00
|
|
|
* Signature: ()J
|
2014-10-23 15:19:38 +00:00
|
|
|
*/
|
2018-04-13 00:55:14 +00:00
|
|
|
jlong Java_org_rocksdb_WriteBatch_00024Handler_createNewHandler0(JNIEnv* env,
|
|
|
|
jobject jobj) {
|
2020-02-20 20:07:53 +00:00
|
|
|
auto* wbjnic = new ROCKSDB_NAMESPACE::WriteBatchHandlerJniCallback(env, jobj);
|
2022-03-01 17:02:15 +00:00
|
|
|
return GET_CPLUSPLUS_POINTER(wbjnic);
|
2014-10-23 15:19:38 +00:00
|
|
|
}
|