Package org.rocksdb

Class TransactionDBOptions

All Implemented Interfaces:
AutoCloseable

public class TransactionDBOptions extends RocksObject
  • Constructor Details

    • TransactionDBOptions

      public TransactionDBOptions()
  • Method Details

    • 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 than #getMaxNumLocks(), 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 than getMaxNumLocks(), 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 by TransactionOptions.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 by TransactionOptions.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 calling RocksDB.put(byte[], byte[]), RocksDB.merge(byte[], byte[]), RocksDB.delete(byte[]) or RocksDB.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 calling RocksDB.put(byte[], byte[]), RocksDB.merge(byte[], byte[]), RocksDB.delete(byte[]) or RocksDB.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 data TxnDBWritePolicy.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 data TxnDBWritePolicy.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:
      disposeInternal in class RocksObject