Module lmdbjava
Package org.lmdbjava

Enum Class EnvFlags

java.lang.Object
java.lang.Enum<EnvFlags>
org.lmdbjava.EnvFlags
All Implemented Interfaces:
Serializable, Comparable<EnvFlags>, Constable, MaskedFlag

public enum EnvFlags extends Enum<EnvFlags> implements MaskedFlag
Flags for use when opening the Env.
  • Enum Constant Details

    • MDB_FIXEDMAP

      public static final EnvFlags MDB_FIXEDMAP
      Mmap at a fixed address (experimental).

      Use a fixed address for the mmap region. This flag must be specified when creating the environment, and is stored persistently in the environment. If successful, the memory map will always reside at the same virtual address and pointers used to reference data items in the database will be constant across multiple invocations. This option may not always work, depending on how the operating system has allocated memory to shared libraries and other uses. The feature is highly experimental.

    • MDB_NOSUBDIR

      public static final EnvFlags MDB_NOSUBDIR
      No environment directory.

      By default, LMDB creates its environment in a directory whose pathname is given in path, and creates its data and lock files under that directory. With this option, path is used as-is for the database main data file. The database lock file is the path with "-lock" appended.

    • MDB_RDONLY_ENV

      public static final EnvFlags MDB_RDONLY_ENV
      Open the environment in read-only mode.

      No write operations will be allowed. LMDB will still modify the lock file - except on read-only filesystems, where LMDB does not use locks.

    • MDB_WRITEMAP

      public static final EnvFlags MDB_WRITEMAP
      Use a writeable memory map unless MDB_RDONLY_ENV is set.

      This is faster and uses fewer mallocs, but loses protection from application bugs like wild pointer writes and other bad updates into the database. Incompatible with nested transactions. Do not mix processes with and without MDB_WRITEMAP on the same environment. This can defeat durability (Env.sync(boolean) etc).

    • MDB_NOMETASYNC

      public static final EnvFlags MDB_NOMETASYNC
      Don't fsync metapage after commit.

      Flush system buffers to disk only once per transaction, omit the metadata flush. Defer that until the system flushes files to disk, or next non-MDB_RDONLY_ENV commit or Env.sync(boolean). This optimization* maintains database integrity, but a system crash may undo the last* committed transaction. I.e. it preserves the ACI (atomicity, consistency, isolation) but not D (durability) database property.

    • MDB_NOSYNC

      public static final EnvFlags MDB_NOSYNC
      Don't fsync after commit.

      Don't flush system buffers to disk when committing a transaction. This optimization means a system crash can corrupt the database or lose the last transactions if buffers are not yet flushed to disk. The risk is governed by how often the system flushes dirty buffers to disk and how often Env.sync(boolean) is called. However, if the filesystem preserves write order and the MDB_WRITEMAP flag is not used, transactions exhibit ACI (atomicity, consistency, isolation) properties and only lose D (durability). I.e. database integrity is maintained, but a system crash may undo the final transactions. Note that (MDB_NOSYNC | MDB_WRITEMAP) leaves the system with no hint for when to write transactions to disk, unless Env.sync(boolean) is called. (MDB_MAPASYNC | MDB_WRITEMAP) may be preferable.

    • MDB_MAPASYNC

      public static final EnvFlags MDB_MAPASYNC
      Use asynchronous msync when MDB_WRITEMAP is used.

      When using MDB_WRITEMAP, use asynchronous flushes to disk. As with MDB_NOSYNC, a system crash can then corrupt the database or lose the last transactions. Calling Env.sync(boolean) ensures on-disk database integrity until next commit.

    • MDB_NOTLS

      public static final EnvFlags MDB_NOTLS
      Tie reader locktable slots to Txn objects instead of to threads.

      Don't use Thread-Local Storage. Tie reader locktable slots to Txn objects instead of to threads. I.e. Txn.reset() keeps the slot reseved for the Txn object. A thread may use parallel read-only transactions. A read-only transaction may span threads if the user synchronizes its use. Applications that multiplex many user threads over individual OS threads need this option. Such an application must also serialize the write transactions in an OS thread, since LMDB's write locking is unaware of the user threads.

    • MDB_NOLOCK

      public static final EnvFlags MDB_NOLOCK
      Don't do any locking, caller must manage their own locks.

      Don't do any locking. If concurrent access is anticipated, the caller must manage all concurrency itself. For proper operation the caller must enforce single-writer semantics, and must ensure that no readers are using old transactions while a writer is active. The simplest approach is to use an exclusive lock so that no readers may be active at all when a writer begins.

    • MDB_NORDAHEAD

      public static final EnvFlags MDB_NORDAHEAD
      Don't do readahead (no effect on Windows).

      Turn off readahead. Most operating systems perform readahead on read requests by default. This option turns it off if the OS supports it. Turning it off may help random read performance when the DB is larger than RAM and system RAM is full. The option is not implemented on Windows.

    • MDB_NOMEMINIT

      public static final EnvFlags MDB_NOMEMINIT
      Don't initialize malloc'd memory before writing to datafile.

      Don't initialize malloc'd memory before writing to unused spaces in the data file. By default, memory for pages written to the data file is obtained using malloc. While these pages may be reused in subsequent transactions, freshly malloc'd pages will be initialized to zeroes before use. This avoids persisting leftover data from other code (that used the heap and subsequently freed the memory) into the data file. Note that many other system libraries may allocate and free memory from the heap for arbitrary uses. E.g., stdio may use the heap for file I/O buffers. This initialization step has a modest performance cost so some applications may want to disable it using this flag. This option can be a problem for applications which handle sensitive data like passwords, and it makes memory checkers like Valgrind noisy. This flag is not needed with MDB_WRITEMAP, which writes directly to the mmap instead of using malloc for pages. The initialization is also skipped if PutFlags.MDB_RESERVE is used; the caller is expected to overwrite all of the memory that was reserved in that case.

  • Method Details

    • values

      public static EnvFlags[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static EnvFlags valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getMask

      public int getMask()
      Description copied from interface: MaskedFlag
      Obtains the integer value for this enum which can be included in a mask.
      Specified by:
      getMask in interface MaskedFlag
      Returns:
      the integer value for combination into a mask