|
|
@ -35,11 +35,6 @@ pub struct Environment { |
|
|
|
dbi_open_mutex: Mutex<()>, |
|
|
|
dbi_open_mutex: Mutex<()>, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Database statistics
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// Contains information about the size and layout of an LMDB database
|
|
|
|
|
|
|
|
pub struct Stat(ffi::MDB_stat); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Environment { |
|
|
|
impl Environment { |
|
|
|
|
|
|
|
|
|
|
|
/// Creates a new builder for specifying options for opening an LMDB environment.
|
|
|
|
/// Creates a new builder for specifying options for opening an LMDB environment.
|
|
|
@ -109,6 +104,9 @@ impl Environment { |
|
|
|
Ok(db) |
|
|
|
Ok(db) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Retrieves the set of flags which the database is opened with.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// The database must belong to to this environment.
|
|
|
|
pub fn get_db_flags<'env>(&'env self, db: Database) -> Result<DatabaseFlags> { |
|
|
|
pub fn get_db_flags<'env>(&'env self, db: Database) -> Result<DatabaseFlags> { |
|
|
|
let txn = self.begin_ro_txn()?; |
|
|
|
let txn = self.begin_ro_txn()?; |
|
|
|
let mut flags: c_uint = 0; |
|
|
|
let mut flags: c_uint = 0; |
|
|
@ -157,7 +155,7 @@ impl Environment { |
|
|
|
ffi::mdb_dbi_close(self.env, db.dbi()); |
|
|
|
ffi::mdb_dbi_close(self.env, db.dbi()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Get database statistics.
|
|
|
|
/// Retrieves statistics about this environment.
|
|
|
|
pub fn stat(&self) -> Result<Stat> { |
|
|
|
pub fn stat(&self) -> Result<Stat> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
let mut stat = Stat(mem::zeroed()); |
|
|
|
let mut stat = Stat(mem::zeroed()); |
|
|
@ -167,14 +165,19 @@ impl Environment { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Environment statistics.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// Contains information about the size and layout of an LMDB environment.
|
|
|
|
|
|
|
|
pub struct Stat(ffi::MDB_stat); |
|
|
|
|
|
|
|
|
|
|
|
impl Stat { |
|
|
|
impl Stat { |
|
|
|
/// Size of database in bytes.
|
|
|
|
/// Size of a database page. This is the same for all databases in the environment.
|
|
|
|
#[inline] |
|
|
|
#[inline] |
|
|
|
pub fn size(&self) -> u32 { |
|
|
|
pub fn page_size(&self) -> u32 { |
|
|
|
self.0.ms_psize |
|
|
|
self.0.ms_psize |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Height of B-tree.
|
|
|
|
/// Depth (height) of the B-tree.
|
|
|
|
#[inline] |
|
|
|
#[inline] |
|
|
|
pub fn depth(&self) -> u32 { |
|
|
|
pub fn depth(&self) -> u32 { |
|
|
|
self.0.ms_depth |
|
|
|
self.0.ms_depth |
|
|
@ -186,7 +189,7 @@ impl Stat { |
|
|
|
self.0.ms_branch_pages |
|
|
|
self.0.ms_branch_pages |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Number of lead pages.
|
|
|
|
/// Number of leaf pages.
|
|
|
|
#[inline] |
|
|
|
#[inline] |
|
|
|
pub fn leaf_pages(&self) -> usize { |
|
|
|
pub fn leaf_pages(&self) -> usize { |
|
|
|
self.0.ms_leaf_pages |
|
|
|
self.0.ms_leaf_pages |
|
|
@ -276,6 +279,7 @@ impl EnvironmentBuilder { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Sets the provided options in the environment.
|
|
|
|
pub fn set_flags(&mut self, flags: EnvironmentFlags) -> &mut EnvironmentBuilder { |
|
|
|
pub fn set_flags(&mut self, flags: EnvironmentFlags) -> &mut EnvironmentBuilder { |
|
|
|
self.flags = flags; |
|
|
|
self.flags = flags; |
|
|
|
self |
|
|
|
self |
|
|
|