Package org.rocksdb
Class TransactionDBOptions
- java.lang.Object
-
- org.rocksdb.AbstractNativeReference
-
- org.rocksdb.AbstractImmutableNativeReference
-
- org.rocksdb.RocksObject
-
- org.rocksdb.TransactionDBOptions
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class TransactionDBOptions extends RocksObject
-
-
Field Summary
-
Fields inherited from class org.rocksdb.RocksObject
nativeHandle_
-
Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_
-
-
Constructor Summary
Constructors Constructor Description TransactionDBOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddisposeInternal(long handle)longgetDefaultLockTimeout()The wait timeout in milliseconds when writing a key OUTSIDE of a transaction (ie by callingRocksDB.put(byte[], byte[]),RocksDB.merge(byte[], byte[]),RocksDB.delete(byte[])orRocksDB.write(org.rocksdb.WriteOptions, org.rocksdb.WriteBatch)directly).longgetMaxNumLocks()Specifies the maximum number of keys that can be locked at the same time per column family.longgetNumStripes()The number of sub-tables per lock table (per column family)longgetTransactionLockTimeout()The default wait timeout in milliseconds when a transaction attempts to lock a key if not specified byTransactionOptions.setLockTimeout(long)If 0, no waiting is done if a lock cannot instantly be acquired.TxnDBWritePolicygetWritePolicy()The policy for when to write the data into the DB.TransactionDBOptionssetDefaultLockTimeout(long defaultLockTimeout)If positive, specifies the wait timeout in milliseconds when writing a key OUTSIDE of a transaction (ie by callingRocksDB.put(byte[], byte[]),RocksDB.merge(byte[], byte[]),RocksDB.delete(byte[])orRocksDB.write(org.rocksdb.WriteOptions, org.rocksdb.WriteBatch)directly).TransactionDBOptionssetMaxNumLocks(long maxNumLocks)Specifies the maximum number of keys that can be locked at the same time per column family.TransactionDBOptionssetNumStripes(long numStripes)Increasing this value will increase the concurrency by dividing the lock table (per column family) into more sub-tables, each with their own separate mutex.TransactionDBOptionssetTransactionLockTimeout(long transactionLockTimeout)If positive, specifies the default wait timeout in milliseconds when a transaction attempts to lock a key if not specified byTransactionOptions.setLockTimeout(long)If 0, no waiting is done if a lock cannot instantly be acquired.TransactionDBOptionssetWritePolicy(TxnDBWritePolicy writePolicy)The policy for when to write the data into the DB.-
Methods inherited from class org.rocksdb.RocksObject
disposeInternal, getNativeHandle
-
Methods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
Methods inherited from class org.rocksdb.AbstractNativeReference
dispose, finalize
-
-
-
-
Method Detail
-
getMaxNumLocks
public long getMaxNumLocks()
Specifies the maximum number of keys that can be locked at the same time per column family. If the number of locked keys is greater thangetMaxNumLocks(), transaction writes (or GetForUpdate) will return an error.- Returns:
- The maximum number of keys that can be locked
-
setMaxNumLocks
public TransactionDBOptions setMaxNumLocks(long maxNumLocks)
Specifies the maximum number of keys that can be locked at the same time per column family. If the number of locked keys is greater thangetMaxNumLocks(), transaction writes (or GetForUpdate) will return an error.- Parameters:
maxNumLocks- The maximum number of keys that can be locked; If this value is not positive, no limit will be enforced.- Returns:
- this TransactionDBOptions instance
-
getNumStripes
public long getNumStripes()
The number of sub-tables per lock table (per column family)- Returns:
- The number of sub-tables
-
setNumStripes
public TransactionDBOptions setNumStripes(long numStripes)
Increasing this value will increase the concurrency by dividing the lock table (per column family) into more sub-tables, each with their own separate mutex. Default: 16- Parameters:
numStripes- The number of sub-tables- Returns:
- this TransactionDBOptions instance
-
getTransactionLockTimeout
public long getTransactionLockTimeout()
The default wait timeout in milliseconds when a transaction attempts to lock a key if not specified byTransactionOptions.setLockTimeout(long)If 0, no waiting is done if a lock cannot instantly be acquired. If negative, there is no timeout.- Returns:
- the default wait timeout in milliseconds
-
setTransactionLockTimeout
public TransactionDBOptions setTransactionLockTimeout(long transactionLockTimeout)
If positive, specifies the default wait timeout in milliseconds when a transaction attempts to lock a key if not specified byTransactionOptions.setLockTimeout(long)If 0, no waiting is done if a lock cannot instantly be acquired. If negative, there is no timeout. Not using a timeout is not recommended as it can lead to deadlocks. Currently, there is no deadlock-detection to recover from a deadlock. Default: 1000- Parameters:
transactionLockTimeout- the default wait timeout in milliseconds- Returns:
- this TransactionDBOptions instance
-
getDefaultLockTimeout
public long getDefaultLockTimeout()
The wait timeout in milliseconds when writing a key OUTSIDE of a transaction (ie by callingRocksDB.put(byte[], byte[]),RocksDB.merge(byte[], byte[]),RocksDB.delete(byte[])orRocksDB.write(org.rocksdb.WriteOptions, org.rocksdb.WriteBatch)directly). If 0, no waiting is done if a lock cannot instantly be acquired. If negative, there is no timeout and will block indefinitely when acquiring a lock.- Returns:
- the timeout in milliseconds when writing a key OUTSIDE of a transaction
-
setDefaultLockTimeout
public TransactionDBOptions setDefaultLockTimeout(long defaultLockTimeout)
If positive, specifies the wait timeout in milliseconds when writing a key OUTSIDE of a transaction (ie by callingRocksDB.put(byte[], byte[]),RocksDB.merge(byte[], byte[]),RocksDB.delete(byte[])orRocksDB.write(org.rocksdb.WriteOptions, org.rocksdb.WriteBatch)directly). If 0, no waiting is done if a lock cannot instantly be acquired. If negative, there is no timeout and will block indefinitely when acquiring a lock. Not using a timeout can lead to deadlocks. Currently, there is no deadlock-detection to recover from a deadlock. While DB writes cannot deadlock with other DB writes, they can deadlock with a transaction. A negative timeout should only be used if all transactions have a small expiration set. Default: 1000- Parameters:
defaultLockTimeout- the timeout in milliseconds when writing a key OUTSIDE of a transaction- Returns:
- this TransactionDBOptions instance
-
getWritePolicy
public TxnDBWritePolicy getWritePolicy()
The policy for when to write the data into the DB. The default policy is to write only the committed dataTxnDBWritePolicy.WRITE_COMMITTED. The data could be written before the commit phase. The DB then needs to provide the mechanisms to tell apart committed from uncommitted data.- Returns:
- The write policy.
-
setWritePolicy
public TransactionDBOptions setWritePolicy(TxnDBWritePolicy writePolicy)
The policy for when to write the data into the DB. The default policy is to write only the committed dataTxnDBWritePolicy.WRITE_COMMITTED. The data could be written before the commit phase. The DB then needs to provide the mechanisms to tell apart committed from uncommitted data.- Parameters:
writePolicy- The write policy.- Returns:
- this TransactionDBOptions instance
-
disposeInternal
protected final void disposeInternal(long handle)
- Specified by:
disposeInternalin classRocksObject
-
-