]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/java/rocksjni/write_batch_with_index.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / java / rocksjni / write_batch_with_index.cc
CommitLineData
7c673cae 1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
11fdf7f2
TL
2// This source code is licensed under both the GPLv2 (found in the
3// COPYING file in the root directory) and Apache 2.0 License
4// (found in the LICENSE.Apache file in the root directory).
7c673cae
FG
5//
6// This file implements the "bridge" between Java and C++ and enables
f67539c2 7// calling c++ ROCKSDB_NAMESPACE::WriteBatchWithIndex methods from Java side.
7c673cae 8
11fdf7f2 9#include "rocksdb/utilities/write_batch_with_index.h"
1e59de90 10
7c673cae
FG
11#include "include/org_rocksdb_WBWIRocksIterator.h"
12#include "include/org_rocksdb_WriteBatchWithIndex.h"
13#include "rocksdb/comparator.h"
1e59de90 14#include "rocksjni/cplusplus_to_java_convert.h"
7c673cae
FG
15#include "rocksjni/portal.h"
16
17/*
18 * Class: org_rocksdb_WriteBatchWithIndex
19 * Method: newWriteBatchWithIndex
20 * Signature: ()J
21 */
22jlong Java_org_rocksdb_WriteBatchWithIndex_newWriteBatchWithIndex__(
11fdf7f2 23 JNIEnv* /*env*/, jclass /*jcls*/) {
f67539c2 24 auto* wbwi = new ROCKSDB_NAMESPACE::WriteBatchWithIndex();
1e59de90 25 return GET_CPLUSPLUS_POINTER(wbwi);
7c673cae
FG
26}
27
28/*
29 * Class: org_rocksdb_WriteBatchWithIndex
30 * Method: newWriteBatchWithIndex
31 * Signature: (Z)J
32 */
33jlong Java_org_rocksdb_WriteBatchWithIndex_newWriteBatchWithIndex__Z(
11fdf7f2 34 JNIEnv* /*env*/, jclass /*jcls*/, jboolean joverwrite_key) {
f67539c2
TL
35 auto* wbwi = new ROCKSDB_NAMESPACE::WriteBatchWithIndex(
36 ROCKSDB_NAMESPACE::BytewiseComparator(), 0,
37 static_cast<bool>(joverwrite_key));
1e59de90 38 return GET_CPLUSPLUS_POINTER(wbwi);
7c673cae
FG
39}
40
41/*
42 * Class: org_rocksdb_WriteBatchWithIndex
43 * Method: newWriteBatchWithIndex
11fdf7f2
TL
44 * Signature: (JBIZ)J
45 */
46jlong Java_org_rocksdb_WriteBatchWithIndex_newWriteBatchWithIndex__JBIZ(
47 JNIEnv* /*env*/, jclass /*jcls*/, jlong jfallback_index_comparator_handle,
48 jbyte jcomparator_type, jint jreserved_bytes, jboolean joverwrite_key) {
f67539c2 49 ROCKSDB_NAMESPACE::Comparator* fallback_comparator = nullptr;
11fdf7f2
TL
50 switch (jcomparator_type) {
51 // JAVA_COMPARATOR
52 case 0x0:
11fdf7f2 53 fallback_comparator =
f67539c2 54 reinterpret_cast<ROCKSDB_NAMESPACE::ComparatorJniCallback*>(
11fdf7f2
TL
55 jfallback_index_comparator_handle);
56 break;
57
58 // JAVA_NATIVE_COMPARATOR_WRAPPER
f67539c2
TL
59 case 0x1:
60 fallback_comparator = reinterpret_cast<ROCKSDB_NAMESPACE::Comparator*>(
11fdf7f2
TL
61 jfallback_index_comparator_handle);
62 break;
63 }
f67539c2 64 auto* wbwi = new ROCKSDB_NAMESPACE::WriteBatchWithIndex(
11fdf7f2
TL
65 fallback_comparator, static_cast<size_t>(jreserved_bytes),
66 static_cast<bool>(joverwrite_key));
1e59de90 67 return GET_CPLUSPLUS_POINTER(wbwi);
7c673cae
FG
68}
69
70/*
71 * Class: org_rocksdb_WriteBatchWithIndex
72 * Method: count0
73 * Signature: (J)I
74 */
11fdf7f2
TL
75jint Java_org_rocksdb_WriteBatchWithIndex_count0(JNIEnv* /*env*/,
76 jobject /*jobj*/,
77 jlong jwbwi_handle) {
f67539c2
TL
78 auto* wbwi =
79 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae
FG
80 assert(wbwi != nullptr);
81
82 return static_cast<jint>(wbwi->GetWriteBatch()->Count());
83}
84
85/*
86 * Class: org_rocksdb_WriteBatchWithIndex
87 * Method: put
88 * Signature: (J[BI[BI)V
89 */
90void Java_org_rocksdb_WriteBatchWithIndex_put__J_3BI_3BI(
91 JNIEnv* env, jobject jobj, jlong jwbwi_handle, jbyteArray jkey,
92 jint jkey_len, jbyteArray jentry_value, jint jentry_value_len) {
f67539c2
TL
93 auto* wbwi =
94 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae 95 assert(wbwi != nullptr);
f67539c2
TL
96 auto put = [&wbwi](ROCKSDB_NAMESPACE::Slice key,
97 ROCKSDB_NAMESPACE::Slice value) {
11fdf7f2 98 return wbwi->Put(key, value);
7c673cae 99 };
f67539c2
TL
100 std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
101 ROCKSDB_NAMESPACE::JniUtil::kv_op(put, env, jobj, jkey, jkey_len,
102 jentry_value, jentry_value_len);
11fdf7f2 103 if (status != nullptr && !status->ok()) {
f67539c2 104 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
11fdf7f2 105 }
7c673cae
FG
106}
107
108/*
109 * Class: org_rocksdb_WriteBatchWithIndex
110 * Method: put
111 * Signature: (J[BI[BIJ)V
112 */
113void Java_org_rocksdb_WriteBatchWithIndex_put__J_3BI_3BIJ(
114 JNIEnv* env, jobject jobj, jlong jwbwi_handle, jbyteArray jkey,
115 jint jkey_len, jbyteArray jentry_value, jint jentry_value_len,
116 jlong jcf_handle) {
f67539c2
TL
117 auto* wbwi =
118 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae 119 assert(wbwi != nullptr);
f67539c2
TL
120 auto* cf_handle =
121 reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
7c673cae 122 assert(cf_handle != nullptr);
f67539c2
TL
123 auto put = [&wbwi, &cf_handle](ROCKSDB_NAMESPACE::Slice key,
124 ROCKSDB_NAMESPACE::Slice value) {
11fdf7f2 125 return wbwi->Put(cf_handle, key, value);
7c673cae 126 };
f67539c2
TL
127 std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
128 ROCKSDB_NAMESPACE::JniUtil::kv_op(put, env, jobj, jkey, jkey_len,
129 jentry_value, jentry_value_len);
11fdf7f2 130 if (status != nullptr && !status->ok()) {
f67539c2 131 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
11fdf7f2 132 }
7c673cae
FG
133}
134
f67539c2
TL
135/*
136 * Class: org_rocksdb_WriteBatchWithIndex
137 * Method: putDirect
138 * Signature: (JLjava/nio/ByteBuffer;IILjava/nio/ByteBuffer;IIJ)V
139 */
140void Java_org_rocksdb_WriteBatchWithIndex_putDirect(
141 JNIEnv* env, jobject /*jobj*/, jlong jwb_handle, jobject jkey,
142 jint jkey_offset, jint jkey_len, jobject jval, jint jval_offset,
143 jint jval_len, jlong jcf_handle) {
144 auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
145 assert(wb != nullptr);
146 auto* cf_handle =
147 reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
148 auto put = [&wb, &cf_handle](ROCKSDB_NAMESPACE::Slice& key,
149 ROCKSDB_NAMESPACE::Slice& value) {
150 if (cf_handle == nullptr) {
151 wb->Put(key, value);
152 } else {
153 wb->Put(cf_handle, key, value);
154 }
155 };
156 ROCKSDB_NAMESPACE::JniUtil::kv_op_direct(
157 put, env, jkey, jkey_offset, jkey_len, jval, jval_offset, jval_len);
158}
159
7c673cae
FG
160/*
161 * Class: org_rocksdb_WriteBatchWithIndex
162 * Method: merge
163 * Signature: (J[BI[BI)V
164 */
165void Java_org_rocksdb_WriteBatchWithIndex_merge__J_3BI_3BI(
166 JNIEnv* env, jobject jobj, jlong jwbwi_handle, jbyteArray jkey,
167 jint jkey_len, jbyteArray jentry_value, jint jentry_value_len) {
f67539c2
TL
168 auto* wbwi =
169 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae 170 assert(wbwi != nullptr);
f67539c2
TL
171 auto merge = [&wbwi](ROCKSDB_NAMESPACE::Slice key,
172 ROCKSDB_NAMESPACE::Slice value) {
11fdf7f2 173 return wbwi->Merge(key, value);
7c673cae 174 };
f67539c2
TL
175 std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
176 ROCKSDB_NAMESPACE::JniUtil::kv_op(merge, env, jobj, jkey, jkey_len,
177 jentry_value, jentry_value_len);
11fdf7f2 178 if (status != nullptr && !status->ok()) {
f67539c2 179 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
11fdf7f2 180 }
7c673cae
FG
181}
182
183/*
184 * Class: org_rocksdb_WriteBatchWithIndex
185 * Method: merge
186 * Signature: (J[BI[BIJ)V
187 */
188void Java_org_rocksdb_WriteBatchWithIndex_merge__J_3BI_3BIJ(
189 JNIEnv* env, jobject jobj, jlong jwbwi_handle, jbyteArray jkey,
190 jint jkey_len, jbyteArray jentry_value, jint jentry_value_len,
191 jlong jcf_handle) {
f67539c2
TL
192 auto* wbwi =
193 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae 194 assert(wbwi != nullptr);
f67539c2
TL
195 auto* cf_handle =
196 reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
7c673cae 197 assert(cf_handle != nullptr);
f67539c2
TL
198 auto merge = [&wbwi, &cf_handle](ROCKSDB_NAMESPACE::Slice key,
199 ROCKSDB_NAMESPACE::Slice value) {
11fdf7f2
TL
200 return wbwi->Merge(cf_handle, key, value);
201 };
f67539c2
TL
202 std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
203 ROCKSDB_NAMESPACE::JniUtil::kv_op(merge, env, jobj, jkey, jkey_len,
204 jentry_value, jentry_value_len);
11fdf7f2 205 if (status != nullptr && !status->ok()) {
f67539c2 206 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
11fdf7f2
TL
207 }
208}
209
210/*
211 * Class: org_rocksdb_WriteBatchWithIndex
212 * Method: delete
213 * Signature: (J[BI)V
214 */
215void Java_org_rocksdb_WriteBatchWithIndex_delete__J_3BI(JNIEnv* env,
216 jobject jobj,
217 jlong jwbwi_handle,
218 jbyteArray jkey,
219 jint jkey_len) {
f67539c2
TL
220 auto* wbwi =
221 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
11fdf7f2 222 assert(wbwi != nullptr);
f67539c2
TL
223 auto remove = [&wbwi](ROCKSDB_NAMESPACE::Slice key) {
224 return wbwi->Delete(key);
225 };
226 std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
227 ROCKSDB_NAMESPACE::JniUtil::k_op(remove, env, jobj, jkey, jkey_len);
11fdf7f2 228 if (status != nullptr && !status->ok()) {
f67539c2 229 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
11fdf7f2
TL
230 }
231}
232
233/*
234 * Class: org_rocksdb_WriteBatchWithIndex
235 * Method: delete
236 * Signature: (J[BIJ)V
237 */
238void Java_org_rocksdb_WriteBatchWithIndex_delete__J_3BIJ(
239 JNIEnv* env, jobject jobj, jlong jwbwi_handle, jbyteArray jkey,
240 jint jkey_len, jlong jcf_handle) {
f67539c2
TL
241 auto* wbwi =
242 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
11fdf7f2 243 assert(wbwi != nullptr);
f67539c2
TL
244 auto* cf_handle =
245 reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
11fdf7f2 246 assert(cf_handle != nullptr);
f67539c2 247 auto remove = [&wbwi, &cf_handle](ROCKSDB_NAMESPACE::Slice key) {
11fdf7f2 248 return wbwi->Delete(cf_handle, key);
7c673cae 249 };
f67539c2
TL
250 std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
251 ROCKSDB_NAMESPACE::JniUtil::k_op(remove, env, jobj, jkey, jkey_len);
11fdf7f2 252 if (status != nullptr && !status->ok()) {
f67539c2 253 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
11fdf7f2 254 }
7c673cae
FG
255}
256
257/*
258 * Class: org_rocksdb_WriteBatchWithIndex
11fdf7f2 259 * Method: singleDelete
7c673cae
FG
260 * Signature: (J[BI)V
261 */
11fdf7f2 262void Java_org_rocksdb_WriteBatchWithIndex_singleDelete__J_3BI(
7c673cae
FG
263 JNIEnv* env, jobject jobj, jlong jwbwi_handle, jbyteArray jkey,
264 jint jkey_len) {
f67539c2
TL
265 auto* wbwi =
266 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae 267 assert(wbwi != nullptr);
f67539c2 268 auto single_delete = [&wbwi](ROCKSDB_NAMESPACE::Slice key) {
11fdf7f2 269 return wbwi->SingleDelete(key);
7c673cae 270 };
f67539c2
TL
271 std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
272 ROCKSDB_NAMESPACE::JniUtil::k_op(single_delete, env, jobj, jkey,
273 jkey_len);
11fdf7f2 274 if (status != nullptr && !status->ok()) {
f67539c2 275 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
11fdf7f2 276 }
7c673cae
FG
277}
278
279/*
280 * Class: org_rocksdb_WriteBatchWithIndex
11fdf7f2 281 * Method: singleDelete
7c673cae
FG
282 * Signature: (J[BIJ)V
283 */
11fdf7f2 284void Java_org_rocksdb_WriteBatchWithIndex_singleDelete__J_3BIJ(
7c673cae
FG
285 JNIEnv* env, jobject jobj, jlong jwbwi_handle, jbyteArray jkey,
286 jint jkey_len, jlong jcf_handle) {
f67539c2
TL
287 auto* wbwi =
288 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae 289 assert(wbwi != nullptr);
f67539c2
TL
290 auto* cf_handle =
291 reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
7c673cae 292 assert(cf_handle != nullptr);
f67539c2 293 auto single_delete = [&wbwi, &cf_handle](ROCKSDB_NAMESPACE::Slice key) {
11fdf7f2 294 return wbwi->SingleDelete(cf_handle, key);
7c673cae 295 };
f67539c2
TL
296 std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
297 ROCKSDB_NAMESPACE::JniUtil::k_op(single_delete, env, jobj, jkey,
298 jkey_len);
11fdf7f2 299 if (status != nullptr && !status->ok()) {
f67539c2 300 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
11fdf7f2 301 }
7c673cae
FG
302}
303
f67539c2
TL
304/*
305 * Class: org_rocksdb_WriteBatchWithIndex
1e59de90 306 * Method: deleteDirect
f67539c2
TL
307 * Signature: (JLjava/nio/ByteBuffer;IIJ)V
308 */
1e59de90 309void Java_org_rocksdb_WriteBatchWithIndex_deleteDirect(
f67539c2
TL
310 JNIEnv* env, jobject /*jobj*/, jlong jwb_handle, jobject jkey,
311 jint jkey_offset, jint jkey_len, jlong jcf_handle) {
312 auto* wb = reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatch*>(jwb_handle);
313 assert(wb != nullptr);
314 auto* cf_handle =
315 reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
316 auto remove = [&wb, &cf_handle](ROCKSDB_NAMESPACE::Slice& key) {
317 if (cf_handle == nullptr) {
318 wb->Delete(key);
319 } else {
320 wb->Delete(cf_handle, key);
321 }
322 };
323 ROCKSDB_NAMESPACE::JniUtil::k_op_direct(remove, env, jkey, jkey_offset,
324 jkey_len);
325}
326
7c673cae
FG
327/*
328 * Class: org_rocksdb_WriteBatchWithIndex
329 * Method: deleteRange
330 * Signature: (J[BI[BI)V
331 */
332void Java_org_rocksdb_WriteBatchWithIndex_deleteRange__J_3BI_3BI(
333 JNIEnv* env, jobject jobj, jlong jwbwi_handle, jbyteArray jbegin_key,
334 jint jbegin_key_len, jbyteArray jend_key, jint jend_key_len) {
f67539c2
TL
335 auto* wbwi =
336 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae 337 assert(wbwi != nullptr);
f67539c2
TL
338 auto deleteRange = [&wbwi](ROCKSDB_NAMESPACE::Slice beginKey,
339 ROCKSDB_NAMESPACE::Slice endKey) {
11fdf7f2 340 return wbwi->DeleteRange(beginKey, endKey);
7c673cae 341 };
f67539c2
TL
342 std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
343 ROCKSDB_NAMESPACE::JniUtil::kv_op(deleteRange, env, jobj, jbegin_key,
344 jbegin_key_len, jend_key, jend_key_len);
11fdf7f2 345 if (status != nullptr && !status->ok()) {
f67539c2 346 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
11fdf7f2 347 }
7c673cae
FG
348}
349
350/*
351 * Class: org_rocksdb_WriteBatchWithIndex
352 * Method: deleteRange
353 * Signature: (J[BI[BIJ)V
354 */
355void Java_org_rocksdb_WriteBatchWithIndex_deleteRange__J_3BI_3BIJ(
356 JNIEnv* env, jobject jobj, jlong jwbwi_handle, jbyteArray jbegin_key,
357 jint jbegin_key_len, jbyteArray jend_key, jint jend_key_len,
358 jlong jcf_handle) {
f67539c2
TL
359 auto* wbwi =
360 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae 361 assert(wbwi != nullptr);
f67539c2
TL
362 auto* cf_handle =
363 reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
7c673cae 364 assert(cf_handle != nullptr);
f67539c2
TL
365 auto deleteRange = [&wbwi, &cf_handle](ROCKSDB_NAMESPACE::Slice beginKey,
366 ROCKSDB_NAMESPACE::Slice endKey) {
11fdf7f2 367 return wbwi->DeleteRange(cf_handle, beginKey, endKey);
7c673cae 368 };
f67539c2
TL
369 std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
370 ROCKSDB_NAMESPACE::JniUtil::kv_op(deleteRange, env, jobj, jbegin_key,
371 jbegin_key_len, jend_key, jend_key_len);
11fdf7f2 372 if (status != nullptr && !status->ok()) {
f67539c2 373 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
11fdf7f2 374 }
7c673cae
FG
375}
376
377/*
378 * Class: org_rocksdb_WriteBatchWithIndex
379 * Method: putLogData
380 * Signature: (J[BI)V
381 */
11fdf7f2
TL
382void Java_org_rocksdb_WriteBatchWithIndex_putLogData(JNIEnv* env, jobject jobj,
383 jlong jwbwi_handle,
384 jbyteArray jblob,
385 jint jblob_len) {
f67539c2
TL
386 auto* wbwi =
387 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae 388 assert(wbwi != nullptr);
f67539c2 389 auto putLogData = [&wbwi](ROCKSDB_NAMESPACE::Slice blob) {
11fdf7f2 390 return wbwi->PutLogData(blob);
7c673cae 391 };
f67539c2
TL
392 std::unique_ptr<ROCKSDB_NAMESPACE::Status> status =
393 ROCKSDB_NAMESPACE::JniUtil::k_op(putLogData, env, jobj, jblob, jblob_len);
11fdf7f2 394 if (status != nullptr && !status->ok()) {
f67539c2 395 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, status);
11fdf7f2 396 }
7c673cae
FG
397}
398
399/*
400 * Class: org_rocksdb_WriteBatchWithIndex
401 * Method: clear
402 * Signature: (J)V
403 */
11fdf7f2
TL
404void Java_org_rocksdb_WriteBatchWithIndex_clear0(JNIEnv* /*env*/,
405 jobject /*jobj*/,
406 jlong jwbwi_handle) {
f67539c2
TL
407 auto* wbwi =
408 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae
FG
409 assert(wbwi != nullptr);
410
411 wbwi->Clear();
412}
413
414/*
415 * Class: org_rocksdb_WriteBatchWithIndex
416 * Method: setSavePoint0
417 * Signature: (J)V
418 */
11fdf7f2
TL
419void Java_org_rocksdb_WriteBatchWithIndex_setSavePoint0(JNIEnv* /*env*/,
420 jobject /*jobj*/,
421 jlong jwbwi_handle) {
f67539c2
TL
422 auto* wbwi =
423 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae
FG
424 assert(wbwi != nullptr);
425
426 wbwi->SetSavePoint();
427}
428
429/*
430 * Class: org_rocksdb_WriteBatchWithIndex
431 * Method: rollbackToSavePoint0
432 * Signature: (J)V
433 */
434void Java_org_rocksdb_WriteBatchWithIndex_rollbackToSavePoint0(
11fdf7f2 435 JNIEnv* env, jobject /*jobj*/, jlong jwbwi_handle) {
f67539c2
TL
436 auto* wbwi =
437 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae
FG
438 assert(wbwi != nullptr);
439
440 auto s = wbwi->RollbackToSavePoint();
441
442 if (s.ok()) {
443 return;
444 }
445
f67539c2 446 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
7c673cae
FG
447}
448
11fdf7f2
TL
449/*
450 * Class: org_rocksdb_WriteBatchWithIndex
451 * Method: popSavePoint
452 * Signature: (J)V
453 */
454void Java_org_rocksdb_WriteBatchWithIndex_popSavePoint(JNIEnv* env,
455 jobject /*jobj*/,
456 jlong jwbwi_handle) {
f67539c2
TL
457 auto* wbwi =
458 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
11fdf7f2
TL
459 assert(wbwi != nullptr);
460
461 auto s = wbwi->PopSavePoint();
462
463 if (s.ok()) {
464 return;
465 }
466
f67539c2 467 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
11fdf7f2
TL
468}
469
470/*
471 * Class: org_rocksdb_WriteBatchWithIndex
472 * Method: setMaxBytes
473 * Signature: (JJ)V
474 */
475void Java_org_rocksdb_WriteBatchWithIndex_setMaxBytes(JNIEnv* /*env*/,
476 jobject /*jobj*/,
477 jlong jwbwi_handle,
478 jlong jmax_bytes) {
f67539c2
TL
479 auto* wbwi =
480 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
11fdf7f2
TL
481 assert(wbwi != nullptr);
482
483 wbwi->SetMaxBytes(static_cast<size_t>(jmax_bytes));
484}
485
486/*
487 * Class: org_rocksdb_WriteBatchWithIndex
488 * Method: getWriteBatch
489 * Signature: (J)Lorg/rocksdb/WriteBatch;
490 */
491jobject Java_org_rocksdb_WriteBatchWithIndex_getWriteBatch(JNIEnv* env,
492 jobject /*jobj*/,
493 jlong jwbwi_handle) {
f67539c2
TL
494 auto* wbwi =
495 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
11fdf7f2
TL
496 assert(wbwi != nullptr);
497
498 auto* wb = wbwi->GetWriteBatch();
499
500 // TODO(AR) is the `wb` object owned by us?
f67539c2 501 return ROCKSDB_NAMESPACE::WriteBatchJni::construct(env, wb);
11fdf7f2
TL
502}
503
7c673cae
FG
504/*
505 * Class: org_rocksdb_WriteBatchWithIndex
506 * Method: iterator0
507 * Signature: (J)J
508 */
11fdf7f2
TL
509jlong Java_org_rocksdb_WriteBatchWithIndex_iterator0(JNIEnv* /*env*/,
510 jobject /*jobj*/,
511 jlong jwbwi_handle) {
f67539c2
TL
512 auto* wbwi =
513 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
7c673cae 514 auto* wbwi_iterator = wbwi->NewIterator();
1e59de90 515 return GET_CPLUSPLUS_POINTER(wbwi_iterator);
7c673cae
FG
516}
517
518/*
519 * Class: org_rocksdb_WriteBatchWithIndex
520 * Method: iterator1
521 * Signature: (JJ)J
522 */
11fdf7f2
TL
523jlong Java_org_rocksdb_WriteBatchWithIndex_iterator1(JNIEnv* /*env*/,
524 jobject /*jobj*/,
525 jlong jwbwi_handle,
526 jlong jcf_handle) {
f67539c2
TL
527 auto* wbwi =
528 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
529 auto* cf_handle =
530 reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
7c673cae 531 auto* wbwi_iterator = wbwi->NewIterator(cf_handle);
1e59de90 532 return GET_CPLUSPLUS_POINTER(wbwi_iterator);
7c673cae
FG
533}
534
535/*
536 * Class: org_rocksdb_WriteBatchWithIndex
537 * Method: iteratorWithBase
20effc67 538 * Signature: (JJJJ)J
7c673cae 539 */
20effc67
TL
540jlong Java_org_rocksdb_WriteBatchWithIndex_iteratorWithBase(
541 JNIEnv*, jobject, jlong jwbwi_handle, jlong jcf_handle,
542 jlong jbase_iterator_handle, jlong jread_opts_handle) {
f67539c2
TL
543 auto* wbwi =
544 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
545 auto* cf_handle =
546 reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
547 auto* base_iterator =
20effc67
TL
548 reinterpret_cast<ROCKSDB_NAMESPACE::Iterator*>(jbase_iterator_handle);
549 ROCKSDB_NAMESPACE::ReadOptions* read_opts =
550 jread_opts_handle == 0
551 ? nullptr
552 : reinterpret_cast<ROCKSDB_NAMESPACE::ReadOptions*>(
553 jread_opts_handle);
554 auto* iterator =
555 wbwi->NewIteratorWithBase(cf_handle, base_iterator, read_opts);
1e59de90 556 return GET_CPLUSPLUS_POINTER(iterator);
7c673cae
FG
557}
558
559/*
560 * Class: org_rocksdb_WriteBatchWithIndex
561 * Method: getFromBatch
562 * Signature: (JJ[BI)[B
563 */
564jbyteArray JNICALL Java_org_rocksdb_WriteBatchWithIndex_getFromBatch__JJ_3BI(
11fdf7f2 565 JNIEnv* env, jobject /*jobj*/, jlong jwbwi_handle, jlong jdbopt_handle,
7c673cae 566 jbyteArray jkey, jint jkey_len) {
f67539c2
TL
567 auto* wbwi =
568 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
569 auto* dbopt = reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions*>(jdbopt_handle);
7c673cae 570
f67539c2
TL
571 auto getter = [&wbwi, &dbopt](const ROCKSDB_NAMESPACE::Slice& key,
572 std::string* value) {
7c673cae
FG
573 return wbwi->GetFromBatch(*dbopt, key, value);
574 };
575
f67539c2 576 return ROCKSDB_NAMESPACE::JniUtil::v_op(getter, env, jkey, jkey_len);
7c673cae
FG
577}
578
579/*
580 * Class: org_rocksdb_WriteBatchWithIndex
581 * Method: getFromBatch
582 * Signature: (JJ[BIJ)[B
583 */
584jbyteArray Java_org_rocksdb_WriteBatchWithIndex_getFromBatch__JJ_3BIJ(
11fdf7f2 585 JNIEnv* env, jobject /*jobj*/, jlong jwbwi_handle, jlong jdbopt_handle,
7c673cae 586 jbyteArray jkey, jint jkey_len, jlong jcf_handle) {
f67539c2
TL
587 auto* wbwi =
588 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
589 auto* dbopt = reinterpret_cast<ROCKSDB_NAMESPACE::DBOptions*>(jdbopt_handle);
590 auto* cf_handle =
591 reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
7c673cae 592
f67539c2 593 auto getter = [&wbwi, &cf_handle, &dbopt](const ROCKSDB_NAMESPACE::Slice& key,
11fdf7f2
TL
594 std::string* value) {
595 return wbwi->GetFromBatch(cf_handle, *dbopt, key, value);
596 };
7c673cae 597
f67539c2 598 return ROCKSDB_NAMESPACE::JniUtil::v_op(getter, env, jkey, jkey_len);
7c673cae
FG
599}
600
601/*
602 * Class: org_rocksdb_WriteBatchWithIndex
603 * Method: getFromBatchAndDB
604 * Signature: (JJJ[BI)[B
605 */
606jbyteArray Java_org_rocksdb_WriteBatchWithIndex_getFromBatchAndDB__JJJ_3BI(
11fdf7f2 607 JNIEnv* env, jobject /*jobj*/, jlong jwbwi_handle, jlong jdb_handle,
7c673cae 608 jlong jreadopt_handle, jbyteArray jkey, jint jkey_len) {
f67539c2
TL
609 auto* wbwi =
610 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
611 auto* db = reinterpret_cast<ROCKSDB_NAMESPACE::DB*>(jdb_handle);
612 auto* readopt =
613 reinterpret_cast<ROCKSDB_NAMESPACE::ReadOptions*>(jreadopt_handle);
7c673cae 614
f67539c2 615 auto getter = [&wbwi, &db, &readopt](const ROCKSDB_NAMESPACE::Slice& key,
11fdf7f2
TL
616 std::string* value) {
617 return wbwi->GetFromBatchAndDB(db, *readopt, key, value);
618 };
7c673cae 619
f67539c2 620 return ROCKSDB_NAMESPACE::JniUtil::v_op(getter, env, jkey, jkey_len);
7c673cae
FG
621}
622
623/*
624 * Class: org_rocksdb_WriteBatchWithIndex
625 * Method: getFromBatchAndDB
626 * Signature: (JJJ[BIJ)[B
627 */
628jbyteArray Java_org_rocksdb_WriteBatchWithIndex_getFromBatchAndDB__JJJ_3BIJ(
11fdf7f2 629 JNIEnv* env, jobject /*jobj*/, jlong jwbwi_handle, jlong jdb_handle,
7c673cae 630 jlong jreadopt_handle, jbyteArray jkey, jint jkey_len, jlong jcf_handle) {
f67539c2
TL
631 auto* wbwi =
632 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(jwbwi_handle);
633 auto* db = reinterpret_cast<ROCKSDB_NAMESPACE::DB*>(jdb_handle);
634 auto* readopt =
635 reinterpret_cast<ROCKSDB_NAMESPACE::ReadOptions*>(jreadopt_handle);
636 auto* cf_handle =
637 reinterpret_cast<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>(jcf_handle);
638
639 auto getter = [&wbwi, &db, &cf_handle, &readopt](
640 const ROCKSDB_NAMESPACE::Slice& key, std::string* value) {
11fdf7f2
TL
641 return wbwi->GetFromBatchAndDB(db, *readopt, cf_handle, key, value);
642 };
7c673cae 643
f67539c2 644 return ROCKSDB_NAMESPACE::JniUtil::v_op(getter, env, jkey, jkey_len);
7c673cae
FG
645}
646
647/*
648 * Class: org_rocksdb_WriteBatchWithIndex
649 * Method: disposeInternal
650 * Signature: (J)V
651 */
11fdf7f2
TL
652void Java_org_rocksdb_WriteBatchWithIndex_disposeInternal(JNIEnv* /*env*/,
653 jobject /*jobj*/,
654 jlong handle) {
f67539c2
TL
655 auto* wbwi =
656 reinterpret_cast<ROCKSDB_NAMESPACE::WriteBatchWithIndex*>(handle);
7c673cae
FG
657 assert(wbwi != nullptr);
658 delete wbwi;
659}
660
661/* WBWIRocksIterator below */
662
663/*
664 * Class: org_rocksdb_WBWIRocksIterator
665 * Method: disposeInternal
666 * Signature: (J)V
667 */
11fdf7f2
TL
668void Java_org_rocksdb_WBWIRocksIterator_disposeInternal(JNIEnv* /*env*/,
669 jobject /*jobj*/,
670 jlong handle) {
f67539c2 671 auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle);
7c673cae
FG
672 assert(it != nullptr);
673 delete it;
674}
675
676/*
677 * Class: org_rocksdb_WBWIRocksIterator
678 * Method: isValid0
679 * Signature: (J)Z
680 */
11fdf7f2
TL
681jboolean Java_org_rocksdb_WBWIRocksIterator_isValid0(JNIEnv* /*env*/,
682 jobject /*jobj*/,
683 jlong handle) {
f67539c2 684 return reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle)->Valid();
7c673cae
FG
685}
686
687/*
688 * Class: org_rocksdb_WBWIRocksIterator
689 * Method: seekToFirst0
690 * Signature: (J)V
691 */
11fdf7f2
TL
692void Java_org_rocksdb_WBWIRocksIterator_seekToFirst0(JNIEnv* /*env*/,
693 jobject /*jobj*/,
694 jlong handle) {
f67539c2 695 reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle)->SeekToFirst();
7c673cae
FG
696}
697
698/*
699 * Class: org_rocksdb_WBWIRocksIterator
700 * Method: seekToLast0
701 * Signature: (J)V
702 */
11fdf7f2
TL
703void Java_org_rocksdb_WBWIRocksIterator_seekToLast0(JNIEnv* /*env*/,
704 jobject /*jobj*/,
705 jlong handle) {
f67539c2 706 reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle)->SeekToLast();
7c673cae
FG
707}
708
709/*
710 * Class: org_rocksdb_WBWIRocksIterator
711 * Method: next0
712 * Signature: (J)V
713 */
11fdf7f2
TL
714void Java_org_rocksdb_WBWIRocksIterator_next0(JNIEnv* /*env*/, jobject /*jobj*/,
715 jlong handle) {
f67539c2 716 reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle)->Next();
7c673cae
FG
717}
718
719/*
720 * Class: org_rocksdb_WBWIRocksIterator
721 * Method: prev0
722 * Signature: (J)V
723 */
11fdf7f2
TL
724void Java_org_rocksdb_WBWIRocksIterator_prev0(JNIEnv* /*env*/, jobject /*jobj*/,
725 jlong handle) {
f67539c2 726 reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle)->Prev();
7c673cae
FG
727}
728
729/*
730 * Class: org_rocksdb_WBWIRocksIterator
731 * Method: seek0
732 * Signature: (J[BI)V
733 */
11fdf7f2
TL
734void Java_org_rocksdb_WBWIRocksIterator_seek0(JNIEnv* env, jobject /*jobj*/,
735 jlong handle, jbyteArray jtarget,
736 jint jtarget_len) {
f67539c2 737 auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle);
1e59de90
TL
738 jbyte* target = new jbyte[jtarget_len];
739 env->GetByteArrayRegion(jtarget, 0, jtarget_len, target);
740 if (env->ExceptionCheck()) {
741 // exception thrown: ArrayIndexOutOfBoundsException
742 delete[] target;
7c673cae
FG
743 return;
744 }
745
f67539c2
TL
746 ROCKSDB_NAMESPACE::Slice target_slice(reinterpret_cast<char*>(target),
747 jtarget_len);
7c673cae
FG
748
749 it->Seek(target_slice);
750
1e59de90 751 delete[] target;
7c673cae
FG
752}
753
f67539c2
TL
754/*
755 * Class: org_rocksdb_WBWIRocksIterator
756 * Method: seekDirect0
757 * Signature: (JLjava/nio/ByteBuffer;II)V
758 */
759void Java_org_rocksdb_WBWIRocksIterator_seekDirect0(
760 JNIEnv* env, jobject /*jobj*/, jlong handle, jobject jtarget,
761 jint jtarget_off, jint jtarget_len) {
762 auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle);
763 auto seek = [&it](ROCKSDB_NAMESPACE::Slice& target_slice) {
764 it->Seek(target_slice);
765 };
766 ROCKSDB_NAMESPACE::JniUtil::k_op_direct(seek, env, jtarget, jtarget_off,
767 jtarget_len);
768}
769
1e59de90
TL
770/*
771 * This method supports fetching into indirect byte buffers;
772 * the Java wrapper extracts the byte[] and passes it here.
773 *
774 * Class: org_rocksdb_WBWIRocksIterator
775 * Method: seekByteArray0
776 * Signature: (J[BII)V
777 */
778void Java_org_rocksdb_WBWIRocksIterator_seekByteArray0(
779 JNIEnv* env, jobject /*jobj*/, jlong handle, jbyteArray jtarget,
780 jint jtarget_off, jint jtarget_len) {
781 const std::unique_ptr<char[]> target(new char[jtarget_len]);
782 if (target == nullptr) {
783 jclass oom_class = env->FindClass("/lang/java/OutOfMemoryError");
784 env->ThrowNew(oom_class,
785 "Memory allocation failed in RocksDB JNI function");
786 return;
787 }
788 env->GetByteArrayRegion(jtarget, jtarget_off, jtarget_len,
789 reinterpret_cast<jbyte*>(target.get()));
790
791 ROCKSDB_NAMESPACE::Slice target_slice(target.get(), jtarget_len);
792
793 auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle);
794 it->Seek(target_slice);
795}
796
11fdf7f2
TL
797/*
798 * Class: org_rocksdb_WBWIRocksIterator
799 * Method: seekForPrev0
800 * Signature: (J[BI)V
801 */
802void Java_org_rocksdb_WBWIRocksIterator_seekForPrev0(JNIEnv* env,
803 jobject /*jobj*/,
804 jlong handle,
805 jbyteArray jtarget,
806 jint jtarget_len) {
f67539c2 807 auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle);
1e59de90
TL
808 jbyte* target = new jbyte[jtarget_len];
809 env->GetByteArrayRegion(jtarget, 0, jtarget_len, target);
810 if (env->ExceptionCheck()) {
811 // exception thrown: ArrayIndexOutOfBoundsException
812 delete[] target;
11fdf7f2
TL
813 return;
814 }
815
f67539c2
TL
816 ROCKSDB_NAMESPACE::Slice target_slice(reinterpret_cast<char*>(target),
817 jtarget_len);
11fdf7f2
TL
818
819 it->SeekForPrev(target_slice);
820
1e59de90
TL
821 delete[] target;
822}
823
824/*
825 * Class: org_rocksdb_WBWIRocksIterator
826 * Method: seekForPrevDirect0
827 * Signature: (JLjava/nio/ByteBuffer;II)V
828 */
829void Java_org_rocksdb_WBWIRocksIterator_seekForPrevDirect0(
830 JNIEnv* env, jobject /*jobj*/, jlong handle, jobject jtarget,
831 jint jtarget_off, jint jtarget_len) {
832 auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle);
833 auto seek_for_prev = [&it](ROCKSDB_NAMESPACE::Slice& target_slice) {
834 it->SeekForPrev(target_slice);
835 };
836 ROCKSDB_NAMESPACE::JniUtil::k_op_direct(seek_for_prev, env, jtarget,
837 jtarget_off, jtarget_len);
838}
839
840/*
841 * This method supports fetching into indirect byte buffers;
842 * the Java wrapper extracts the byte[] and passes it here.
843 *
844 * Class: org_rocksdb_WBWIRocksIterator
845 * Method: seekForPrevByteArray0
846 * Signature: (J[BII)V
847 */
848void Java_org_rocksdb_WBWIRocksIterator_seekForPrevByteArray0(
849 JNIEnv* env, jobject /*jobj*/, jlong handle, jbyteArray jtarget,
850 jint jtarget_off, jint jtarget_len) {
851 const std::unique_ptr<char[]> target(new char[jtarget_len]);
852 if (target == nullptr) {
853 jclass oom_class = env->FindClass("/lang/java/OutOfMemoryError");
854 env->ThrowNew(oom_class,
855 "Memory allocation failed in RocksDB JNI function");
856 return;
857 }
858 env->GetByteArrayRegion(jtarget, jtarget_off, jtarget_len,
859 reinterpret_cast<jbyte*>(target.get()));
860
861 ROCKSDB_NAMESPACE::Slice target_slice(target.get(), jtarget_len);
862
863 auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle);
864 it->SeekForPrev(target_slice);
11fdf7f2
TL
865}
866
7c673cae
FG
867/*
868 * Class: org_rocksdb_WBWIRocksIterator
869 * Method: status0
870 * Signature: (J)V
871 */
11fdf7f2
TL
872void Java_org_rocksdb_WBWIRocksIterator_status0(JNIEnv* env, jobject /*jobj*/,
873 jlong handle) {
f67539c2
TL
874 auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle);
875 ROCKSDB_NAMESPACE::Status s = it->status();
7c673cae
FG
876
877 if (s.ok()) {
878 return;
879 }
880
f67539c2 881 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
7c673cae
FG
882}
883
884/*
885 * Class: org_rocksdb_WBWIRocksIterator
886 * Method: entry1
887 * Signature: (J)[J
888 */
11fdf7f2
TL
889jlongArray Java_org_rocksdb_WBWIRocksIterator_entry1(JNIEnv* env,
890 jobject /*jobj*/,
891 jlong handle) {
f67539c2
TL
892 auto* it = reinterpret_cast<ROCKSDB_NAMESPACE::WBWIIterator*>(handle);
893 const ROCKSDB_NAMESPACE::WriteEntry& we = it->Entry();
7c673cae
FG
894
895 jlong results[3];
896
11fdf7f2 897 // set the type of the write entry
f67539c2 898 results[0] = ROCKSDB_NAMESPACE::WriteTypeJni::toJavaWriteType(we.type);
7c673cae 899
11fdf7f2
TL
900 // NOTE: key_slice and value_slice will be freed by
901 // org.rocksdb.DirectSlice#close
7c673cae 902
f67539c2 903 auto* key_slice = new ROCKSDB_NAMESPACE::Slice(we.key.data(), we.key.size());
1e59de90 904 results[1] = GET_CPLUSPLUS_POINTER(key_slice);
f67539c2
TL
905 if (we.type == ROCKSDB_NAMESPACE::kDeleteRecord ||
906 we.type == ROCKSDB_NAMESPACE::kSingleDeleteRecord ||
907 we.type == ROCKSDB_NAMESPACE::kLogDataRecord) {
7c673cae
FG
908 // set native handle of value slice to null if no value available
909 results[2] = 0;
910 } else {
f67539c2
TL
911 auto* value_slice =
912 new ROCKSDB_NAMESPACE::Slice(we.value.data(), we.value.size());
1e59de90 913 results[2] = GET_CPLUSPLUS_POINTER(value_slice);
7c673cae
FG
914 }
915
916 jlongArray jresults = env->NewLongArray(3);
11fdf7f2 917 if (jresults == nullptr) {
7c673cae 918 // exception thrown: OutOfMemoryError
11fdf7f2 919 if (results[2] != 0) {
f67539c2
TL
920 auto* value_slice =
921 reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(results[2]);
7c673cae
FG
922 delete value_slice;
923 }
924 delete key_slice;
925 return nullptr;
926 }
927
928 env->SetLongArrayRegion(jresults, 0, 3, results);
11fdf7f2 929 if (env->ExceptionCheck()) {
7c673cae
FG
930 // exception thrown: ArrayIndexOutOfBoundsException
931 env->DeleteLocalRef(jresults);
11fdf7f2 932 if (results[2] != 0) {
f67539c2
TL
933 auto* value_slice =
934 reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(results[2]);
7c673cae
FG
935 delete value_slice;
936 }
937 delete key_slice;
938 return nullptr;
939 }
940
941 return jresults;
942}
20effc67
TL
943
944/*
945 * Class: org_rocksdb_WBWIRocksIterator
946 * Method: refresh0
947 * Signature: (J)V
948 */
949void Java_org_rocksdb_WBWIRocksIterator_refresh0(JNIEnv* env) {
1e59de90
TL
950 ROCKSDB_NAMESPACE::Status s =
951 ROCKSDB_NAMESPACE::Status::NotSupported("Refresh() is not supported");
20effc67
TL
952 ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
953}