[−][src]Struct rkv::Rkv
Wrapper around an lmdb::Environment
.
Methods
impl Rkv
[src]
Static methods.
pub fn environment_builder() -> EnvironmentBuilder
[src]
pub fn new(path: &Path) -> Result<Rkv, StoreError>
[src]
Return a new Rkv environment that supports up to DEFAULT_MAX_DBS
open databases.
pub fn from_env(path: &Path, env: EnvironmentBuilder) -> Result<Rkv, StoreError>
[src]
Return a new Rkv environment from the provided builder.
pub fn with_capacity(path: &Path, max_dbs: c_uint) -> Result<Rkv, StoreError>
[src]
Return a new Rkv environment that supports the specified number of open databases.
impl Rkv
[src]
Store creation methods.
pub fn open_single<'s, T>(
&self,
name: T,
opts: StoreOptions
) -> Result<SingleStore, StoreError> where
T: Into<Option<&'s str>>,
[src]
&self,
name: T,
opts: StoreOptions
) -> Result<SingleStore, StoreError> where
T: Into<Option<&'s str>>,
Create or Open an existing database in (&u8 -> Single Value) mode. Note: that create=true cannot be called concurrently with other operations so if you are sure that the database exists, call this with create=false.
pub fn open_integer<'s, T, K: PrimitiveInt>(
&self,
name: T,
opts: StoreOptions
) -> Result<IntegerStore<K>, StoreError> where
T: Into<Option<&'s str>>,
[src]
&self,
name: T,
opts: StoreOptions
) -> Result<IntegerStore<K>, StoreError> where
T: Into<Option<&'s str>>,
Create or Open an existing database in (Integer -> Single Value) mode. Note: that create=true cannot be called concurrently with other operations so if you are sure that the database exists, call this with create=false.
pub fn open_multi<'s, T>(
&self,
name: T,
opts: StoreOptions
) -> Result<MultiStore, StoreError> where
T: Into<Option<&'s str>>,
[src]
&self,
name: T,
opts: StoreOptions
) -> Result<MultiStore, StoreError> where
T: Into<Option<&'s str>>,
Create or Open an existing database in (&u8 -> Multiple Values) mode. Note: that create=true cannot be called concurrently with other operations so if you are sure that the database exists, call this with create=false.
pub fn open_multi_integer<'s, T, K: PrimitiveInt>(
&self,
name: T,
opts: StoreOptions
) -> Result<MultiIntegerStore<K>, StoreError> where
T: Into<Option<&'s str>>,
[src]
&self,
name: T,
opts: StoreOptions
) -> Result<MultiIntegerStore<K>, StoreError> where
T: Into<Option<&'s str>>,
Create or Open an existing database in (Integer -> Multiple Values) mode. Note: that create=true cannot be called concurrently with other operations so if you are sure that the database exists, call this with create=false.
impl Rkv
[src]
Read and write accessors.
pub fn read(&self) -> Result<Reader, StoreError>
[src]
Create a read transaction. There can be multiple concurrent readers for an environment, up to the maximum specified by LMDB (default 126), and you can open readers while a write transaction is active.
pub fn write(&self) -> Result<Writer, StoreError>
[src]
Create a write transaction. There can be only one write transaction active at any given time, so trying to create a second one will block until the first is committed or aborted.
impl Rkv
[src]
Other environment methods.
pub fn sync(&self, force: bool) -> Result<(), StoreError>
[src]
Flush the data buffers to disk. This call is only useful, when the environment
was open with either NO_SYNC
, NO_META_SYNC
or MAP_ASYNC
(see below).
The call is not valid if the environment was opened with READ_ONLY
.
Data is always written to disk when transaction.commit()
is called,
but the operating system may keep it buffered.
LMDB always flushes the OS buffers upon commit as well,
unless the environment was opened with NO_SYNC
or in part NO_META_SYNC
.
force
: if true, force a synchronous flush.
Otherwise if the environment has the NO_SYNC
flag set the flushes will be omitted,
and with MAP_ASYNC
they will be asynchronous.
pub fn stat(&self) -> Result<Stat, StoreError>
[src]
Retrieve statistics about this environment.
It includes:
- Page size in bytes
- B-tree depth
- Number of internal (non-leaf) pages
- Number of leaf pages
- Number of overflow pages
- Number of data entries
pub fn info(&self) -> Result<Info, StoreError>
[src]
Retrieve information about this environment.
It includes:
- Map size in bytes
- The last used page number
- The last transaction ID
- Max number of readers allowed
- Number of readers in use
pub fn load_ratio(&self) -> Result<f32, StoreError>
[src]
Retrieve the load ratio (# of used pages / total pages) about this environment.
With the formular: (last_page_no - freelist_pages) / total_pages
pub fn set_map_size(&self, size: usize) -> Result<(), StoreError>
[src]
Sets the size of the memory map to use for the environment.
This can be used to resize the map when the environment is already open.
You can also use Rkv::environment_builder()
to set the map size during
the Rkv
initialization.
Note:
-
No active transactions allowed when performing resizing in this process. It's up to the consumer to enforce that.
-
The size should be a multiple of the OS page size. Any attempt to set a size smaller than the space already consumed by the environment will be silently changed to the current size of the used space.
-
In the multi-process case, once a process resizes the map, other processes need to either re-open the environment, or call set_map_size with size 0 to update the environment. Otherwise, new transaction creation will fail with
LmdbError::MapResized
.
Trait Implementations
Auto Trait Implementations
impl Send for Rkv
impl Unpin for Rkv
impl Sync for Rkv
impl UnwindSafe for Rkv
impl RefUnwindSafe for Rkv
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,