2016-02-10 00:12:00 +01:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-16 01:03:42 +02: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-08-03 22:11:44 +02:00
|
|
|
//
|
|
|
|
// This file implements the "bridge" between Java and C++ for
|
2020-02-20 21:07:53 +01:00
|
|
|
// ROCKSDB_NAMESPACE::Slice.
|
2014-08-03 22:11:44 +02:00
|
|
|
|
2018-04-13 02:55:14 +02:00
|
|
|
#include <jni.h>
|
2014-08-03 22:11:44 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "include/org_rocksdb_AbstractSlice.h"
|
|
|
|
#include "include/org_rocksdb_DirectSlice.h"
|
2018-04-13 02:55:14 +02:00
|
|
|
#include "include/org_rocksdb_Slice.h"
|
2014-08-03 22:11:44 +02:00
|
|
|
#include "rocksdb/slice.h"
|
|
|
|
#include "rocksjni/portal.h"
|
|
|
|
|
2014-08-21 22:55:51 +02:00
|
|
|
// <editor-fold desc="org.rocksdb.AbstractSlice>
|
2014-08-03 22:11:44 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_AbstractSlice
|
|
|
|
* Method: createNewSliceFromString
|
2016-01-20 18:05:41 +01:00
|
|
|
* Signature: (Ljava/lang/String;)J
|
2014-08-03 22:11:44 +02:00
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
jlong Java_org_rocksdb_AbstractSlice_createNewSliceFromString(JNIEnv* env,
|
|
|
|
jclass /*jcls*/,
|
|
|
|
jstring jstr) {
|
2017-02-28 01:26:12 +01:00
|
|
|
const auto* str = env->GetStringUTFChars(jstr, nullptr);
|
2018-04-13 02:55:14 +02:00
|
|
|
if (str == nullptr) {
|
2017-02-28 01:26:12 +01:00
|
|
|
// exception thrown: OutOfMemoryError
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-01-17 01:22:29 +01:00
|
|
|
const size_t len = strlen(str);
|
2017-02-28 01:26:12 +01:00
|
|
|
|
|
|
|
// NOTE: buf will be deleted in the
|
|
|
|
// Java_org_rocksdb_Slice_disposeInternalBuf or
|
|
|
|
// or Java_org_rocksdb_DirectSlice_disposeInternalBuf methods
|
2015-01-17 01:22:29 +01:00
|
|
|
char* buf = new char[len + 1];
|
|
|
|
memcpy(buf, str, len);
|
|
|
|
buf[len] = 0;
|
2014-12-10 00:37:08 +01:00
|
|
|
env->ReleaseStringUTFChars(jstr, str);
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = new ROCKSDB_NAMESPACE::Slice(buf);
|
2016-01-20 18:05:41 +01:00
|
|
|
return reinterpret_cast<jlong>(slice);
|
2014-08-03 22:11:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_AbstractSlice
|
|
|
|
* Method: size0
|
|
|
|
* Signature: (J)I
|
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
jint Java_org_rocksdb_AbstractSlice_size0(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong handle) {
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2014-11-11 22:47:22 +01:00
|
|
|
return static_cast<jint>(slice->size());
|
2014-08-03 22:11:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_AbstractSlice
|
|
|
|
* Method: empty0
|
|
|
|
* Signature: (J)Z
|
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
jboolean Java_org_rocksdb_AbstractSlice_empty0(JNIEnv* /*env*/,
|
|
|
|
jobject /*jobj*/, jlong handle) {
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2014-08-03 22:11:44 +02:00
|
|
|
return slice->empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_AbstractSlice
|
|
|
|
* Method: toString0
|
|
|
|
* Signature: (JZ)Ljava/lang/String;
|
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
jstring Java_org_rocksdb_AbstractSlice_toString0(JNIEnv* env, jobject /*jobj*/,
|
|
|
|
jlong handle, jboolean hex) {
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2014-08-03 22:11:44 +02:00
|
|
|
const std::string s = slice->ToString(hex);
|
|
|
|
return env->NewStringUTF(s.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_AbstractSlice
|
|
|
|
* Method: compare0
|
|
|
|
* Signature: (JJ)I;
|
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
jint Java_org_rocksdb_AbstractSlice_compare0(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong handle, jlong otherHandle) {
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
|
|
|
const auto* otherSlice =
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(otherHandle);
|
2014-08-03 22:11:44 +02:00
|
|
|
return slice->compare(*otherSlice);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_AbstractSlice
|
|
|
|
* Method: startsWith0
|
|
|
|
* Signature: (JJ)Z;
|
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
jboolean Java_org_rocksdb_AbstractSlice_startsWith0(JNIEnv* /*env*/,
|
|
|
|
jobject /*jobj*/,
|
|
|
|
jlong handle,
|
|
|
|
jlong otherHandle) {
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
|
|
|
const auto* otherSlice =
|
|
|
|
reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(otherHandle);
|
2014-08-03 22:11:44 +02:00
|
|
|
return slice->starts_with(*otherSlice);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_AbstractSlice
|
|
|
|
* Method: disposeInternal
|
|
|
|
* Signature: (J)V
|
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
void Java_org_rocksdb_AbstractSlice_disposeInternal(JNIEnv* /*env*/,
|
|
|
|
jobject /*jobj*/,
|
|
|
|
jlong handle) {
|
2020-02-20 21:07:53 +01:00
|
|
|
delete reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2014-08-03 22:11:44 +02:00
|
|
|
}
|
|
|
|
|
2014-08-21 22:55:51 +02:00
|
|
|
// </editor-fold>
|
2014-08-03 22:11:44 +02:00
|
|
|
|
2014-08-21 22:55:51 +02:00
|
|
|
// <editor-fold desc="org.rocksdb.Slice>
|
2014-08-03 22:11:44 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Slice
|
|
|
|
* Method: createNewSlice0
|
2016-01-20 18:05:41 +01:00
|
|
|
* Signature: ([BI)J
|
2014-08-03 22:11:44 +02:00
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
jlong Java_org_rocksdb_Slice_createNewSlice0(JNIEnv* env, jclass /*jcls*/,
|
|
|
|
jbyteArray data, jint offset) {
|
2014-08-03 22:11:44 +02:00
|
|
|
const jsize dataSize = env->GetArrayLength(data);
|
|
|
|
const int len = dataSize - offset;
|
|
|
|
|
2018-04-13 02:55:14 +02:00
|
|
|
// NOTE: buf will be deleted in the Java_org_rocksdb_Slice_disposeInternalBuf
|
|
|
|
// method
|
2017-02-28 01:26:12 +01:00
|
|
|
jbyte* buf = new jbyte[len];
|
|
|
|
env->GetByteArrayRegion(data, offset, len, buf);
|
2018-04-13 02:55:14 +02:00
|
|
|
if (env->ExceptionCheck()) {
|
2017-02-28 01:26:12 +01:00
|
|
|
// exception thrown: ArrayIndexOutOfBoundsException
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = new ROCKSDB_NAMESPACE::Slice((const char*)buf, len);
|
2016-01-20 18:05:41 +01:00
|
|
|
return reinterpret_cast<jlong>(slice);
|
2014-08-03 22:11:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Slice
|
|
|
|
* Method: createNewSlice1
|
2016-01-20 18:05:41 +01:00
|
|
|
* Signature: ([B)J
|
2014-08-03 22:11:44 +02:00
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
jlong Java_org_rocksdb_Slice_createNewSlice1(JNIEnv* env, jclass /*jcls*/,
|
|
|
|
jbyteArray data) {
|
2017-02-28 01:26:12 +01:00
|
|
|
jbyte* ptrData = env->GetByteArrayElements(data, nullptr);
|
2018-04-13 02:55:14 +02:00
|
|
|
if (ptrData == nullptr) {
|
2017-02-28 01:26:12 +01:00
|
|
|
// exception thrown: OutOfMemoryError
|
|
|
|
return 0;
|
|
|
|
}
|
2014-12-10 00:37:08 +01:00
|
|
|
const int len = env->GetArrayLength(data) + 1;
|
2014-08-15 15:42:03 +02:00
|
|
|
|
2018-04-13 02:55:14 +02:00
|
|
|
// NOTE: buf will be deleted in the Java_org_rocksdb_Slice_disposeInternalBuf
|
|
|
|
// method
|
2016-01-20 18:05:41 +01:00
|
|
|
char* buf = new char[len];
|
2014-12-10 00:37:08 +01:00
|
|
|
memcpy(buf, ptrData, len - 1);
|
2018-04-13 02:55:14 +02:00
|
|
|
buf[len - 1] = '\0';
|
2014-08-03 22:11:44 +02:00
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = new ROCKSDB_NAMESPACE::Slice(buf, len - 1);
|
2014-08-03 22:11:44 +02:00
|
|
|
|
2014-08-15 15:42:03 +02:00
|
|
|
env->ReleaseByteArrayElements(data, ptrData, JNI_ABORT);
|
2016-01-20 18:05:41 +01:00
|
|
|
|
|
|
|
return reinterpret_cast<jlong>(slice);
|
2014-08-03 22:11:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Slice
|
|
|
|
* Method: data0
|
|
|
|
* Signature: (J)[B
|
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
jbyteArray Java_org_rocksdb_Slice_data0(JNIEnv* env, jobject /*jobj*/,
|
|
|
|
jlong handle) {
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2017-02-28 01:26:12 +01:00
|
|
|
const jsize len = static_cast<jsize>(slice->size());
|
2014-08-03 22:11:44 +02:00
|
|
|
const jbyteArray data = env->NewByteArray(len);
|
2018-04-13 02:55:14 +02:00
|
|
|
if (data == nullptr) {
|
2017-02-28 01:26:12 +01:00
|
|
|
// exception thrown: OutOfMemoryError
|
|
|
|
return nullptr;
|
|
|
|
}
|
2018-04-13 02:55:14 +02:00
|
|
|
|
|
|
|
env->SetByteArrayRegion(
|
|
|
|
data, 0, len,
|
|
|
|
const_cast<jbyte*>(reinterpret_cast<const jbyte*>(slice->data())));
|
|
|
|
if (env->ExceptionCheck()) {
|
2017-02-28 01:26:12 +01:00
|
|
|
// exception thrown: ArrayIndexOutOfBoundsException
|
|
|
|
env->DeleteLocalRef(data);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-08-03 22:11:44 +02:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2017-02-28 01:26:12 +01:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Slice
|
|
|
|
* Method: clear0
|
|
|
|
* Signature: (JZJ)V
|
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
void Java_org_rocksdb_Slice_clear0(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong handle, jboolean shouldRelease,
|
|
|
|
jlong internalBufferOffset) {
|
2020-02-20 21:07:53 +01:00
|
|
|
auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2018-04-13 02:55:14 +02:00
|
|
|
if (shouldRelease == JNI_TRUE) {
|
2017-02-28 01:26:12 +01:00
|
|
|
const char* buf = slice->data_ - internalBufferOffset;
|
2018-04-13 02:55:14 +02:00
|
|
|
delete[] buf;
|
2017-02-28 01:26:12 +01:00
|
|
|
}
|
|
|
|
slice->clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Slice
|
|
|
|
* Method: removePrefix0
|
|
|
|
* Signature: (JI)V
|
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
void Java_org_rocksdb_Slice_removePrefix0(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong handle, jint length) {
|
2020-02-20 21:07:53 +01:00
|
|
|
auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2017-02-28 01:26:12 +01:00
|
|
|
slice->remove_prefix(length);
|
|
|
|
}
|
|
|
|
|
2021-01-16 02:03:11 +01:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_DirectSlice
|
|
|
|
* Method: setLength0
|
|
|
|
* Signature: (JI)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_DirectSlice_setLength0(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong handle, jint length) {
|
2021-07-16 02:22:49 +02:00
|
|
|
auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2021-01-16 02:03:11 +01:00
|
|
|
slice->size_ = length;
|
|
|
|
}
|
|
|
|
|
2014-08-15 15:42:03 +02:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_Slice
|
|
|
|
* Method: disposeInternalBuf
|
2017-02-28 01:26:12 +01:00
|
|
|
* Signature: (JJ)V
|
2014-08-15 15:42:03 +02:00
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
void Java_org_rocksdb_Slice_disposeInternalBuf(JNIEnv* /*env*/,
|
|
|
|
jobject /*jobj*/, jlong handle,
|
|
|
|
jlong internalBufferOffset) {
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2017-02-28 01:26:12 +01:00
|
|
|
const char* buf = slice->data_ - internalBufferOffset;
|
2018-04-13 02:55:14 +02:00
|
|
|
delete[] buf;
|
2014-08-15 15:42:03 +02:00
|
|
|
}
|
|
|
|
|
2014-12-14 21:34:37 +01:00
|
|
|
// </editor-fold>
|
|
|
|
|
|
|
|
// <editor-fold desc="org.rocksdb.DirectSlice>
|
|
|
|
|
2014-08-03 22:11:44 +02:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_DirectSlice
|
|
|
|
* Method: createNewDirectSlice0
|
2016-01-20 18:05:41 +01:00
|
|
|
* Signature: (Ljava/nio/ByteBuffer;I)J
|
2014-08-03 22:11:44 +02:00
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
jlong Java_org_rocksdb_DirectSlice_createNewDirectSlice0(JNIEnv* env,
|
|
|
|
jclass /*jcls*/,
|
|
|
|
jobject data,
|
|
|
|
jint length) {
|
2017-02-28 01:26:12 +01:00
|
|
|
assert(data != nullptr);
|
|
|
|
void* data_addr = env->GetDirectBufferAddress(data);
|
2018-04-13 02:55:14 +02:00
|
|
|
if (data_addr == nullptr) {
|
2017-02-28 01:26:12 +01:00
|
|
|
// error: memory region is undefined, given object is not a direct
|
|
|
|
// java.nio.Buffer, or JNI access to direct buffers is not supported by JVM
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::IllegalArgumentExceptionJni::ThrowNew(
|
|
|
|
env, ROCKSDB_NAMESPACE::Status::InvalidArgument(
|
|
|
|
"Could not access DirectBuffer"));
|
2017-02-28 01:26:12 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-13 02:55:14 +02:00
|
|
|
const auto* ptrData = reinterpret_cast<char*>(data_addr);
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = new ROCKSDB_NAMESPACE::Slice(ptrData, length);
|
2016-01-20 18:05:41 +01:00
|
|
|
return reinterpret_cast<jlong>(slice);
|
2014-08-03 22:11:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_DirectSlice
|
|
|
|
* Method: createNewDirectSlice1
|
2016-01-20 18:05:41 +01:00
|
|
|
* Signature: (Ljava/nio/ByteBuffer;)J
|
2014-08-03 22:11:44 +02:00
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
jlong Java_org_rocksdb_DirectSlice_createNewDirectSlice1(JNIEnv* env,
|
|
|
|
jclass /*jcls*/,
|
|
|
|
jobject data) {
|
2017-02-28 01:26:12 +01:00
|
|
|
void* data_addr = env->GetDirectBufferAddress(data);
|
2018-04-13 02:55:14 +02:00
|
|
|
if (data_addr == nullptr) {
|
2017-02-28 01:26:12 +01:00
|
|
|
// error: memory region is undefined, given object is not a direct
|
|
|
|
// java.nio.Buffer, or JNI access to direct buffers is not supported by JVM
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::IllegalArgumentExceptionJni::ThrowNew(
|
|
|
|
env, ROCKSDB_NAMESPACE::Status::InvalidArgument(
|
|
|
|
"Could not access DirectBuffer"));
|
2017-02-28 01:26:12 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto* ptrData = reinterpret_cast<char*>(data_addr);
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = new ROCKSDB_NAMESPACE::Slice(ptrData);
|
2016-01-20 18:05:41 +01:00
|
|
|
return reinterpret_cast<jlong>(slice);
|
2014-08-03 22:11:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_DirectSlice
|
|
|
|
* Method: data0
|
|
|
|
* Signature: (J)Ljava/lang/Object;
|
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
jobject Java_org_rocksdb_DirectSlice_data0(JNIEnv* env, jobject /*jobj*/,
|
|
|
|
jlong handle) {
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2014-08-21 22:55:51 +02:00
|
|
|
return env->NewDirectByteBuffer(const_cast<char*>(slice->data()),
|
2018-04-13 02:55:14 +02:00
|
|
|
slice->size());
|
2014-08-03 22:11:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_DirectSlice
|
|
|
|
* Method: get0
|
|
|
|
* Signature: (JI)B
|
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
jbyte Java_org_rocksdb_DirectSlice_get0(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong handle, jint offset) {
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2014-12-18 22:27:50 +01:00
|
|
|
return (*slice)[offset];
|
2014-08-03 22:11:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_DirectSlice
|
|
|
|
* Method: clear0
|
2017-02-28 01:26:12 +01:00
|
|
|
* Signature: (JZJ)V
|
2014-08-03 22:11:44 +02:00
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
void Java_org_rocksdb_DirectSlice_clear0(JNIEnv* /*env*/, jobject /*jobj*/,
|
|
|
|
jlong handle, jboolean shouldRelease,
|
|
|
|
jlong internalBufferOffset) {
|
2020-02-20 21:07:53 +01:00
|
|
|
auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2018-04-13 02:55:14 +02:00
|
|
|
if (shouldRelease == JNI_TRUE) {
|
2017-02-28 01:26:12 +01:00
|
|
|
const char* buf = slice->data_ - internalBufferOffset;
|
2018-04-13 02:55:14 +02:00
|
|
|
delete[] buf;
|
2017-02-28 01:26:12 +01:00
|
|
|
}
|
2014-08-03 22:11:44 +02:00
|
|
|
slice->clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_DirectSlice
|
|
|
|
* Method: removePrefix0
|
|
|
|
* Signature: (JI)V
|
|
|
|
*/
|
2018-04-13 02:55:14 +02:00
|
|
|
void Java_org_rocksdb_DirectSlice_removePrefix0(JNIEnv* /*env*/,
|
|
|
|
jobject /*jobj*/, jlong handle,
|
|
|
|
jint length) {
|
2020-02-20 21:07:53 +01:00
|
|
|
auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2014-08-03 22:11:44 +02:00
|
|
|
slice->remove_prefix(length);
|
|
|
|
}
|
|
|
|
|
2017-02-28 01:26:12 +01:00
|
|
|
/*
|
|
|
|
* Class: org_rocksdb_DirectSlice
|
|
|
|
* Method: disposeInternalBuf
|
|
|
|
* Signature: (JJ)V
|
|
|
|
*/
|
|
|
|
void Java_org_rocksdb_DirectSlice_disposeInternalBuf(
|
2018-04-13 02:55:14 +02:00
|
|
|
JNIEnv* /*env*/, jobject /*jobj*/, jlong handle,
|
|
|
|
jlong internalBufferOffset) {
|
2020-02-20 21:07:53 +01:00
|
|
|
const auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
|
2017-02-28 01:26:12 +01:00
|
|
|
const char* buf = slice->data_ - internalBufferOffset;
|
2018-04-13 02:55:14 +02:00
|
|
|
delete[] buf;
|
2017-02-28 01:26:12 +01:00
|
|
|
}
|
|
|
|
|
2014-08-21 22:55:51 +02:00
|
|
|
// </editor-fold>
|