Module lmdbjava
Package org.lmdbjava

Class Txn<T>

java.lang.Object
org.lmdbjava.Txn<T>
Type Parameters:
T - buffer type
All Implemented Interfaces:
AutoCloseable

public final class Txn<T> extends Object implements AutoCloseable
LMDB transaction.
  • Method Details

    • abort

      public void abort()
      Aborts this transaction.
    • close

      public void close()
      Closes this transaction by aborting if not already committed.

      Closing the transaction will invoke BufferProxy.deallocate(java.lang.Object) for each read-only buffer (ie the key and value).

      Specified by:
      close in interface AutoCloseable
    • commit

      public void commit()
      Commits this transaction.
    • getId

      public long getId()
      Return the transaction's ID.
      Returns:
      A transaction ID, valid if input is an active transaction
    • getParent

      public Txn<T> getParent()
      Obtains this transaction's parent.
      Returns:
      the parent transaction (may be null)
    • isReadOnly

      public boolean isReadOnly()
      Whether this transaction is read-only.
      Returns:
      if read-only
    • key

      public T key()
      Fetch the buffer which holds a read-only view of the LMDI allocated memory. Any use of this buffer must comply with the standard LMDB C "mdb_get" contract (ie do not modify, do not attempt to release the memory, do not use once the transaction or cursor closes, do not use after a write etc).
      Returns:
      the key buffer (never null)
    • renew

      public void renew()
      Renews a read-only transaction previously released by reset().
    • reset

      public void reset()
      Aborts this read-only transaction and resets the transaction handle so it can be reused upon calling renew().
    • val

      public T val()
      Fetch the buffer which holds a read-only view of the LMDI allocated memory. Any use of this buffer must comply with the standard LMDB C "mdb_get" contract (ie do not modify, do not attempt to release the memory, do not use once the transaction or cursor closes, do not use after a write etc).
      Returns:
      the value buffer (never null)
    • checkReadOnly

      public void checkReadOnly()
    • checkReady

      public void checkReady()
    • checkWritesAllowed

      public void checkWritesAllowed()
    • getState

      public Txn.State getState()
      Return the state of the transaction.
      Returns:
      the state