]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/Transaction.java
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / rocksdb / java / src / main / java / org / rocksdb / Transaction.java
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
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).
5
6 package org.rocksdb;
7
8 import java.util.List;
9
10 /**
11 * Provides BEGIN/COMMIT/ROLLBACK transactions.
12 *
13 * To use transactions, you must first create either an
14 * {@link OptimisticTransactionDB} or a {@link TransactionDB}
15 *
16 * To create a transaction, use
17 * {@link OptimisticTransactionDB#beginTransaction(org.rocksdb.WriteOptions)} or
18 * {@link TransactionDB#beginTransaction(org.rocksdb.WriteOptions)}
19 *
20 * It is up to the caller to synchronize access to this object.
21 *
22 * See samples/src/main/java/OptimisticTransactionSample.java and
23 * samples/src/main/java/TransactionSample.java for some simple
24 * examples.
25 */
26 public class Transaction extends RocksObject {
27
28 private final RocksDB parent;
29
30 /**
31 * Intentionally package private
32 * as this is called from
33 * {@link OptimisticTransactionDB#beginTransaction(org.rocksdb.WriteOptions)}
34 * or {@link TransactionDB#beginTransaction(org.rocksdb.WriteOptions)}
35 *
36 * @param parent This must be either {@link TransactionDB} or
37 * {@link OptimisticTransactionDB}
38 * @param transactionHandle The native handle to the underlying C++
39 * transaction object
40 */
41 Transaction(final RocksDB parent, final long transactionHandle) {
42 super(transactionHandle);
43 this.parent = parent;
44 }
45
46 /**
47 * If a transaction has a snapshot set, the transaction will ensure that
48 * any keys successfully written(or fetched via {@link #getForUpdate}) have
49 * not been modified outside of this transaction since the time the snapshot
50 * was set.
51 *
52 * If a snapshot has not been set, the transaction guarantees that keys have
53 * not been modified since the time each key was first written (or fetched via
54 * {@link #getForUpdate}).
55 *
56 * Using {@link #setSnapshot()} will provide stricter isolation guarantees
57 * at the expense of potentially more transaction failures due to conflicts
58 * with other writes.
59 *
60 * Calling {@link #setSnapshot()} has no effect on keys written before this
61 * function has been called.
62 *
63 * {@link #setSnapshot()} may be called multiple times if you would like to
64 * change the snapshot used for different operations in this transaction.
65 *
66 * Calling {@link #setSnapshot()} will not affect the version of Data returned
67 * by get(...) methods. See {@link #get} for more details.
68 */
69 public void setSnapshot() {
70 assert(isOwningHandle());
71 setSnapshot(nativeHandle_);
72 }
73
74 /**
75 * Similar to {@link #setSnapshot()}, but will not change the current snapshot
76 * until put/merge/delete/getForUpdate/multiGetForUpdate is called.
77 * By calling this function, the transaction will essentially call
78 * {@link #setSnapshot()} for you right before performing the next
79 * write/getForUpdate.
80 *
81 * Calling {@link #setSnapshotOnNextOperation()} will not affect what
82 * snapshot is returned by {@link #getSnapshot} until the next
83 * write/getForUpdate is executed.
84 *
85 * When the snapshot is created the notifier's snapshotCreated method will
86 * be called so that the caller can get access to the snapshot.
87 *
88 * This is an optimization to reduce the likelihood of conflicts that
89 * could occur in between the time {@link #setSnapshot()} is called and the
90 * first write/getForUpdate operation. i.e. this prevents the following
91 * race-condition:
92 *
93 * txn1->setSnapshot();
94 * txn2->put("A", ...);
95 * txn2->commit();
96 * txn1->getForUpdate(opts, "A", ...); * FAIL!
97 */
98 public void setSnapshotOnNextOperation() {
99 assert(isOwningHandle());
100 setSnapshotOnNextOperation(nativeHandle_);
101 }
102
103 /**
104 * Similar to {@link #setSnapshot()}, but will not change the current snapshot
105 * until put/merge/delete/getForUpdate/multiGetForUpdate is called.
106 * By calling this function, the transaction will essentially call
107 * {@link #setSnapshot()} for you right before performing the next
108 * write/getForUpdate.
109 *
110 * Calling {@link #setSnapshotOnNextOperation()} will not affect what
111 * snapshot is returned by {@link #getSnapshot} until the next
112 * write/getForUpdate is executed.
113 *
114 * When the snapshot is created the
115 * {@link AbstractTransactionNotifier#snapshotCreated(Snapshot)} method will
116 * be called so that the caller can get access to the snapshot.
117 *
118 * This is an optimization to reduce the likelihood of conflicts that
119 * could occur in between the time {@link #setSnapshot()} is called and the
120 * first write/getForUpdate operation. i.e. this prevents the following
121 * race-condition:
122 *
123 * txn1->setSnapshot();
124 * txn2->put("A", ...);
125 * txn2->commit();
126 * txn1->getForUpdate(opts, "A", ...); * FAIL!
127 *
128 * @param transactionNotifier A handler for receiving snapshot notifications
129 * for the transaction
130 *
131 */
132 public void setSnapshotOnNextOperation(
133 final AbstractTransactionNotifier transactionNotifier) {
134 assert(isOwningHandle());
135 setSnapshotOnNextOperation(nativeHandle_, transactionNotifier.nativeHandle_);
136 }
137
138 /**
139 * Returns the Snapshot created by the last call to {@link #setSnapshot()}.
140 *
141 * REQUIRED: The returned Snapshot is only valid up until the next time
142 * {@link #setSnapshot()}/{@link #setSnapshotOnNextOperation()} is called,
143 * {@link #clearSnapshot()} is called, or the Transaction is deleted.
144 *
145 * @return The snapshot or null if there is no snapshot
146 */
147 public Snapshot getSnapshot() {
148 assert(isOwningHandle());
149 final long snapshotNativeHandle = getSnapshot(nativeHandle_);
150 if(snapshotNativeHandle == 0) {
151 return null;
152 } else {
153 final Snapshot snapshot = new Snapshot(snapshotNativeHandle);
154 return snapshot;
155 }
156 }
157
158 /**
159 * Clears the current snapshot (i.e. no snapshot will be 'set')
160 *
161 * This removes any snapshot that currently exists or is set to be created
162 * on the next update operation ({@link #setSnapshotOnNextOperation()}).
163 *
164 * Calling {@link #clearSnapshot()} has no effect on keys written before this
165 * function has been called.
166 *
167 * If a reference to a snapshot was retrieved via {@link #getSnapshot()}, it
168 * will no longer be valid and should be discarded after a call to
169 * {@link #clearSnapshot()}.
170 */
171 public void clearSnapshot() {
172 assert(isOwningHandle());
173 clearSnapshot(nativeHandle_);
174 }
175
176 /**
177 * Prepare the current transaction for 2PC
178 */
179 void prepare() throws RocksDBException {
180 //TODO(AR) consider a Java'ish version of this function, which returns an AutoCloseable (commit)
181 assert(isOwningHandle());
182 prepare(nativeHandle_);
183 }
184
185 /**
186 * Write all batched keys to the db atomically.
187 *
188 * Returns OK on success.
189 *
190 * May return any error status that could be returned by DB:Write().
191 *
192 * If this transaction was created by an {@link OptimisticTransactionDB}
193 * Status::Busy() may be returned if the transaction could not guarantee
194 * that there are no write conflicts. Status::TryAgain() may be returned
195 * if the memtable history size is not large enough
196 * (See max_write_buffer_number_to_maintain).
197 *
198 * If this transaction was created by a {@link TransactionDB},
199 * Status::Expired() may be returned if this transaction has lived for
200 * longer than {@link TransactionOptions#getExpiration()}.
201 *
202 * @throws RocksDBException if an error occurs when committing the transaction
203 */
204 public void commit() throws RocksDBException {
205 assert(isOwningHandle());
206 commit(nativeHandle_);
207 }
208
209 /**
210 * Discard all batched writes in this transaction.
211 *
212 * @throws RocksDBException if an error occurs when rolling back the transaction
213 */
214 public void rollback() throws RocksDBException {
215 assert(isOwningHandle());
216 rollback(nativeHandle_);
217 }
218
219 /**
220 * Records the state of the transaction for future calls to
221 * {@link #rollbackToSavePoint()}.
222 *
223 * May be called multiple times to set multiple save points.
224 *
225 * @throws RocksDBException if an error occurs whilst setting a save point
226 */
227 public void setSavePoint() throws RocksDBException {
228 assert(isOwningHandle());
229 setSavePoint(nativeHandle_);
230 }
231
232 /**
233 * Undo all operations in this transaction (put, merge, delete, putLogData)
234 * since the most recent call to {@link #setSavePoint()} and removes the most
235 * recent {@link #setSavePoint()}.
236 *
237 * If there is no previous call to {@link #setSavePoint()},
238 * returns Status::NotFound()
239 *
240 * @throws RocksDBException if an error occurs when rolling back to a save point
241 */
242 public void rollbackToSavePoint() throws RocksDBException {
243 assert(isOwningHandle());
244 rollbackToSavePoint(nativeHandle_);
245 }
246
247 /**
248 * This function is similar to
249 * {@link RocksDB#get(ColumnFamilyHandle, ReadOptions, byte[])} except it will
250 * also read pending changes in this transaction.
251 * Currently, this function will return Status::MergeInProgress if the most
252 * recent write to the queried key in this batch is a Merge.
253 *
254 * If {@link ReadOptions#snapshot()} is not set, the current version of the
255 * key will be read. Calling {@link #setSnapshot()} does not affect the
256 * version of the data returned.
257 *
258 * Note that setting {@link ReadOptions#setSnapshot(Snapshot)} will affect
259 * what is read from the DB but will NOT change which keys are read from this
260 * transaction (the keys in this transaction do not yet belong to any snapshot
261 * and will be fetched regardless).
262 *
263 * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle} instance
264 * @param readOptions Read options.
265 * @param key the key to retrieve the value for.
266 *
267 * @return a byte array storing the value associated with the input key if
268 * any. null if it does not find the specified key.
269 *
270 * @throws RocksDBException thrown if error happens in underlying native
271 * library.
272 */
273 public byte[] get(final ColumnFamilyHandle columnFamilyHandle,
274 final ReadOptions readOptions, final byte[] key) throws RocksDBException {
275 assert(isOwningHandle());
276 return get(nativeHandle_, readOptions.nativeHandle_, key, key.length,
277 columnFamilyHandle.nativeHandle_);
278 }
279
280 /**
281 * This function is similar to
282 * {@link RocksDB#get(ReadOptions, byte[])} except it will
283 * also read pending changes in this transaction.
284 * Currently, this function will return Status::MergeInProgress if the most
285 * recent write to the queried key in this batch is a Merge.
286 *
287 * If {@link ReadOptions#snapshot()} is not set, the current version of the
288 * key will be read. Calling {@link #setSnapshot()} does not affect the
289 * version of the data returned.
290 *
291 * Note that setting {@link ReadOptions#setSnapshot(Snapshot)} will affect
292 * what is read from the DB but will NOT change which keys are read from this
293 * transaction (the keys in this transaction do not yet belong to any snapshot
294 * and will be fetched regardless).
295 *
296 * @param readOptions Read options.
297 * @param key the key to retrieve the value for.
298 *
299 * @return a byte array storing the value associated with the input key if
300 * any. null if it does not find the specified key.
301 *
302 * @throws RocksDBException thrown if error happens in underlying native
303 * library.
304 */
305 public byte[] get(final ReadOptions readOptions, final byte[] key)
306 throws RocksDBException {
307 assert(isOwningHandle());
308 return get(nativeHandle_, readOptions.nativeHandle_, key, key.length);
309 }
310
311 /**
312 * This function is similar to
313 * {@link RocksDB#multiGet(ReadOptions, List, List)} except it will
314 * also read pending changes in this transaction.
315 * Currently, this function will return Status::MergeInProgress if the most
316 * recent write to the queried key in this batch is a Merge.
317 *
318 * If {@link ReadOptions#snapshot()} is not set, the current version of the
319 * key will be read. Calling {@link #setSnapshot()} does not affect the
320 * version of the data returned.
321 *
322 * Note that setting {@link ReadOptions#setSnapshot(Snapshot)} will affect
323 * what is read from the DB but will NOT change which keys are read from this
324 * transaction (the keys in this transaction do not yet belong to any snapshot
325 * and will be fetched regardless).
326 *
327 * @param readOptions Read options.
328 * @param columnFamilyHandles {@link java.util.List} containing
329 * {@link org.rocksdb.ColumnFamilyHandle} instances.
330 * @param keys of keys for which values need to be retrieved.
331 *
332 * @return Array of values, one for each key
333 *
334 * @throws RocksDBException thrown if error happens in underlying
335 * native library.
336 * @throws IllegalArgumentException thrown if the size of passed keys is not
337 * equal to the amount of passed column family handles.
338 */
339 public byte[][] multiGet(final ReadOptions readOptions,
340 final List<ColumnFamilyHandle> columnFamilyHandles,
341 final byte[][] keys) throws RocksDBException {
342 assert(isOwningHandle());
343 // Check if key size equals cfList size. If not a exception must be
344 // thrown. If not a Segmentation fault happens.
345 if (keys.length != columnFamilyHandles.size()) {
346 throw new IllegalArgumentException(
347 "For each key there must be a ColumnFamilyHandle.");
348 }
349 if(keys.length == 0) {
350 return new byte[0][0];
351 }
352 final long[] cfHandles = new long[columnFamilyHandles.size()];
353 for (int i = 0; i < columnFamilyHandles.size(); i++) {
354 cfHandles[i] = columnFamilyHandles.get(i).nativeHandle_;
355 }
356
357 return multiGet(nativeHandle_, readOptions.nativeHandle_,
358 keys, cfHandles);
359 }
360
361 /**
362 * This function is similar to
363 * {@link RocksDB#multiGet(ReadOptions, List)} except it will
364 * also read pending changes in this transaction.
365 * Currently, this function will return Status::MergeInProgress if the most
366 * recent write to the queried key in this batch is a Merge.
367 *
368 * If {@link ReadOptions#snapshot()} is not set, the current version of the
369 * key will be read. Calling {@link #setSnapshot()} does not affect the
370 * version of the data returned.
371 *
372 * Note that setting {@link ReadOptions#setSnapshot(Snapshot)} will affect
373 * what is read from the DB but will NOT change which keys are read from this
374 * transaction (the keys in this transaction do not yet belong to any snapshot
375 * and will be fetched regardless).
376 *
377 * @param readOptions Read options.=
378 * {@link org.rocksdb.ColumnFamilyHandle} instances.
379 * @param keys of keys for which values need to be retrieved.
380 *
381 * @return Array of values, one for each key
382 *
383 * @throws RocksDBException thrown if error happens in underlying
384 * native library.
385 */
386 public byte[][] multiGet(final ReadOptions readOptions,
387 final byte[][] keys) throws RocksDBException {
388 assert(isOwningHandle());
389 if(keys.length == 0) {
390 return new byte[0][0];
391 }
392
393 return multiGet(nativeHandle_, readOptions.nativeHandle_,
394 keys);
395 }
396
397 /**
398 * Read this key and ensure that this transaction will only
399 * be able to be committed if this key is not written outside this
400 * transaction after it has first been read (or after the snapshot if a
401 * snapshot is set in this transaction). The transaction behavior is the
402 * same regardless of whether the key exists or not.
403 *
404 * Note: Currently, this function will return Status::MergeInProgress
405 * if the most recent write to the queried key in this batch is a Merge.
406 *
407 * The values returned by this function are similar to
408 * {@link RocksDB#get(ColumnFamilyHandle, ReadOptions, byte[])}.
409 * If value==nullptr, then this function will not read any data, but will
410 * still ensure that this key cannot be written to by outside of this
411 * transaction.
412 *
413 * If this transaction was created by an {@link OptimisticTransactionDB},
414 * {@link #getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)}
415 * could cause {@link #commit()} to fail. Otherwise, it could return any error
416 * that could be returned by
417 * {@link RocksDB#get(ColumnFamilyHandle, ReadOptions, byte[])}.
418 *
419 * If this transaction was created on a {@link TransactionDB}, an
420 * {@link RocksDBException} may be thrown with an accompanying {@link Status}
421 * when:
422 * {@link Status.Code#Busy} if there is a write conflict,
423 * {@link Status.Code#TimedOut} if a lock could not be acquired,
424 * {@link Status.Code#TryAgain} if the memtable history size is not large
425 * enough. See
426 * {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
427 * {@link Status.Code#MergeInProgress} if merge operations cannot be
428 * resolved.
429 *
430 * @param readOptions Read options.
431 * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle}
432 * instance
433 * @param key the key to retrieve the value for.
434 * @param exclusive true if the transaction should have exclusive access to
435 * the key, otherwise false for shared access.
436 * @param do_validate true if it should validate the snapshot before doing the read
437 *
438 * @return a byte array storing the value associated with the input key if
439 * any. null if it does not find the specified key.
440 *
441 * @throws RocksDBException thrown if error happens in underlying
442 * native library.
443 */
444 public byte[] getForUpdate(final ReadOptions readOptions,
445 final ColumnFamilyHandle columnFamilyHandle, final byte[] key, final boolean exclusive,
446 final boolean do_validate) throws RocksDBException {
447 assert (isOwningHandle());
448 return getForUpdate(nativeHandle_, readOptions.nativeHandle_, key, key.length,
449 columnFamilyHandle.nativeHandle_, exclusive, do_validate);
450 }
451
452 /**
453 * Same as
454 * {@link #getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean, boolean)}
455 * with do_validate=true.
456 *
457 * @param readOptions Read options.
458 * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle}
459 * instance
460 * @param key the key to retrieve the value for.
461 * @param exclusive true if the transaction should have exclusive access to
462 * the key, otherwise false for shared access.
463 *
464 * @return a byte array storing the value associated with the input key if
465 * any. null if it does not find the specified key.
466 *
467 * @throws RocksDBException thrown if error happens in underlying
468 * native library.
469 */
470 public byte[] getForUpdate(final ReadOptions readOptions,
471 final ColumnFamilyHandle columnFamilyHandle, final byte[] key,
472 final boolean exclusive) throws RocksDBException {
473 assert(isOwningHandle());
474 return getForUpdate(nativeHandle_, readOptions.nativeHandle_, key, key.length,
475 columnFamilyHandle.nativeHandle_, exclusive, true /*do_validate*/);
476 }
477
478 /**
479 * Read this key and ensure that this transaction will only
480 * be able to be committed if this key is not written outside this
481 * transaction after it has first been read (or after the snapshot if a
482 * snapshot is set in this transaction). The transaction behavior is the
483 * same regardless of whether the key exists or not.
484 *
485 * Note: Currently, this function will return Status::MergeInProgress
486 * if the most recent write to the queried key in this batch is a Merge.
487 *
488 * The values returned by this function are similar to
489 * {@link RocksDB#get(ReadOptions, byte[])}.
490 * If value==nullptr, then this function will not read any data, but will
491 * still ensure that this key cannot be written to by outside of this
492 * transaction.
493 *
494 * If this transaction was created on an {@link OptimisticTransactionDB},
495 * {@link #getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)}
496 * could cause {@link #commit()} to fail. Otherwise, it could return any error
497 * that could be returned by
498 * {@link RocksDB#get(ReadOptions, byte[])}.
499 *
500 * If this transaction was created on a {@link TransactionDB}, an
501 * {@link RocksDBException} may be thrown with an accompanying {@link Status}
502 * when:
503 * {@link Status.Code#Busy} if there is a write conflict,
504 * {@link Status.Code#TimedOut} if a lock could not be acquired,
505 * {@link Status.Code#TryAgain} if the memtable history size is not large
506 * enough. See
507 * {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
508 * {@link Status.Code#MergeInProgress} if merge operations cannot be
509 * resolved.
510 *
511 * @param readOptions Read options.
512 * @param key the key to retrieve the value for.
513 * @param exclusive true if the transaction should have exclusive access to
514 * the key, otherwise false for shared access.
515 *
516 * @return a byte array storing the value associated with the input key if
517 * any. null if it does not find the specified key.
518 *
519 * @throws RocksDBException thrown if error happens in underlying
520 * native library.
521 */
522 public byte[] getForUpdate(final ReadOptions readOptions, final byte[] key,
523 final boolean exclusive) throws RocksDBException {
524 assert(isOwningHandle());
525 return getForUpdate(
526 nativeHandle_, readOptions.nativeHandle_, key, key.length, exclusive, true /*do_validate*/);
527 }
528
529 /**
530 * A multi-key version of
531 * {@link #getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)}.
532 *
533 *
534 * @param readOptions Read options.
535 * @param columnFamilyHandles {@link org.rocksdb.ColumnFamilyHandle}
536 * instances
537 * @param keys the keys to retrieve the values for.
538 *
539 * @return Array of values, one for each key
540 *
541 * @throws RocksDBException thrown if error happens in underlying
542 * native library.
543 */
544 public byte[][] multiGetForUpdate(final ReadOptions readOptions,
545 final List<ColumnFamilyHandle> columnFamilyHandles,
546 final byte[][] keys) throws RocksDBException {
547 assert(isOwningHandle());
548 // Check if key size equals cfList size. If not a exception must be
549 // thrown. If not a Segmentation fault happens.
550 if (keys.length != columnFamilyHandles.size()){
551 throw new IllegalArgumentException(
552 "For each key there must be a ColumnFamilyHandle.");
553 }
554 if(keys.length == 0) {
555 return new byte[0][0];
556 }
557 final long[] cfHandles = new long[columnFamilyHandles.size()];
558 for (int i = 0; i < columnFamilyHandles.size(); i++) {
559 cfHandles[i] = columnFamilyHandles.get(i).nativeHandle_;
560 }
561 return multiGetForUpdate(nativeHandle_, readOptions.nativeHandle_,
562 keys, cfHandles);
563 }
564
565 /**
566 * A multi-key version of {@link #getForUpdate(ReadOptions, byte[], boolean)}.
567 *
568 *
569 * @param readOptions Read options.
570 * @param keys the keys to retrieve the values for.
571 *
572 * @return Array of values, one for each key
573 *
574 * @throws RocksDBException thrown if error happens in underlying
575 * native library.
576 */
577 public byte[][] multiGetForUpdate(final ReadOptions readOptions,
578 final byte[][] keys) throws RocksDBException {
579 assert(isOwningHandle());
580 if(keys.length == 0) {
581 return new byte[0][0];
582 }
583
584 return multiGetForUpdate(nativeHandle_,
585 readOptions.nativeHandle_, keys);
586 }
587
588 /**
589 * Returns an iterator that will iterate on all keys in the default
590 * column family including both keys in the DB and uncommitted keys in this
591 * transaction.
592 *
593 * Setting {@link ReadOptions#setSnapshot(Snapshot)} will affect what is read
594 * from the DB but will NOT change which keys are read from this transaction
595 * (the keys in this transaction do not yet belong to any snapshot and will be
596 * fetched regardless).
597 *
598 * Caller is responsible for deleting the returned Iterator.
599 *
600 * The returned iterator is only valid until {@link #commit()},
601 * {@link #rollback()}, or {@link #rollbackToSavePoint()} is called.
602 *
603 * @param readOptions Read options.
604 *
605 * @return instance of iterator object.
606 */
607 public RocksIterator getIterator(final ReadOptions readOptions) {
608 assert(isOwningHandle());
609 return new RocksIterator(parent, getIterator(nativeHandle_,
610 readOptions.nativeHandle_));
611 }
612
613 /**
614 * Returns an iterator that will iterate on all keys in the default
615 * column family including both keys in the DB and uncommitted keys in this
616 * transaction.
617 *
618 * Setting {@link ReadOptions#setSnapshot(Snapshot)} will affect what is read
619 * from the DB but will NOT change which keys are read from this transaction
620 * (the keys in this transaction do not yet belong to any snapshot and will be
621 * fetched regardless).
622 *
623 * Caller is responsible for calling {@link RocksIterator#close()} on
624 * the returned Iterator.
625 *
626 * The returned iterator is only valid until {@link #commit()},
627 * {@link #rollback()}, or {@link #rollbackToSavePoint()} is called.
628 *
629 * @param readOptions Read options.
630 * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle}
631 * instance
632 *
633 * @return instance of iterator object.
634 */
635 public RocksIterator getIterator(final ReadOptions readOptions,
636 final ColumnFamilyHandle columnFamilyHandle) {
637 assert(isOwningHandle());
638 return new RocksIterator(parent, getIterator(nativeHandle_,
639 readOptions.nativeHandle_, columnFamilyHandle.nativeHandle_));
640 }
641
642 /**
643 * Similar to {@link RocksDB#put(ColumnFamilyHandle, byte[], byte[])}, but
644 * will also perform conflict checking on the keys be written.
645 *
646 * If this Transaction was created on an {@link OptimisticTransactionDB},
647 * these functions should always succeed.
648 *
649 * If this Transaction was created on a {@link TransactionDB}, an
650 * {@link RocksDBException} may be thrown with an accompanying {@link Status}
651 * when:
652 * {@link Status.Code#Busy} if there is a write conflict,
653 * {@link Status.Code#TimedOut} if a lock could not be acquired,
654 * {@link Status.Code#TryAgain} if the memtable history size is not large
655 * enough. See
656 * {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
657 *
658 * @param columnFamilyHandle The column family to put the key/value into
659 * @param key the specified key to be inserted.
660 * @param value the value associated with the specified key.
661 *
662 * @throws RocksDBException when one of the TransactionalDB conditions
663 * described above occurs, or in the case of an unexpected error
664 */
665 public void put(final ColumnFamilyHandle columnFamilyHandle, final byte[] key, final byte[] value,
666 final boolean assume_tracked) throws RocksDBException {
667 assert (isOwningHandle());
668 put(nativeHandle_, key, key.length, value, value.length, columnFamilyHandle.nativeHandle_,
669 assume_tracked);
670 }
671
672 /*
673 * Same as
674 * {@link #put(ColumnFamilyHandle, byte[], byte[], boolean)}
675 * with assume_tracked=false.
676 */
677 public void put(final ColumnFamilyHandle columnFamilyHandle, final byte[] key,
678 final byte[] value) throws RocksDBException {
679 assert(isOwningHandle());
680 put(nativeHandle_, key, key.length, value, value.length, columnFamilyHandle.nativeHandle_,
681 /*assume_tracked*/ false);
682 }
683
684 /**
685 * Similar to {@link RocksDB#put(byte[], byte[])}, but
686 * will also perform conflict checking on the keys be written.
687 *
688 * If this Transaction was created on an {@link OptimisticTransactionDB},
689 * these functions should always succeed.
690 *
691 * If this Transaction was created on a {@link TransactionDB}, an
692 * {@link RocksDBException} may be thrown with an accompanying {@link Status}
693 * when:
694 * {@link Status.Code#Busy} if there is a write conflict,
695 * {@link Status.Code#TimedOut} if a lock could not be acquired,
696 * {@link Status.Code#TryAgain} if the memtable history size is not large
697 * enough. See
698 * {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
699 *
700 * @param key the specified key to be inserted.
701 * @param value the value associated with the specified key.
702 *
703 * @throws RocksDBException when one of the TransactionalDB conditions
704 * described above occurs, or in the case of an unexpected error
705 */
706 public void put(final byte[] key, final byte[] value)
707 throws RocksDBException {
708 assert(isOwningHandle());
709 put(nativeHandle_, key, key.length, value, value.length);
710 }
711
712 //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future
713 /**
714 * Similar to {@link #put(ColumnFamilyHandle, byte[], byte[])} but allows
715 * you to specify the key and value in several parts that will be
716 * concatenated together.
717 *
718 * @param columnFamilyHandle The column family to put the key/value into
719 * @param keyParts the specified key to be inserted.
720 * @param valueParts the value associated with the specified key.
721 *
722 * @throws RocksDBException when one of the TransactionalDB conditions
723 * described above occurs, or in the case of an unexpected error
724 */
725 public void put(final ColumnFamilyHandle columnFamilyHandle, final byte[][] keyParts,
726 final byte[][] valueParts, final boolean assume_tracked) throws RocksDBException {
727 assert (isOwningHandle());
728 put(nativeHandle_, keyParts, keyParts.length, valueParts, valueParts.length,
729 columnFamilyHandle.nativeHandle_, assume_tracked);
730 }
731
732 /*
733 * Same as
734 * {@link #put(ColumnFamilyHandle, byte[][], byte[][], boolean)}
735 * with assume_tracked=false.
736 */
737 public void put(final ColumnFamilyHandle columnFamilyHandle,
738 final byte[][] keyParts, final byte[][] valueParts)
739 throws RocksDBException {
740 assert(isOwningHandle());
741 put(nativeHandle_, keyParts, keyParts.length, valueParts, valueParts.length,
742 columnFamilyHandle.nativeHandle_, /*assume_tracked*/ false);
743 }
744
745 //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future
746 /**
747 * Similar to {@link #put(byte[], byte[])} but allows
748 * you to specify the key and value in several parts that will be
749 * concatenated together
750 *
751 * @param keyParts the specified key to be inserted.
752 * @param valueParts the value associated with the specified key.
753 *
754 * @throws RocksDBException when one of the TransactionalDB conditions
755 * described above occurs, or in the case of an unexpected error
756 */
757 public void put(final byte[][] keyParts, final byte[][] valueParts)
758 throws RocksDBException {
759 assert(isOwningHandle());
760 put(nativeHandle_, keyParts, keyParts.length, valueParts,
761 valueParts.length);
762 }
763
764 /**
765 * Similar to {@link RocksDB#merge(ColumnFamilyHandle, byte[], byte[])}, but
766 * will also perform conflict checking on the keys be written.
767 *
768 * If this Transaction was created on an {@link OptimisticTransactionDB},
769 * these functions should always succeed.
770 *
771 * If this Transaction was created on a {@link TransactionDB}, an
772 * {@link RocksDBException} may be thrown with an accompanying {@link Status}
773 * when:
774 * {@link Status.Code#Busy} if there is a write conflict,
775 * {@link Status.Code#TimedOut} if a lock could not be acquired,
776 * {@link Status.Code#TryAgain} if the memtable history size is not large
777 * enough. See
778 * {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
779 *
780 * @param columnFamilyHandle The column family to merge the key/value into
781 * @param key the specified key to be merged.
782 * @param value the value associated with the specified key.
783 *
784 * @throws RocksDBException when one of the TransactionalDB conditions
785 * described above occurs, or in the case of an unexpected error
786 */
787 public void merge(final ColumnFamilyHandle columnFamilyHandle, final byte[] key,
788 final byte[] value, final boolean assume_tracked) throws RocksDBException {
789 assert (isOwningHandle());
790 merge(nativeHandle_, key, key.length, value, value.length, columnFamilyHandle.nativeHandle_,
791 assume_tracked);
792 }
793
794 /*
795 * Same as
796 * {@link #merge(ColumnFamilyHandle, byte[], byte[], boolean)}
797 * with assume_tracked=false.
798 */
799 public void merge(final ColumnFamilyHandle columnFamilyHandle,
800 final byte[] key, final byte[] value) throws RocksDBException {
801 assert(isOwningHandle());
802 merge(nativeHandle_, key, key.length, value, value.length, columnFamilyHandle.nativeHandle_,
803 /*assume_tracked*/ false);
804 }
805
806 /**
807 * Similar to {@link RocksDB#merge(byte[], byte[])}, but
808 * will also perform conflict checking on the keys be written.
809 *
810 * If this Transaction was created on an {@link OptimisticTransactionDB},
811 * these functions should always succeed.
812 *
813 * If this Transaction was created on a {@link TransactionDB}, an
814 * {@link RocksDBException} may be thrown with an accompanying {@link Status}
815 * when:
816 * {@link Status.Code#Busy} if there is a write conflict,
817 * {@link Status.Code#TimedOut} if a lock could not be acquired,
818 * {@link Status.Code#TryAgain} if the memtable history size is not large
819 * enough. See
820 * {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
821 *
822 * @param key the specified key to be merged.
823 * @param value the value associated with the specified key.
824 *
825 * @throws RocksDBException when one of the TransactionalDB conditions
826 * described above occurs, or in the case of an unexpected error
827 */
828 public void merge(final byte[] key, final byte[] value)
829 throws RocksDBException {
830 assert(isOwningHandle());
831 merge(nativeHandle_, key, key.length, value, value.length);
832 }
833
834 /**
835 * Similar to {@link RocksDB#delete(ColumnFamilyHandle, byte[])}, but
836 * will also perform conflict checking on the keys be written.
837 *
838 * If this Transaction was created on an {@link OptimisticTransactionDB},
839 * these functions should always succeed.
840 *
841 * If this Transaction was created on a {@link TransactionDB}, an
842 * {@link RocksDBException} may be thrown with an accompanying {@link Status}
843 * when:
844 * {@link Status.Code#Busy} if there is a write conflict,
845 * {@link Status.Code#TimedOut} if a lock could not be acquired,
846 * {@link Status.Code#TryAgain} if the memtable history size is not large
847 * enough. See
848 * {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
849 *
850 * @param columnFamilyHandle The column family to delete the key/value from
851 * @param key the specified key to be deleted.
852 *
853 * @throws RocksDBException when one of the TransactionalDB conditions
854 * described above occurs, or in the case of an unexpected error
855 */
856 public void delete(final ColumnFamilyHandle columnFamilyHandle, final byte[] key,
857 final boolean assume_tracked) throws RocksDBException {
858 assert (isOwningHandle());
859 delete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_, assume_tracked);
860 }
861
862 /*
863 * Same as
864 * {@link #delete(ColumnFamilyHandle, byte[], boolean)}
865 * with assume_tracked=false.
866 */
867 public void delete(final ColumnFamilyHandle columnFamilyHandle,
868 final byte[] key) throws RocksDBException {
869 assert(isOwningHandle());
870 delete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_,
871 /*assume_tracked*/ false);
872 }
873
874 /**
875 * Similar to {@link RocksDB#delete(byte[])}, but
876 * will also perform conflict checking on the keys be written.
877 *
878 * If this Transaction was created on an {@link OptimisticTransactionDB},
879 * these functions should always succeed.
880 *
881 * If this Transaction was created on a {@link TransactionDB}, an
882 * {@link RocksDBException} may be thrown with an accompanying {@link Status}
883 * when:
884 * {@link Status.Code#Busy} if there is a write conflict,
885 * {@link Status.Code#TimedOut} if a lock could not be acquired,
886 * {@link Status.Code#TryAgain} if the memtable history size is not large
887 * enough. See
888 * {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
889 *
890 * @param key the specified key to be deleted.
891 *
892 * @throws RocksDBException when one of the TransactionalDB conditions
893 * described above occurs, or in the case of an unexpected error
894 */
895 public void delete(final byte[] key) throws RocksDBException {
896 assert(isOwningHandle());
897 delete(nativeHandle_, key, key.length);
898 }
899
900 //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future
901 /**
902 * Similar to {@link #delete(ColumnFamilyHandle, byte[])} but allows
903 * you to specify the key in several parts that will be
904 * concatenated together.
905 *
906 * @param columnFamilyHandle The column family to delete the key/value from
907 * @param keyParts the specified key to be deleted.
908 *
909 * @throws RocksDBException when one of the TransactionalDB conditions
910 * described above occurs, or in the case of an unexpected error
911 */
912 public void delete(final ColumnFamilyHandle columnFamilyHandle, final byte[][] keyParts,
913 final boolean assume_tracked) throws RocksDBException {
914 assert (isOwningHandle());
915 delete(
916 nativeHandle_, keyParts, keyParts.length, columnFamilyHandle.nativeHandle_, assume_tracked);
917 }
918
919 /*
920 * Same as
921 * {@link #delete(ColumnFamilyHandle, byte[][], boolean)}
922 * with assume_tracked=false.
923 */
924 public void delete(final ColumnFamilyHandle columnFamilyHandle,
925 final byte[][] keyParts) throws RocksDBException {
926 assert(isOwningHandle());
927 delete(nativeHandle_, keyParts, keyParts.length, columnFamilyHandle.nativeHandle_,
928 /*assume_tracked*/ false);
929 }
930
931 //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future
932 /**
933 * Similar to {@link #delete(byte[])} but allows
934 * you to specify key the in several parts that will be
935 * concatenated together.
936 *
937 * @param keyParts the specified key to be deleted
938 *
939 * @throws RocksDBException when one of the TransactionalDB conditions
940 * described above occurs, or in the case of an unexpected error
941 */
942 public void delete(final byte[][] keyParts) throws RocksDBException {
943 assert(isOwningHandle());
944 delete(nativeHandle_, keyParts, keyParts.length);
945 }
946
947 /**
948 * Similar to {@link RocksDB#singleDelete(ColumnFamilyHandle, byte[])}, but
949 * will also perform conflict checking on the keys be written.
950 *
951 * If this Transaction was created on an {@link OptimisticTransactionDB},
952 * these functions should always succeed.
953 *
954 * If this Transaction was created on a {@link TransactionDB}, an
955 * {@link RocksDBException} may be thrown with an accompanying {@link Status}
956 * when:
957 * {@link Status.Code#Busy} if there is a write conflict,
958 * {@link Status.Code#TimedOut} if a lock could not be acquired,
959 * {@link Status.Code#TryAgain} if the memtable history size is not large
960 * enough. See
961 * {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
962 *
963 * @param columnFamilyHandle The column family to delete the key/value from
964 * @param key the specified key to be deleted.
965 *
966 * @throws RocksDBException when one of the TransactionalDB conditions
967 * described above occurs, or in the case of an unexpected error
968 */
969 @Experimental("Performance optimization for a very specific workload")
970 public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, final byte[] key,
971 final boolean assume_tracked) throws RocksDBException {
972 assert (isOwningHandle());
973 singleDelete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_, assume_tracked);
974 }
975
976 /*
977 * Same as
978 * {@link #singleDelete(ColumnFamilyHandle, byte[], boolean)}
979 * with assume_tracked=false.
980 */
981 @Experimental("Performance optimization for a very specific workload")
982 public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, final byte[] key)
983 throws RocksDBException {
984 assert(isOwningHandle());
985 singleDelete(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_,
986 /*assume_tracked*/ false);
987 }
988
989 /**
990 * Similar to {@link RocksDB#singleDelete(byte[])}, but
991 * will also perform conflict checking on the keys be written.
992 *
993 * If this Transaction was created on an {@link OptimisticTransactionDB},
994 * these functions should always succeed.
995 *
996 * If this Transaction was created on a {@link TransactionDB}, an
997 * {@link RocksDBException} may be thrown with an accompanying {@link Status}
998 * when:
999 * {@link Status.Code#Busy} if there is a write conflict,
1000 * {@link Status.Code#TimedOut} if a lock could not be acquired,
1001 * {@link Status.Code#TryAgain} if the memtable history size is not large
1002 * enough. See
1003 * {@link ColumnFamilyOptions#maxWriteBufferNumberToMaintain()}
1004 *
1005 * @param key the specified key to be deleted.
1006 *
1007 * @throws RocksDBException when one of the TransactionalDB conditions
1008 * described above occurs, or in the case of an unexpected error
1009 */
1010 @Experimental("Performance optimization for a very specific workload")
1011 public void singleDelete(final byte[] key) throws RocksDBException {
1012 assert(isOwningHandle());
1013 singleDelete(nativeHandle_, key, key.length);
1014 }
1015
1016 //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future
1017 /**
1018 * Similar to {@link #singleDelete(ColumnFamilyHandle, byte[])} but allows
1019 * you to specify the key in several parts that will be
1020 * concatenated together.
1021 *
1022 * @param columnFamilyHandle The column family to delete the key/value from
1023 * @param keyParts the specified key to be deleted.
1024 *
1025 * @throws RocksDBException when one of the TransactionalDB conditions
1026 * described above occurs, or in the case of an unexpected error
1027 */
1028 @Experimental("Performance optimization for a very specific workload")
1029 public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, final byte[][] keyParts,
1030 final boolean assume_tracked) throws RocksDBException {
1031 assert (isOwningHandle());
1032 singleDelete(
1033 nativeHandle_, keyParts, keyParts.length, columnFamilyHandle.nativeHandle_, assume_tracked);
1034 }
1035
1036 /*
1037 * Same as
1038 * {@link #singleDelete(ColumnFamilyHandle, byte[][], boolean)}
1039 * with assume_tracked=false.
1040 */
1041 @Experimental("Performance optimization for a very specific workload")
1042 public void singleDelete(final ColumnFamilyHandle columnFamilyHandle, final byte[][] keyParts)
1043 throws RocksDBException {
1044 assert(isOwningHandle());
1045 singleDelete(nativeHandle_, keyParts, keyParts.length, columnFamilyHandle.nativeHandle_,
1046 /*assume_tracked*/ false);
1047 }
1048
1049 //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future
1050 /**
1051 * Similar to {@link #singleDelete(byte[])} but allows
1052 * you to specify the key in several parts that will be
1053 * concatenated together.
1054 *
1055 * @param keyParts the specified key to be deleted.
1056 *
1057 * @throws RocksDBException when one of the TransactionalDB conditions
1058 * described above occurs, or in the case of an unexpected error
1059 */
1060 @Experimental("Performance optimization for a very specific workload")
1061 public void singleDelete(final byte[][] keyParts) throws RocksDBException {
1062 assert(isOwningHandle());
1063 singleDelete(nativeHandle_, keyParts, keyParts.length);
1064 }
1065
1066 /**
1067 * Similar to {@link RocksDB#put(ColumnFamilyHandle, byte[], byte[])},
1068 * but operates on the transactions write batch. This write will only happen
1069 * if this transaction gets committed successfully.
1070 *
1071 * Unlike {@link #put(ColumnFamilyHandle, byte[], byte[])} no conflict
1072 * checking will be performed for this key.
1073 *
1074 * If this Transaction was created on a {@link TransactionDB}, this function
1075 * will still acquire locks necessary to make sure this write doesn't cause
1076 * conflicts in other transactions; This may cause a {@link RocksDBException}
1077 * with associated {@link Status.Code#Busy}.
1078 *
1079 * @param columnFamilyHandle The column family to put the key/value into
1080 * @param key the specified key to be inserted.
1081 * @param value the value associated with the specified key.
1082 *
1083 * @throws RocksDBException when one of the TransactionalDB conditions
1084 * described above occurs, or in the case of an unexpected error
1085 */
1086 public void putUntracked(final ColumnFamilyHandle columnFamilyHandle,
1087 final byte[] key, final byte[] value) throws RocksDBException {
1088 assert(isOwningHandle());
1089 putUntracked(nativeHandle_, key, key.length, value, value.length,
1090 columnFamilyHandle.nativeHandle_);
1091 }
1092
1093 /**
1094 * Similar to {@link RocksDB#put(byte[], byte[])},
1095 * but operates on the transactions write batch. This write will only happen
1096 * if this transaction gets committed successfully.
1097 *
1098 * Unlike {@link #put(byte[], byte[])} no conflict
1099 * checking will be performed for this key.
1100 *
1101 * If this Transaction was created on a {@link TransactionDB}, this function
1102 * will still acquire locks necessary to make sure this write doesn't cause
1103 * conflicts in other transactions; This may cause a {@link RocksDBException}
1104 * with associated {@link Status.Code#Busy}.
1105 *
1106 * @param key the specified key to be inserted.
1107 * @param value the value associated with the specified key.
1108 *
1109 * @throws RocksDBException when one of the TransactionalDB conditions
1110 * described above occurs, or in the case of an unexpected error
1111 */
1112 public void putUntracked(final byte[] key, final byte[] value)
1113 throws RocksDBException {
1114 assert(isOwningHandle());
1115 putUntracked(nativeHandle_, key, key.length, value, value.length);
1116 }
1117
1118 //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future
1119 /**
1120 * Similar to {@link #putUntracked(ColumnFamilyHandle, byte[], byte[])} but
1121 * allows you to specify the key and value in several parts that will be
1122 * concatenated together.
1123 *
1124 * @param columnFamilyHandle The column family to put the key/value into
1125 * @param keyParts the specified key to be inserted.
1126 * @param valueParts the value associated with the specified key.
1127 *
1128 * @throws RocksDBException when one of the TransactionalDB conditions
1129 * described above occurs, or in the case of an unexpected error
1130 */
1131 public void putUntracked(final ColumnFamilyHandle columnFamilyHandle,
1132 final byte[][] keyParts, final byte[][] valueParts)
1133 throws RocksDBException {
1134 assert(isOwningHandle());
1135 putUntracked(nativeHandle_, keyParts, keyParts.length, valueParts,
1136 valueParts.length, columnFamilyHandle.nativeHandle_);
1137 }
1138
1139 //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future
1140 /**
1141 * Similar to {@link #putUntracked(byte[], byte[])} but
1142 * allows you to specify the key and value in several parts that will be
1143 * concatenated together.
1144 *
1145 * @param keyParts the specified key to be inserted.
1146 * @param valueParts the value associated with the specified key.
1147 *
1148 * @throws RocksDBException when one of the TransactionalDB conditions
1149 * described above occurs, or in the case of an unexpected error
1150 */
1151 public void putUntracked(final byte[][] keyParts, final byte[][] valueParts)
1152 throws RocksDBException {
1153 assert(isOwningHandle());
1154 putUntracked(nativeHandle_, keyParts, keyParts.length, valueParts,
1155 valueParts.length);
1156 }
1157
1158 /**
1159 * Similar to {@link RocksDB#merge(ColumnFamilyHandle, byte[], byte[])},
1160 * but operates on the transactions write batch. This write will only happen
1161 * if this transaction gets committed successfully.
1162 *
1163 * Unlike {@link #merge(ColumnFamilyHandle, byte[], byte[])} no conflict
1164 * checking will be performed for this key.
1165 *
1166 * If this Transaction was created on a {@link TransactionDB}, this function
1167 * will still acquire locks necessary to make sure this write doesn't cause
1168 * conflicts in other transactions; This may cause a {@link RocksDBException}
1169 * with associated {@link Status.Code#Busy}.
1170 *
1171 * @param columnFamilyHandle The column family to merge the key/value into
1172 * @param key the specified key to be merged.
1173 * @param value the value associated with the specified key.
1174 *
1175 * @throws RocksDBException when one of the TransactionalDB conditions
1176 * described above occurs, or in the case of an unexpected error
1177 */
1178 public void mergeUntracked(final ColumnFamilyHandle columnFamilyHandle,
1179 final byte[] key, final byte[] value) throws RocksDBException {
1180 mergeUntracked(nativeHandle_, key, key.length, value, value.length,
1181 columnFamilyHandle.nativeHandle_);
1182 }
1183
1184 /**
1185 * Similar to {@link RocksDB#merge(byte[], byte[])},
1186 * but operates on the transactions write batch. This write will only happen
1187 * if this transaction gets committed successfully.
1188 *
1189 * Unlike {@link #merge(byte[], byte[])} no conflict
1190 * checking will be performed for this key.
1191 *
1192 * If this Transaction was created on a {@link TransactionDB}, this function
1193 * will still acquire locks necessary to make sure this write doesn't cause
1194 * conflicts in other transactions; This may cause a {@link RocksDBException}
1195 * with associated {@link Status.Code#Busy}.
1196 *
1197 * @param key the specified key to be merged.
1198 * @param value the value associated with the specified key.
1199 *
1200 * @throws RocksDBException when one of the TransactionalDB conditions
1201 * described above occurs, or in the case of an unexpected error
1202 */
1203 public void mergeUntracked(final byte[] key, final byte[] value)
1204 throws RocksDBException {
1205 assert(isOwningHandle());
1206 mergeUntracked(nativeHandle_, key, key.length, value, value.length);
1207 }
1208
1209 /**
1210 * Similar to {@link RocksDB#delete(ColumnFamilyHandle, byte[])},
1211 * but operates on the transactions write batch. This write will only happen
1212 * if this transaction gets committed successfully.
1213 *
1214 * Unlike {@link #delete(ColumnFamilyHandle, byte[])} no conflict
1215 * checking will be performed for this key.
1216 *
1217 * If this Transaction was created on a {@link TransactionDB}, this function
1218 * will still acquire locks necessary to make sure this write doesn't cause
1219 * conflicts in other transactions; This may cause a {@link RocksDBException}
1220 * with associated {@link Status.Code#Busy}.
1221 *
1222 * @param columnFamilyHandle The column family to delete the key/value from
1223 * @param key the specified key to be deleted.
1224 *
1225 * @throws RocksDBException when one of the TransactionalDB conditions
1226 * described above occurs, or in the case of an unexpected error
1227 */
1228 public void deleteUntracked(final ColumnFamilyHandle columnFamilyHandle,
1229 final byte[] key) throws RocksDBException {
1230 assert(isOwningHandle());
1231 deleteUntracked(nativeHandle_, key, key.length,
1232 columnFamilyHandle.nativeHandle_);
1233 }
1234
1235 /**
1236 * Similar to {@link RocksDB#delete(byte[])},
1237 * but operates on the transactions write batch. This write will only happen
1238 * if this transaction gets committed successfully.
1239 *
1240 * Unlike {@link #delete(byte[])} no conflict
1241 * checking will be performed for this key.
1242 *
1243 * If this Transaction was created on a {@link TransactionDB}, this function
1244 * will still acquire locks necessary to make sure this write doesn't cause
1245 * conflicts in other transactions; This may cause a {@link RocksDBException}
1246 * with associated {@link Status.Code#Busy}.
1247 *
1248 * @param key the specified key to be deleted.
1249 *
1250 * @throws RocksDBException when one of the TransactionalDB conditions
1251 * described above occurs, or in the case of an unexpected error
1252 */
1253 public void deleteUntracked(final byte[] key) throws RocksDBException {
1254 assert(isOwningHandle());
1255 deleteUntracked(nativeHandle_, key, key.length);
1256 }
1257
1258 //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future
1259 /**
1260 * Similar to {@link #deleteUntracked(ColumnFamilyHandle, byte[])} but allows
1261 * you to specify the key in several parts that will be
1262 * concatenated together.
1263 *
1264 * @param columnFamilyHandle The column family to delete the key/value from
1265 * @param keyParts the specified key to be deleted.
1266 *
1267 * @throws RocksDBException when one of the TransactionalDB conditions
1268 * described above occurs, or in the case of an unexpected error
1269 */
1270 public void deleteUntracked(final ColumnFamilyHandle columnFamilyHandle,
1271 final byte[][] keyParts) throws RocksDBException {
1272 assert(isOwningHandle());
1273 deleteUntracked(nativeHandle_, keyParts, keyParts.length,
1274 columnFamilyHandle.nativeHandle_);
1275 }
1276
1277 //TODO(AR) refactor if we implement org.rocksdb.SliceParts in future
1278 /**
1279 * Similar to {@link #deleteUntracked(byte[])} but allows
1280 * you to specify the key in several parts that will be
1281 * concatenated together.
1282 *
1283 * @param keyParts the specified key to be deleted.
1284 *
1285 * @throws RocksDBException when one of the TransactionalDB conditions
1286 * described above occurs, or in the case of an unexpected error
1287 */
1288 public void deleteUntracked(final byte[][] keyParts) throws RocksDBException {
1289 assert(isOwningHandle());
1290 deleteUntracked(nativeHandle_, keyParts, keyParts.length);
1291 }
1292
1293 /**
1294 * Similar to {@link WriteBatch#putLogData(byte[])}
1295 *
1296 * @param blob binary object to be inserted
1297 */
1298 public void putLogData(final byte[] blob) {
1299 assert(isOwningHandle());
1300 putLogData(nativeHandle_, blob, blob.length);
1301 }
1302
1303 /**
1304 * By default, all put/merge/delete operations will be indexed in the
1305 * transaction so that get/getForUpdate/getIterator can search for these
1306 * keys.
1307 *
1308 * If the caller does not want to fetch the keys about to be written,
1309 * they may want to avoid indexing as a performance optimization.
1310 * Calling {@link #disableIndexing()} will turn off indexing for all future
1311 * put/merge/delete operations until {@link #enableIndexing()} is called.
1312 *
1313 * If a key is put/merge/deleted after {@link #disableIndexing()} is called
1314 * and then is fetched via get/getForUpdate/getIterator, the result of the
1315 * fetch is undefined.
1316 */
1317 public void disableIndexing() {
1318 assert(isOwningHandle());
1319 disableIndexing(nativeHandle_);
1320 }
1321
1322 /**
1323 * Re-enables indexing after a previous call to {@link #disableIndexing()}
1324 */
1325 public void enableIndexing() {
1326 assert(isOwningHandle());
1327 enableIndexing(nativeHandle_);
1328 }
1329
1330 /**
1331 * Returns the number of distinct Keys being tracked by this transaction.
1332 * If this transaction was created by a {@link TransactionDB}, this is the
1333 * number of keys that are currently locked by this transaction.
1334 * If this transaction was created by an {@link OptimisticTransactionDB},
1335 * this is the number of keys that need to be checked for conflicts at commit
1336 * time.
1337 *
1338 * @return the number of distinct Keys being tracked by this transaction
1339 */
1340 public long getNumKeys() {
1341 assert(isOwningHandle());
1342 return getNumKeys(nativeHandle_);
1343 }
1344
1345 /**
1346 * Returns the number of puts that have been applied to this
1347 * transaction so far.
1348 *
1349 * @return the number of puts that have been applied to this transaction
1350 */
1351 public long getNumPuts() {
1352 assert(isOwningHandle());
1353 return getNumPuts(nativeHandle_);
1354 }
1355
1356 /**
1357 * Returns the number of deletes that have been applied to this
1358 * transaction so far.
1359 *
1360 * @return the number of deletes that have been applied to this transaction
1361 */
1362 public long getNumDeletes() {
1363 assert(isOwningHandle());
1364 return getNumDeletes(nativeHandle_);
1365 }
1366
1367 /**
1368 * Returns the number of merges that have been applied to this
1369 * transaction so far.
1370 *
1371 * @return the number of merges that have been applied to this transaction
1372 */
1373 public long getNumMerges() {
1374 assert(isOwningHandle());
1375 return getNumMerges(nativeHandle_);
1376 }
1377
1378 /**
1379 * Returns the elapsed time in milliseconds since this Transaction began.
1380 *
1381 * @return the elapsed time in milliseconds since this transaction began.
1382 */
1383 public long getElapsedTime() {
1384 assert(isOwningHandle());
1385 return getElapsedTime(nativeHandle_);
1386 }
1387
1388 /**
1389 * Fetch the underlying write batch that contains all pending changes to be
1390 * committed.
1391 *
1392 * Note: You should not write or delete anything from the batch directly and
1393 * should only use the functions in the {@link Transaction} class to
1394 * write to this transaction.
1395 *
1396 * @return The write batch
1397 */
1398 public WriteBatchWithIndex getWriteBatch() {
1399 assert(isOwningHandle());
1400 final WriteBatchWithIndex writeBatchWithIndex =
1401 new WriteBatchWithIndex(getWriteBatch(nativeHandle_));
1402 return writeBatchWithIndex;
1403 }
1404
1405 /**
1406 * Change the value of {@link TransactionOptions#getLockTimeout()}
1407 * (in milliseconds) for this transaction.
1408 *
1409 * Has no effect on OptimisticTransactions.
1410 *
1411 * @param lockTimeout the timeout (in milliseconds) for locks used by this
1412 * transaction.
1413 */
1414 public void setLockTimeout(final long lockTimeout) {
1415 assert(isOwningHandle());
1416 setLockTimeout(nativeHandle_, lockTimeout);
1417 }
1418
1419 /**
1420 * Return the WriteOptions that will be used during {@link #commit()}.
1421 *
1422 * @return the WriteOptions that will be used
1423 */
1424 public WriteOptions getWriteOptions() {
1425 assert(isOwningHandle());
1426 final WriteOptions writeOptions =
1427 new WriteOptions(getWriteOptions(nativeHandle_));
1428 return writeOptions;
1429 }
1430
1431 /**
1432 * Reset the WriteOptions that will be used during {@link #commit()}.
1433 *
1434 * @param writeOptions The new WriteOptions
1435 */
1436 public void setWriteOptions(final WriteOptions writeOptions) {
1437 assert(isOwningHandle());
1438 setWriteOptions(nativeHandle_, writeOptions.nativeHandle_);
1439 }
1440
1441 /**
1442 * If this key was previously fetched in this transaction using
1443 * {@link #getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)}/
1444 * {@link #multiGetForUpdate(ReadOptions, List, byte[][])}, calling
1445 * {@link #undoGetForUpdate(ColumnFamilyHandle, byte[])} will tell
1446 * the transaction that it no longer needs to do any conflict checking
1447 * for this key.
1448 *
1449 * If a key has been fetched N times via
1450 * {@link #getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)}/
1451 * {@link #multiGetForUpdate(ReadOptions, List, byte[][])}, then
1452 * {@link #undoGetForUpdate(ColumnFamilyHandle, byte[])} will only have an
1453 * effect if it is also called N times. If this key has been written to in
1454 * this transaction, {@link #undoGetForUpdate(ColumnFamilyHandle, byte[])}
1455 * will have no effect.
1456 *
1457 * If {@link #setSavePoint()} has been called after the
1458 * {@link #getForUpdate(ReadOptions, ColumnFamilyHandle, byte[], boolean)},
1459 * {@link #undoGetForUpdate(ColumnFamilyHandle, byte[])} will not have any
1460 * effect.
1461 *
1462 * If this Transaction was created by an {@link OptimisticTransactionDB},
1463 * calling {@link #undoGetForUpdate(ColumnFamilyHandle, byte[])} can affect
1464 * whether this key is conflict checked at commit time.
1465 * If this Transaction was created by a {@link TransactionDB},
1466 * calling {@link #undoGetForUpdate(ColumnFamilyHandle, byte[])} may release
1467 * any held locks for this key.
1468 *
1469 * @param columnFamilyHandle {@link org.rocksdb.ColumnFamilyHandle}
1470 * instance
1471 * @param key the key to retrieve the value for.
1472 */
1473 public void undoGetForUpdate(final ColumnFamilyHandle columnFamilyHandle,
1474 final byte[] key) {
1475 assert(isOwningHandle());
1476 undoGetForUpdate(nativeHandle_, key, key.length, columnFamilyHandle.nativeHandle_);
1477 }
1478
1479 /**
1480 * If this key was previously fetched in this transaction using
1481 * {@link #getForUpdate(ReadOptions, byte[], boolean)}/
1482 * {@link #multiGetForUpdate(ReadOptions, List, byte[][])}, calling
1483 * {@link #undoGetForUpdate(byte[])} will tell
1484 * the transaction that it no longer needs to do any conflict checking
1485 * for this key.
1486 *
1487 * If a key has been fetched N times via
1488 * {@link #getForUpdate(ReadOptions, byte[], boolean)}/
1489 * {@link #multiGetForUpdate(ReadOptions, List, byte[][])}, then
1490 * {@link #undoGetForUpdate(byte[])} will only have an
1491 * effect if it is also called N times. If this key has been written to in
1492 * this transaction, {@link #undoGetForUpdate(byte[])}
1493 * will have no effect.
1494 *
1495 * If {@link #setSavePoint()} has been called after the
1496 * {@link #getForUpdate(ReadOptions, byte[], boolean)},
1497 * {@link #undoGetForUpdate(byte[])} will not have any
1498 * effect.
1499 *
1500 * If this Transaction was created by an {@link OptimisticTransactionDB},
1501 * calling {@link #undoGetForUpdate(byte[])} can affect
1502 * whether this key is conflict checked at commit time.
1503 * If this Transaction was created by a {@link TransactionDB},
1504 * calling {@link #undoGetForUpdate(byte[])} may release
1505 * any held locks for this key.
1506 *
1507 * @param key the key to retrieve the value for.
1508 */
1509 public void undoGetForUpdate(final byte[] key) {
1510 assert(isOwningHandle());
1511 undoGetForUpdate(nativeHandle_, key, key.length);
1512 }
1513
1514 /**
1515 * Adds the keys from the WriteBatch to the transaction
1516 *
1517 * @param writeBatch The write batch to read from
1518 *
1519 * @throws RocksDBException if an error occurs whilst rebuilding from the
1520 * write batch.
1521 */
1522 public void rebuildFromWriteBatch(final WriteBatch writeBatch)
1523 throws RocksDBException {
1524 assert(isOwningHandle());
1525 rebuildFromWriteBatch(nativeHandle_, writeBatch.nativeHandle_);
1526 }
1527
1528 /**
1529 * Get the Commit time Write Batch.
1530 *
1531 * @return the commit time write batch.
1532 */
1533 public WriteBatch getCommitTimeWriteBatch() {
1534 assert(isOwningHandle());
1535 final WriteBatch writeBatch =
1536 new WriteBatch(getCommitTimeWriteBatch(nativeHandle_));
1537 return writeBatch;
1538 }
1539
1540 /**
1541 * Set the log number.
1542 *
1543 * @param logNumber the log number
1544 */
1545 public void setLogNumber(final long logNumber) {
1546 assert(isOwningHandle());
1547 setLogNumber(nativeHandle_, logNumber);
1548 }
1549
1550 /**
1551 * Get the log number.
1552 *
1553 * @return the log number
1554 */
1555 public long getLogNumber() {
1556 assert(isOwningHandle());
1557 return getLogNumber(nativeHandle_);
1558 }
1559
1560 /**
1561 * Set the name of the transaction.
1562 *
1563 * @param transactionName the name of the transaction
1564 *
1565 * @throws RocksDBException if an error occurs when setting the transaction
1566 * name.
1567 */
1568 public void setName(final String transactionName) throws RocksDBException {
1569 assert(isOwningHandle());
1570 setName(nativeHandle_, transactionName);
1571 }
1572
1573 /**
1574 * Get the name of the transaction.
1575 *
1576 * @return the name of the transaction
1577 */
1578 public String getName() {
1579 assert(isOwningHandle());
1580 return getName(nativeHandle_);
1581 }
1582
1583 /**
1584 * Get the ID of the transaction.
1585 *
1586 * @return the ID of the transaction.
1587 */
1588 public long getID() {
1589 assert(isOwningHandle());
1590 return getID(nativeHandle_);
1591 }
1592
1593 /**
1594 * Determine if a deadlock has been detected.
1595 *
1596 * @return true if a deadlock has been detected.
1597 */
1598 public boolean isDeadlockDetect() {
1599 assert(isOwningHandle());
1600 return isDeadlockDetect(nativeHandle_);
1601 }
1602
1603 /**
1604 * Get the list of waiting transactions.
1605 *
1606 * @return The list of waiting transactions.
1607 */
1608 public WaitingTransactions getWaitingTxns() {
1609 assert(isOwningHandle());
1610 return getWaitingTxns(nativeHandle_);
1611 }
1612
1613 /**
1614 * Get the execution status of the transaction.
1615 *
1616 * NOTE: The execution status of an Optimistic Transaction
1617 * never changes. This is only useful for non-optimistic transactions!
1618 *
1619 * @return The execution status of the transaction
1620 */
1621 public TransactionState getState() {
1622 assert(isOwningHandle());
1623 return TransactionState.getTransactionState(
1624 getState(nativeHandle_));
1625 }
1626
1627 /**
1628 * The globally unique id with which the transaction is identified. This id
1629 * might or might not be set depending on the implementation. Similarly the
1630 * implementation decides the point in lifetime of a transaction at which it
1631 * assigns the id. Although currently it is the case, the id is not guaranteed
1632 * to remain the same across restarts.
1633 *
1634 * @return the transaction id.
1635 */
1636 @Experimental("NOTE: Experimental feature")
1637 public long getId() {
1638 assert(isOwningHandle());
1639 return getId(nativeHandle_);
1640 }
1641
1642 public enum TransactionState {
1643 STARTED((byte)0),
1644 AWAITING_PREPARE((byte)1),
1645 PREPARED((byte)2),
1646 AWAITING_COMMIT((byte)3),
1647 COMMITED((byte)4),
1648 AWAITING_ROLLBACK((byte)5),
1649 ROLLEDBACK((byte)6),
1650 LOCKS_STOLEN((byte)7);
1651
1652 private final byte value;
1653
1654 TransactionState(final byte value) {
1655 this.value = value;
1656 }
1657
1658 /**
1659 * Get TransactionState by byte value.
1660 *
1661 * @param value byte representation of TransactionState.
1662 *
1663 * @return {@link org.rocksdb.Transaction.TransactionState} instance or null.
1664 * @throws java.lang.IllegalArgumentException if an invalid
1665 * value is provided.
1666 */
1667 public static TransactionState getTransactionState(final byte value) {
1668 for (final TransactionState transactionState : TransactionState.values()) {
1669 if (transactionState.value == value){
1670 return transactionState;
1671 }
1672 }
1673 throw new IllegalArgumentException(
1674 "Illegal value provided for TransactionState.");
1675 }
1676 }
1677
1678 /**
1679 * Called from C++ native method {@link #getWaitingTxns(long)}
1680 * to construct a WaitingTransactions object.
1681 *
1682 * @param columnFamilyId The id of the {@link ColumnFamilyHandle}
1683 * @param key The key
1684 * @param transactionIds The transaction ids
1685 *
1686 * @return The waiting transactions
1687 */
1688 private WaitingTransactions newWaitingTransactions(
1689 final long columnFamilyId, final String key,
1690 final long[] transactionIds) {
1691 return new WaitingTransactions(columnFamilyId, key, transactionIds);
1692 }
1693
1694 public static class WaitingTransactions {
1695 private final long columnFamilyId;
1696 private final String key;
1697 private final long[] transactionIds;
1698
1699 private WaitingTransactions(final long columnFamilyId, final String key,
1700 final long[] transactionIds) {
1701 this.columnFamilyId = columnFamilyId;
1702 this.key = key;
1703 this.transactionIds = transactionIds;
1704 }
1705
1706 /**
1707 * Get the Column Family ID.
1708 *
1709 * @return The column family ID
1710 */
1711 public long getColumnFamilyId() {
1712 return columnFamilyId;
1713 }
1714
1715 /**
1716 * Get the key on which the transactions are waiting.
1717 *
1718 * @return The key
1719 */
1720 public String getKey() {
1721 return key;
1722 }
1723
1724 /**
1725 * Get the IDs of the waiting transactions.
1726 *
1727 * @return The IDs of the waiting transactions
1728 */
1729 public long[] getTransactionIds() {
1730 return transactionIds;
1731 }
1732 }
1733
1734 private native void setSnapshot(final long handle);
1735 private native void setSnapshotOnNextOperation(final long handle);
1736 private native void setSnapshotOnNextOperation(final long handle,
1737 final long transactionNotifierHandle);
1738 private native long getSnapshot(final long handle);
1739 private native void clearSnapshot(final long handle);
1740 private native void prepare(final long handle) throws RocksDBException;
1741 private native void commit(final long handle) throws RocksDBException;
1742 private native void rollback(final long handle) throws RocksDBException;
1743 private native void setSavePoint(final long handle) throws RocksDBException;
1744 private native void rollbackToSavePoint(final long handle)
1745 throws RocksDBException;
1746 private native byte[] get(final long handle, final long readOptionsHandle,
1747 final byte key[], final int keyLength, final long columnFamilyHandle)
1748 throws RocksDBException;
1749 private native byte[] get(final long handle, final long readOptionsHandle,
1750 final byte key[], final int keyLen) throws RocksDBException;
1751 private native byte[][] multiGet(final long handle,
1752 final long readOptionsHandle, final byte[][] keys,
1753 final long[] columnFamilyHandles) throws RocksDBException;
1754 private native byte[][] multiGet(final long handle,
1755 final long readOptionsHandle, final byte[][] keys)
1756 throws RocksDBException;
1757 private native byte[] getForUpdate(final long handle, final long readOptionsHandle,
1758 final byte key[], final int keyLength, final long columnFamilyHandle, final boolean exclusive,
1759 final boolean do_validate) throws RocksDBException;
1760 private native byte[] getForUpdate(final long handle, final long readOptionsHandle,
1761 final byte key[], final int keyLen, final boolean exclusive, final boolean do_validate)
1762 throws RocksDBException;
1763 private native byte[][] multiGetForUpdate(final long handle,
1764 final long readOptionsHandle, final byte[][] keys,
1765 final long[] columnFamilyHandles) throws RocksDBException;
1766 private native byte[][] multiGetForUpdate(final long handle,
1767 final long readOptionsHandle, final byte[][] keys)
1768 throws RocksDBException;
1769 private native long getIterator(final long handle,
1770 final long readOptionsHandle);
1771 private native long getIterator(final long handle,
1772 final long readOptionsHandle, final long columnFamilyHandle);
1773 private native void put(final long handle, final byte[] key, final int keyLength,
1774 final byte[] value, final int valueLength, final long columnFamilyHandle,
1775 final boolean assume_tracked) throws RocksDBException;
1776 private native void put(final long handle, final byte[] key,
1777 final int keyLength, final byte[] value, final int valueLength)
1778 throws RocksDBException;
1779 private native void put(final long handle, final byte[][] keys, final int keysLength,
1780 final byte[][] values, final int valuesLength, final long columnFamilyHandle,
1781 final boolean assume_tracked) throws RocksDBException;
1782 private native void put(final long handle, final byte[][] keys,
1783 final int keysLength, final byte[][] values, final int valuesLength)
1784 throws RocksDBException;
1785 private native void merge(final long handle, final byte[] key, final int keyLength,
1786 final byte[] value, final int valueLength, final long columnFamilyHandle,
1787 final boolean assume_tracked) throws RocksDBException;
1788 private native void merge(final long handle, final byte[] key,
1789 final int keyLength, final byte[] value, final int valueLength)
1790 throws RocksDBException;
1791 private native void delete(final long handle, final byte[] key, final int keyLength,
1792 final long columnFamilyHandle, final boolean assume_tracked) throws RocksDBException;
1793 private native void delete(final long handle, final byte[] key,
1794 final int keyLength) throws RocksDBException;
1795 private native void delete(final long handle, final byte[][] keys, final int keysLength,
1796 final long columnFamilyHandle, final boolean assume_tracked) throws RocksDBException;
1797 private native void delete(final long handle, final byte[][] keys,
1798 final int keysLength) throws RocksDBException;
1799 private native void singleDelete(final long handle, final byte[] key, final int keyLength,
1800 final long columnFamilyHandle, final boolean assume_tracked) throws RocksDBException;
1801 private native void singleDelete(final long handle, final byte[] key,
1802 final int keyLength) throws RocksDBException;
1803 private native void singleDelete(final long handle, final byte[][] keys, final int keysLength,
1804 final long columnFamilyHandle, final boolean assume_tracked) throws RocksDBException;
1805 private native void singleDelete(final long handle, final byte[][] keys,
1806 final int keysLength) throws RocksDBException;
1807 private native void putUntracked(final long handle, final byte[] key,
1808 final int keyLength, final byte[] value, final int valueLength,
1809 final long columnFamilyHandle) throws RocksDBException;
1810 private native void putUntracked(final long handle, final byte[] key,
1811 final int keyLength, final byte[] value, final int valueLength)
1812 throws RocksDBException;
1813 private native void putUntracked(final long handle, final byte[][] keys,
1814 final int keysLength, final byte[][] values, final int valuesLength,
1815 final long columnFamilyHandle) throws RocksDBException;
1816 private native void putUntracked(final long handle, final byte[][] keys,
1817 final int keysLength, final byte[][] values, final int valuesLength)
1818 throws RocksDBException;
1819 private native void mergeUntracked(final long handle, final byte[] key,
1820 final int keyLength, final byte[] value, final int valueLength,
1821 final long columnFamilyHandle) throws RocksDBException;
1822 private native void mergeUntracked(final long handle, final byte[] key,
1823 final int keyLength, final byte[] value, final int valueLength)
1824 throws RocksDBException;
1825 private native void deleteUntracked(final long handle, final byte[] key,
1826 final int keyLength, final long columnFamilyHandle)
1827 throws RocksDBException;
1828 private native void deleteUntracked(final long handle, final byte[] key,
1829 final int keyLength) throws RocksDBException;
1830 private native void deleteUntracked(final long handle, final byte[][] keys,
1831 final int keysLength, final long columnFamilyHandle)
1832 throws RocksDBException;
1833 private native void deleteUntracked(final long handle, final byte[][] keys,
1834 final int keysLength) throws RocksDBException;
1835 private native void putLogData(final long handle, final byte[] blob,
1836 final int blobLength);
1837 private native void disableIndexing(final long handle);
1838 private native void enableIndexing(final long handle);
1839 private native long getNumKeys(final long handle);
1840 private native long getNumPuts(final long handle);
1841 private native long getNumDeletes(final long handle);
1842 private native long getNumMerges(final long handle);
1843 private native long getElapsedTime(final long handle);
1844 private native long getWriteBatch(final long handle);
1845 private native void setLockTimeout(final long handle, final long lockTimeout);
1846 private native long getWriteOptions(final long handle);
1847 private native void setWriteOptions(final long handle,
1848 final long writeOptionsHandle);
1849 private native void undoGetForUpdate(final long handle, final byte[] key,
1850 final int keyLength, final long columnFamilyHandle);
1851 private native void undoGetForUpdate(final long handle, final byte[] key,
1852 final int keyLength);
1853 private native void rebuildFromWriteBatch(final long handle,
1854 final long writeBatchHandle) throws RocksDBException;
1855 private native long getCommitTimeWriteBatch(final long handle);
1856 private native void setLogNumber(final long handle, final long logNumber);
1857 private native long getLogNumber(final long handle);
1858 private native void setName(final long handle, final String name)
1859 throws RocksDBException;
1860 private native String getName(final long handle);
1861 private native long getID(final long handle);
1862 private native boolean isDeadlockDetect(final long handle);
1863 private native WaitingTransactions getWaitingTxns(final long handle);
1864 private native byte getState(final long handle);
1865 private native long getId(final long handle);
1866
1867 @Override protected final native void disposeInternal(final long handle);
1868 }