Skip to main content

DatabaseImpl

Struct DatabaseImpl 

Source
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

Source

pub fn new( id: DatabaseId, name: String, db_type: DbType, config: &DatabaseConfig, ) -> Self

Creates a new DatabaseImpl.

Source

pub fn get_id(&self) -> DatabaseId

Source

pub fn get_name(&self) -> &str

Source

pub fn get_db_type(&self) -> DbType

Source

pub fn is_deferred_write(&self) -> bool

Returns true if this database uses deferred write mode.

Source

pub fn get_sorted_duplicates(&self) -> bool

Source

pub fn is_temporary(&self) -> bool

Source

pub fn get_key_prefixing(&self) -> bool

Source

pub fn is_replicated(&self) -> bool

Source

pub fn is_deleted(&self) -> bool

Source

pub fn is_deleting(&self) -> bool

Source

pub fn start_delete(&mut self)

Source

pub fn finish_delete(&mut self)

Source

pub fn is_dirty(&self) -> bool

Source

pub fn set_dirty(&self)

Source

pub fn clear_dirty(&self)

Source

pub fn increment_reference_count(&self)

Source

pub fn decrement_reference_count(&self)

Source

pub fn reference_count(&self) -> i64

Source

pub fn entry_count(&self) -> u64

Returns the current entry count.

In — reads an AtomicLong.

Source

pub fn increment_entry_count(&self)

Increments the entry count by 1 (on new insert).

Source

pub fn decrement_entry_count(&self)

Decrements the entry count by 1 (on delete), saturating at zero.

Source

pub fn get_tree(&self) -> Option<&DatabaseTree>

Source

pub fn get_tree_mut(&mut self) -> Option<&mut DatabaseTree>

Source

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.

Source

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).

Source

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().

Source

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).

Source

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).

Source

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.

Source

pub fn max_tree_entries_per_node(&self) -> i32

Source

pub fn log_size(&self) -> usize

Serialization.

Source

pub fn write_to_log(&self, buf: &mut Vec<u8>) -> Result<()>

Source

pub fn read_from_log(buf: &[u8]) -> Result<Self>

Trait Implementations§

Source§

impl Debug for DatabaseImpl

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.