Struct lmdb_zero::EnvBuilder
[−]
[src]
pub struct EnvBuilder { /* fields omitted */ }
Handle on an uninitialised LMDB environment to allow configuring pre-open options.
Methods
impl EnvBuilder
[src]
pub fn new() -> Result<Self>
[src]
Allocates a new, uninitialised environment.
pub fn set_mapsize(&mut self, size: usize) -> Result<()>
[src]
Set the size of the memory map to use for this environment.
The size should be a multiple of the OS page size. The default is 10485760 bytes. The size of the memory map is also the maximum size of the database. The value should be chosen as large as possible, to accommodate future growth of the database.
The new size takes effect immediately for the current process but will not be persisted to any others until a write transaction has been committed by the current process. Also, only mapsize increases are persisted into the environment.
See also Environment::set_mapsize()
.
pub fn set_maxreaders(&mut self, readers: u32) -> Result<()>
[src]
Set the maximum number of threads/reader slots for the environment.
This defines the number of slots in the lock table that is used to
track readers in the the environment. The default is 126. Starting a
read-only transaction normally ties a lock table slot to the current
thread until the environment closes or the thread exits. If NOTLS
is
in use, starting a transaction instead ties the slot to the transaction
object until it or the Environment
object is destroyed.
pub fn set_maxdbs(&mut self, dbs: u32) -> Result<()>
[src]
Set the maximum number of named databases for the environment.
This function is only needed if multiple databases will be used in the environment. Simpler applications that use the environment as a single unnamed database can ignore this option.
Currently a moderate number of slots are cheap but a huge number gets expensive: 7-120 words per transaction, and every mdb_dbi_open() does a linear search of the opened slots.
pub unsafe fn open(
self,
path: &str,
flags: Flags,
mode: FileMode
) -> Result<Environment>
[src]
self,
path: &str,
flags: Flags,
mode: FileMode
) -> Result<Environment>
Opens the file or directory at path
with the given flags
and, on
UNIX, permissions given by mode
.
path
is a &str
for convenience, and must be convertable to a
CString
. The non-use of &OsStr
or AsRef<Path>
as normally used in
std
is deliberate, since the path must be convertable to a byte
string. But as a result there is no way to address files whose names
are not valid UTF-8 through this call.
Unsafety
It is the caller's responsibility to ensure that the underlying file
will be used properly. Since LMDB is built on memory-mapping, these
responsibilities run quite deep and vary based on flags
.
-
The caller must ensure that no other process writes to the file in any way except going through LMDB. If this is violated, segfaults can occur, or immutable references can be observed to have their referent mutated asynchronously.
-
If the caller uses flags which suppress locking, the caller must additionally ensure that LMDB's locking requirements are upheld.
-
If the caller uses flags that result in the creation of a sparse file, the caller must ensure there is actually sufficient disk space for all pages of the file or else a segfault may occur.