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 public class OptimisticTransactionOptions extends RocksObject
9     implements TransactionalOptions<OptimisticTransactionOptions> {
10 
OptimisticTransactionOptions()11   public OptimisticTransactionOptions() {
12     super(newOptimisticTransactionOptions());
13   }
14 
15   @Override
isSetSnapshot()16   public boolean isSetSnapshot() {
17     assert(isOwningHandle());
18     return isSetSnapshot(nativeHandle_);
19   }
20 
21   @Override
setSetSnapshot( final boolean setSnapshot)22   public OptimisticTransactionOptions setSetSnapshot(
23       final boolean setSnapshot) {
24     assert(isOwningHandle());
25     setSetSnapshot(nativeHandle_, setSnapshot);
26     return this;
27   }
28 
29   /**
30    * Should be set if the DB has a non-default comparator.
31    * See comment in
32    * {@link WriteBatchWithIndex#WriteBatchWithIndex(AbstractComparator, int, boolean)}
33    * constructor.
34    *
35    * @param comparator The comparator to use for the transaction.
36    *
37    * @return this OptimisticTransactionOptions instance
38    */
setComparator( final AbstractComparator comparator)39   public OptimisticTransactionOptions setComparator(
40       final AbstractComparator comparator) {
41     assert(isOwningHandle());
42     setComparator(nativeHandle_, comparator.nativeHandle_);
43     return this;
44   }
45 
newOptimisticTransactionOptions()46   private native static long newOptimisticTransactionOptions();
isSetSnapshot(final long handle)47   private native boolean isSetSnapshot(final long handle);
setSetSnapshot(final long handle, final boolean setSnapshot)48   private native void setSetSnapshot(final long handle,
49       final boolean setSnapshot);
setComparator(final long handle, final long comparatorHandle)50   private native void setComparator(final long handle,
51       final long comparatorHandle);
disposeInternal(final long handle)52   @Override protected final native void disposeInternal(final long handle);
53 }
54