pub struct DatabaseImpl {
pub throughput: Arc<ThroughputStats>,
/* private fields */
}Expand description
The underlying object for a given database.
Fields§
§throughput: Arc<ThroughputStats>Per-database operation throughput counters.
Shared with every CursorImpl opened on this database so that insert, search, update, delete and position operations can be counted on the hot path without acquiring any mutex.
Implementations§
Source§impl DatabaseImpl
impl DatabaseImpl
Sourcepub fn new(
id: DatabaseId,
name: String,
db_type: DbType,
config: &DatabaseConfig,
) -> Self
pub fn new( id: DatabaseId, name: String, db_type: DbType, config: &DatabaseConfig, ) -> Self
Creates a new DatabaseImpl.
pub fn get_id(&self) -> DatabaseId
pub fn get_name(&self) -> &str
pub fn get_db_type(&self) -> DbType
Sourcepub fn is_deferred_write(&self) -> bool
pub fn is_deferred_write(&self) -> bool
Returns true if this database uses deferred write mode.
pub fn get_sorted_duplicates(&self) -> bool
pub fn is_temporary(&self) -> bool
pub fn get_key_prefixing(&self) -> bool
pub fn is_replicated(&self) -> bool
pub fn is_deleted(&self) -> bool
pub fn is_deleting(&self) -> bool
pub fn start_delete(&mut self)
pub fn finish_delete(&mut self)
pub fn is_dirty(&self) -> bool
pub fn set_dirty(&self)
pub fn clear_dirty(&self)
pub fn increment_reference_count(&self)
pub fn decrement_reference_count(&self)
pub fn reference_count(&self) -> i64
Sourcepub fn entry_count(&self) -> u64
pub fn entry_count(&self) -> u64
Returns the current entry count.
In — reads an AtomicLong.
Sourcepub fn increment_entry_count(&self)
pub fn increment_entry_count(&self)
Increments the entry count by 1 (on new insert).
Sourcepub fn decrement_entry_count(&self)
pub fn decrement_entry_count(&self)
Decrements the entry count by 1 (on delete), saturating at zero.
pub fn get_tree(&self) -> Option<&DatabaseTree>
pub fn get_tree_mut(&mut self) -> Option<&mut DatabaseTree>
Sourcepub fn get_real_tree(&self) -> Option<RwLockReadGuard<'_, Tree>>
pub fn get_real_tree(&self) -> Option<RwLockReadGuard<'_, Tree>>
Returns a read guard over the real B+tree.
Returns Option<RwLockReadGuard<'_, Tree>> — the guard Derefs to
&Tree, so all existing cursor-code patterns (tree.search(key),
Self::get_data_from_tree(tree, key), etc.) continue to work without
modification through auto-deref coercion.
Returns None if no tree is present or if the lock is poisoned.
§X-7 fix
Use get_real_tree_arc() (below) to obtain the Arc<RwLock<Tree>>
for sharing with the cleaner’s db-tree registry.
Sourcepub fn get_real_tree_arc(&self) -> Option<Arc<RwLock<Tree>>>
pub fn get_real_tree_arc(&self) -> Option<Arc<RwLock<Tree>>>
Returns a clone of the Arc<RwLock<Tree>> for sharing with the
cleaner’s per-database tree registry (X-7 fix).
Sourcepub fn update_key_expiration(&self, key: &[u8], expiration_hours: u32) -> bool
pub fn update_key_expiration(&self, key: &[u8], expiration_hours: u32) -> bool
Sets the expiration time (absolute hours since Unix epoch) for the
BIN slot holding key.
Returns true if the key was found and updated.
Delegates to Tree::update_key_expiration().
Sourcepub fn collect_btree_stats(&self) -> Option<TreeStats>
pub fn collect_btree_stats(&self) -> Option<TreeStats>
Collects structural B-tree statistics.
Walks the full tree (O(n) in node count) and returns node counts
and maximum depth. Implements DatabaseImpl.getDbStats(fast=false).
Returns None if this DatabaseImpl has no real tree (e.g. internal
metadata databases).
Sourcepub fn set_recovered_tree(&mut self, tree: Tree)
pub fn set_recovered_tree(&mut self, tree: Tree)
Replace the real B+tree with a tree recovered from the log.
Called by EnvironmentImpl::open_database() when a matching
recovered_trees entry exists (Approach B of P1b wiring).
Sourcepub fn set_memory_counter(&mut self, counter: Arc<AtomicI64>)
pub fn set_memory_counter(&mut self, counter: Arc<AtomicI64>)
Wires the environment’s shared memory-usage counter into this database’s tree so that BIN insertions/deletions update the Arbiter’s budget.
Must be called after new() in EnvironmentImpl::open_database().
Also forwards the counter to the recovered tree (if any) so that
databases opened after recovery also track memory.