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 
9 interface TransactionalDB<T extends TransactionalOptions>
10     extends AutoCloseable {
11 
12   /**
13    * Starts a new Transaction.
14    *
15    * Caller is responsible for calling {@link #close()} on the returned
16    * transaction when it is no longer needed.
17    *
18    * @param writeOptions Any write options for the transaction
19    * @return a new transaction
20    */
beginTransaction(final WriteOptions writeOptions)21   Transaction beginTransaction(final WriteOptions writeOptions);
22 
23   /**
24    * Starts a new Transaction.
25    *
26    * Caller is responsible for calling {@link #close()} on the returned
27    * transaction when it is no longer needed.
28    *
29    * @param writeOptions Any write options for the transaction
30    * @param transactionOptions Any options for the transaction
31    * @return a new transaction
32    */
beginTransaction(final WriteOptions writeOptions, final T transactionOptions)33   Transaction beginTransaction(final WriteOptions writeOptions,
34       final T transactionOptions);
35 
36   /**
37    * Starts a new Transaction.
38    *
39    * Caller is responsible for calling {@link #close()} on the returned
40    * transaction when it is no longer needed.
41    *
42    * @param writeOptions Any write options for the transaction
43    * @param oldTransaction this Transaction will be reused instead of allocating
44    *     a new one. This is an optimization to avoid extra allocations
45    *     when repeatedly creating transactions.
46    * @return The oldTransaction which has been reinitialized as a new
47    *     transaction
48    */
beginTransaction(final WriteOptions writeOptions, final Transaction oldTransaction)49   Transaction beginTransaction(final WriteOptions writeOptions,
50       final Transaction oldTransaction);
51 
52   /**
53    * Starts a new Transaction.
54    *
55    * Caller is responsible for calling {@link #close()} on the returned
56    * transaction when it is no longer needed.
57    *
58    * @param writeOptions Any write options for the transaction
59    * @param transactionOptions Any options for the transaction
60    * @param oldTransaction this Transaction will be reused instead of allocating
61    *     a new one. This is an optimization to avoid extra allocations
62    *     when repeatedly creating transactions.
63    * @return The oldTransaction which has been reinitialized as a new
64    *     transaction
65    */
beginTransaction(final WriteOptions writeOptions, final T transactionOptions, final Transaction oldTransaction)66   Transaction beginTransaction(final WriteOptions writeOptions,
67       final T transactionOptions, final Transaction oldTransaction);
68 }
69