|
|
@ -3,8 +3,9 @@ use libc::c_uint; |
|
|
|
use ffi::*; |
|
|
|
use ffi::*; |
|
|
|
|
|
|
|
|
|
|
|
bitflags! { |
|
|
|
bitflags! { |
|
|
|
#[doc="Environment Options"] |
|
|
|
#[doc="Environment options."] |
|
|
|
flags EnvironmentFlags: c_uint { |
|
|
|
#[derive(Default)] |
|
|
|
|
|
|
|
pub struct EnvironmentFlags: c_uint { |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Use a fixed address for the mmap region. This flag must be specified"] |
|
|
|
#[doc="Use a fixed address for the mmap region. This flag must be specified"] |
|
|
|
#[doc="when creating the environment, and is stored persistently in the environment."] |
|
|
|
#[doc="when creating the environment, and is stored persistently in the environment."] |
|
|
@ -13,25 +14,25 @@ bitflags! { |
|
|
|
#[doc="across multiple invocations. This option may not always work, depending on"] |
|
|
|
#[doc="across multiple invocations. This option may not always work, depending on"] |
|
|
|
#[doc="how the operating system has allocated memory to shared libraries and other uses."] |
|
|
|
#[doc="how the operating system has allocated memory to shared libraries and other uses."] |
|
|
|
#[doc="The feature is highly experimental."] |
|
|
|
#[doc="The feature is highly experimental."] |
|
|
|
const FIXED_MAP = MDB_FIXEDMAP, |
|
|
|
const FIXED_MAP = MDB_FIXEDMAP; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="By default, LMDB creates its environment in a directory whose pathname is given in"] |
|
|
|
#[doc="By default, LMDB creates its environment in a directory whose pathname is given in"] |
|
|
|
#[doc="`path`, and creates its data and lock files under that directory. With this option,"] |
|
|
|
#[doc="`path`, and creates its data and lock files under that directory. With this option,"] |
|
|
|
#[doc="`path` is used as-is for the database main data file. The database lock file is the"] |
|
|
|
#[doc="`path` is used as-is for the database main data file. The database lock file is the"] |
|
|
|
#[doc="`path` with `-lock` appended."] |
|
|
|
#[doc="`path` with `-lock` appended."] |
|
|
|
const NO_SUB_DIR = MDB_NOSUBDIR, |
|
|
|
const NO_SUB_DIR = MDB_NOSUBDIR; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Use a writeable memory map unless `READ_ONLY` is set. This is faster and uses"] |
|
|
|
#[doc="Use a writeable memory map unless `READ_ONLY` is set. This is faster and uses"] |
|
|
|
#[doc="fewer mallocs, but loses protection from application bugs like wild pointer writes"] |
|
|
|
#[doc="fewer mallocs, but loses protection from application bugs like wild pointer writes"] |
|
|
|
#[doc="and other bad updates into the database. Incompatible with nested transactions."] |
|
|
|
#[doc="and other bad updates into the database. Incompatible with nested transactions."] |
|
|
|
#[doc="Processes with and without `WRITE_MAP` on the same environment do not cooperate"] |
|
|
|
#[doc="Processes with and without `WRITE_MAP` on the same environment do not cooperate"] |
|
|
|
#[doc="well."] |
|
|
|
#[doc="well."] |
|
|
|
const WRITE_MAP = MDB_WRITEMAP, |
|
|
|
const WRITE_MAP = MDB_WRITEMAP; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Open the environment in read-only mode. No write operations will be allowed."] |
|
|
|
#[doc="Open the environment in read-only mode. No write operations will be allowed."] |
|
|
|
#[doc="When opening an environment, LMDB will still modify the lock file - except on"] |
|
|
|
#[doc="When opening an environment, LMDB will still modify the lock file - except on"] |
|
|
|
#[doc="read-only filesystems, where LMDB does not use locks."] |
|
|
|
#[doc="read-only filesystems, where LMDB does not use locks."] |
|
|
|
const READ_ONLY = MDB_RDONLY, |
|
|
|
const READ_ONLY = MDB_RDONLY; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Flush system buffers to disk only once per transaction, omit the metadata flush."] |
|
|
|
#[doc="Flush system buffers to disk only once per transaction, omit the metadata flush."] |
|
|
|
#[doc="Defer that until the system flushes files to disk, or next non-`READ_ONLY` commit"] |
|
|
|
#[doc="Defer that until the system flushes files to disk, or next non-`READ_ONLY` commit"] |
|
|
@ -39,7 +40,7 @@ bitflags! { |
|
|
|
#[doc="system crash may undo the last committed transaction. I.e. it preserves the ACI"] |
|
|
|
#[doc="system crash may undo the last committed transaction. I.e. it preserves the ACI"] |
|
|
|
#[doc="(atomicity, consistency, isolation) but not D (durability) database property."] |
|
|
|
#[doc="(atomicity, consistency, isolation) but not D (durability) database property."] |
|
|
|
#[doc="\n\nThis flag may be changed at any time using `Environment::set_flags`."] |
|
|
|
#[doc="\n\nThis flag may be changed at any time using `Environment::set_flags`."] |
|
|
|
const NO_META_SYNC = MDB_NOMETASYNC, |
|
|
|
const NO_META_SYNC = MDB_NOMETASYNC; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Don't flush system buffers to disk when committing a transaction. This optimization"] |
|
|
|
#[doc="Don't flush system buffers to disk when committing a transaction. This optimization"] |
|
|
|
#[doc="means a system crash can corrupt the database or lose the last transactions if"] |
|
|
|
#[doc="means a system crash can corrupt the database or lose the last transactions if"] |
|
|
@ -52,36 +53,36 @@ bitflags! { |
|
|
|
#[doc="system with no hint for when to write transactions to disk, unless"] |
|
|
|
#[doc="system with no hint for when to write transactions to disk, unless"] |
|
|
|
#[doc="`Environment::sync` is called. (`MAP_ASYNC | WRITE_MAP`) may be preferable."] |
|
|
|
#[doc="`Environment::sync` is called. (`MAP_ASYNC | WRITE_MAP`) may be preferable."] |
|
|
|
#[doc="\n\nThis flag may be changed at any time using `Environment::set_flags`."] |
|
|
|
#[doc="\n\nThis flag may be changed at any time using `Environment::set_flags`."] |
|
|
|
const NO_SYNC = MDB_NOSYNC, |
|
|
|
const NO_SYNC = MDB_NOSYNC; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="When using `WRITE_MAP`, use asynchronous flushes to disk. As with `NO_SYNC`, a"] |
|
|
|
#[doc="When using `WRITE_MAP`, use asynchronous flushes to disk. As with `NO_SYNC`, a"] |
|
|
|
#[doc="system crash can then corrupt the database or lose the last transactions. Calling"] |
|
|
|
#[doc="system crash can then corrupt the database or lose the last transactions. Calling"] |
|
|
|
#[doc="`Environment::sync` ensures on-disk database integrity until next commit."] |
|
|
|
#[doc="`Environment::sync` ensures on-disk database integrity until next commit."] |
|
|
|
#[doc="\n\nThis flag may be changed at any time using `Environment::set_flags`."] |
|
|
|
#[doc="\n\nThis flag may be changed at any time using `Environment::set_flags`."] |
|
|
|
const MAP_ASYNC = MDB_MAPASYNC, |
|
|
|
const MAP_ASYNC = MDB_MAPASYNC; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Don't use thread-local storage. Tie reader locktable slots to transaction objects"] |
|
|
|
#[doc="Don't use thread-local storage. Tie reader locktable slots to transaction objects"] |
|
|
|
#[doc="instead of to threads. I.e. `RoTransaction::reset` keeps the slot reseved for the"] |
|
|
|
#[doc="instead of to threads. I.e. `RoTransaction::reset` keeps the slot reserved for the"] |
|
|
|
#[doc="transaction object. A thread may use parallel read-only transactions. A read-only"] |
|
|
|
#[doc="transaction object. A thread may use parallel read-only transactions. A read-only"] |
|
|
|
#[doc="transaction may span threads if the user synchronizes its use. Applications that"] |
|
|
|
#[doc="transaction may span threads if the user synchronizes its use. Applications that"] |
|
|
|
#[doc="multiplex many the user synchronizes its use. Applications that multiplex many user"] |
|
|
|
#[doc="multiplex many the user synchronizes its use. Applications that multiplex many user"] |
|
|
|
#[doc="threads over individual OS threads need this option. Such an application must also"] |
|
|
|
#[doc="threads over individual OS threads need this option. Such an application must also"] |
|
|
|
#[doc="serialize the write transactions in an OS thread, since LMDB's write locking is"] |
|
|
|
#[doc="serialize the write transactions in an OS thread, since LMDB's write locking is"] |
|
|
|
#[doc="unaware of the user threads."] |
|
|
|
#[doc="unaware of the user threads."] |
|
|
|
const NO_TLS = MDB_NOTLS, |
|
|
|
const NO_TLS = MDB_NOTLS; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Do not do any locking. If concurrent access is anticipated, the caller must manage"] |
|
|
|
#[doc="Do not do any locking. If concurrent access is anticipated, the caller must manage"] |
|
|
|
#[doc="all concurrency themself. For proper operation the caller must enforce"] |
|
|
|
#[doc="all concurrency themself. For proper operation the caller must enforce"] |
|
|
|
#[doc="single-writer semantics, and must ensure that no readers are using old"] |
|
|
|
#[doc="single-writer semantics, and must ensure that no readers are using old"] |
|
|
|
#[doc="transactions while a writer is active. The simplest approach is to use an exclusive"] |
|
|
|
#[doc="transactions while a writer is active. The simplest approach is to use an exclusive"] |
|
|
|
#[doc="lock so that no readers may be active at all when a writer begins."] |
|
|
|
#[doc="lock so that no readers may be active at all when a writer begins."] |
|
|
|
const NO_LOCK = MDB_NOLOCK, |
|
|
|
const NO_LOCK = MDB_NOLOCK; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Turn off readahead. Most operating systems perform readahead on read requests by"] |
|
|
|
#[doc="Turn off readahead. Most operating systems perform readahead on read requests by"] |
|
|
|
#[doc="default. This option turns it off if the OS supports it. Turning it off may help"] |
|
|
|
#[doc="default. This option turns it off if the OS supports it. Turning it off may help"] |
|
|
|
#[doc="random read performance when the DB is larger than RAM and system RAM is full."] |
|
|
|
#[doc="random read performance when the DB is larger than RAM and system RAM is full."] |
|
|
|
#[doc="The option is not implemented on Windows."] |
|
|
|
#[doc="The option is not implemented on Windows."] |
|
|
|
const NO_READAHEAD = MDB_NORDAHEAD, |
|
|
|
const NO_READAHEAD = MDB_NORDAHEAD; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Do not initialize malloc'd memory before writing to unused spaces in the data file."] |
|
|
|
#[doc="Do not initialize malloc'd memory before writing to unused spaces in the data file."] |
|
|
|
#[doc="By default, memory for pages written to the data file is obtained using malloc."] |
|
|
|
#[doc="By default, memory for pages written to the data file is obtained using malloc."] |
|
|
@ -98,73 +99,75 @@ bitflags! { |
|
|
|
#[doc="with reserve; the caller is expected to overwrite all of the memory that was"] |
|
|
|
#[doc="with reserve; the caller is expected to overwrite all of the memory that was"] |
|
|
|
#[doc="reserved in that case."] |
|
|
|
#[doc="reserved in that case."] |
|
|
|
#[doc="\n\nThis flag may be changed at any time using `Environment::set_flags`."] |
|
|
|
#[doc="\n\nThis flag may be changed at any time using `Environment::set_flags`."] |
|
|
|
const NO_MEM_INIT = MDB_NOMEMINIT, |
|
|
|
const NO_MEM_INIT = MDB_NOMEMINIT; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bitflags! { |
|
|
|
bitflags! { |
|
|
|
#[doc="Database Options"] |
|
|
|
#[doc="Database options."] |
|
|
|
flags DatabaseFlags: c_uint { |
|
|
|
#[derive(Default)] |
|
|
|
|
|
|
|
pub struct DatabaseFlags: c_uint { |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Keys are strings to be compared in reverse order, from the end of the strings"] |
|
|
|
#[doc="Keys are strings to be compared in reverse order, from the end of the strings"] |
|
|
|
#[doc="to the beginning. By default, Keys are treated as strings and compared from"] |
|
|
|
#[doc="to the beginning. By default, Keys are treated as strings and compared from"] |
|
|
|
#[doc="beginning to end."] |
|
|
|
#[doc="beginning to end."] |
|
|
|
const REVERSE_KEY = MDB_REVERSEKEY, |
|
|
|
const REVERSE_KEY = MDB_REVERSEKEY; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Duplicate keys may be used in the database. (Or, from another perspective,"] |
|
|
|
#[doc="Duplicate keys may be used in the database. (Or, from another perspective,"] |
|
|
|
#[doc="keys may have multiple data items, stored in sorted order.) By default"] |
|
|
|
#[doc="keys may have multiple data items, stored in sorted order.) By default"] |
|
|
|
#[doc="keys must be unique and may have only a single data item."] |
|
|
|
#[doc="keys must be unique and may have only a single data item."] |
|
|
|
const DUP_SORT = MDB_DUPSORT, |
|
|
|
const DUP_SORT = MDB_DUPSORT; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Keys are binary integers in native byte order. Setting this option requires all"] |
|
|
|
#[doc="Keys are binary integers in native byte order. Setting this option requires all"] |
|
|
|
#[doc="keys to be the same size, typically 32 or 64 bits."] |
|
|
|
#[doc="keys to be the same size, typically 32 or 64 bits."] |
|
|
|
const INTEGER_KEY = MDB_INTEGERKEY, |
|
|
|
const INTEGER_KEY = MDB_INTEGERKEY; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="This flag may only be used in combination with `DUP_SORT`. This option tells"] |
|
|
|
#[doc="This flag may only be used in combination with `DUP_SORT`. This option tells"] |
|
|
|
#[doc="the library that the data items for this database are all the same size, which"] |
|
|
|
#[doc="the library that the data items for this database are all the same size, which"] |
|
|
|
#[doc="allows further optimizations in storage and retrieval. When all data items are"] |
|
|
|
#[doc="allows further optimizations in storage and retrieval. When all data items are"] |
|
|
|
#[doc="the same size, the `GET_MULTIPLE` and `NEXT_MULTIPLE` cursor operations may be"] |
|
|
|
#[doc="the same size, the `GET_MULTIPLE` and `NEXT_MULTIPLE` cursor operations may be"] |
|
|
|
#[doc="used to retrieve multiple items at once."] |
|
|
|
#[doc="used to retrieve multiple items at once."] |
|
|
|
const DUP_FIXED = MDB_DUPFIXED, |
|
|
|
const DUP_FIXED = MDB_DUPFIXED; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="This option specifies that duplicate data items are also integers, and"] |
|
|
|
#[doc="This option specifies that duplicate data items are also integers, and"] |
|
|
|
#[doc="should be sorted as such."] |
|
|
|
#[doc="should be sorted as such."] |
|
|
|
const INTEGER_DUP = MDB_INTEGERDUP, |
|
|
|
const INTEGER_DUP = MDB_INTEGERDUP; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="This option specifies that duplicate data items should be compared as strings"] |
|
|
|
#[doc="This option specifies that duplicate data items should be compared as strings"] |
|
|
|
#[doc="in reverse order."] |
|
|
|
#[doc="in reverse order."] |
|
|
|
const REVERSE_DUP = MDB_REVERSEDUP, |
|
|
|
const REVERSE_DUP = MDB_REVERSEDUP; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bitflags! { |
|
|
|
bitflags! { |
|
|
|
#[doc="Write Options"] |
|
|
|
#[doc="Write options."] |
|
|
|
flags WriteFlags: c_uint { |
|
|
|
#[derive(Default)] |
|
|
|
|
|
|
|
pub struct WriteFlags: c_uint { |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Insert the new item only if the key does not already appear in the database."] |
|
|
|
#[doc="Insert the new item only if the key does not already appear in the database."] |
|
|
|
#[doc="The function will return `LmdbError::KeyExist` if the key already appears in the"] |
|
|
|
#[doc="The function will return `LmdbError::KeyExist` if the key already appears in the"] |
|
|
|
#[doc="database, even if the database supports duplicates (`DUP_SORT`)."] |
|
|
|
#[doc="database, even if the database supports duplicates (`DUP_SORT`)."] |
|
|
|
const NO_OVERWRITE = MDB_NOOVERWRITE, |
|
|
|
const NO_OVERWRITE = MDB_NOOVERWRITE; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Insert the new item only if it does not already appear in the database."] |
|
|
|
#[doc="Insert the new item only if it does not already appear in the database."] |
|
|
|
#[doc="This flag may only be specified if the database was opened with `DUP_SORT`."] |
|
|
|
#[doc="This flag may only be specified if the database was opened with `DUP_SORT`."] |
|
|
|
#[doc="The function will return `LmdbError::KeyExist` if the item already appears in the"] |
|
|
|
#[doc="The function will return `LmdbError::KeyExist` if the item already appears in the"] |
|
|
|
#[doc="database."] |
|
|
|
#[doc="database."] |
|
|
|
const NO_DUP_DATA = MDB_NODUPDATA, |
|
|
|
const NO_DUP_DATA = MDB_NODUPDATA; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="For `Cursor::put`. Replace the item at the current cursor position. The key"] |
|
|
|
#[doc="For `Cursor::put`. Replace the item at the current cursor position. The key"] |
|
|
|
#[doc="parameter must match the current position. If using sorted duplicates (`DUP_SORT`)"] |
|
|
|
#[doc="parameter must match the current position. If using sorted duplicates (`DUP_SORT`)"] |
|
|
|
#[doc="the data item must still sort into the same position. This is intended to be used"] |
|
|
|
#[doc="the data item must still sort into the same position. This is intended to be used"] |
|
|
|
#[doc="when the new data is the same size as the old. Otherwise it will simply perform a"] |
|
|
|
#[doc="when the new data is the same size as the old. Otherwise it will simply perform a"] |
|
|
|
#[doc="delete of the old record followed by an insert."] |
|
|
|
#[doc="delete of the old record followed by an insert."] |
|
|
|
const CURRENT = MDB_CURRENT, |
|
|
|
const CURRENT = MDB_CURRENT; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Append the given item to the end of the database. No key comparisons are performed."] |
|
|
|
#[doc="Append the given item to the end of the database. No key comparisons are performed."] |
|
|
|
#[doc="This option allows fast bulk loading when keys are already known to be in the"] |
|
|
|
#[doc="This option allows fast bulk loading when keys are already known to be in the"] |
|
|
|
#[doc="correct order. Loading unsorted keys with this flag will cause data corruption."] |
|
|
|
#[doc="correct order. Loading unsorted keys with this flag will cause data corruption."] |
|
|
|
const APPEND = MDB_APPEND, |
|
|
|
const APPEND = MDB_APPEND; |
|
|
|
|
|
|
|
|
|
|
|
#[doc="Same as `APPEND`, but for sorted dup data."] |
|
|
|
#[doc="Same as `APPEND`, but for sorted dup data."] |
|
|
|
const APPEND_DUP = MDB_APPENDDUP, |
|
|
|
const APPEND_DUP = MDB_APPENDDUP; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|