FileHandlePool

Struct FileHandlePool 

Source
pub struct FileHandlePool { /* private fields */ }
Expand description

Manages a pool of file handles for column families.

The pool maintains a fixed maximum number of open file descriptors and implements LRU eviction when the pool is full. This allows unlimited column families while keeping file descriptor usage bounded.

Each column family can acquire its own FileBackend to the same physical file, enabling true concurrent writes through independent file descriptors.

Implementations§

Source§

impl FileHandlePool

Source

pub fn new(path: PathBuf, max_size: usize) -> Self

Creates a new file handle pool.

§Arguments
  • path - Path to the database file
  • max_size - Maximum number of file handles to keep open
Source

pub fn acquire( &self, cf_name: &str, ) -> Result<Arc<dyn StorageBackend>, DatabaseError>

Acquires a file handle for the specified column family.

If the column family already has an open handle, it is reused and its last_used timestamp is updated. If the pool is full, the least recently used handle is evicted.

§Arguments
  • cf_name - Name of the column family requesting a handle
§Returns

An Arc-wrapped StorageBackend that the column family can use for I/O operations.

Source

pub fn touch(&self, cf_name: &str)

Updates the last_used timestamp for a column family’s handle.

This should be called when a column family’s Database is reused to prevent premature eviction.

Source

pub fn release(&self, cf_name: &str)

Explicitly releases a column family’s file handle.

This is optional and allows manual control over when handles are released. If not called, handles are released automatically via LRU eviction.

Source

pub fn len(&self) -> usize

Returns the current number of open file handles.

Source

pub fn is_empty(&self) -> bool

Returns true if the pool has no open handles.

Source

pub fn max_size(&self) -> usize

Returns the maximum pool size.

Source

pub fn file_growth_lock(&self) -> Arc<Mutex<()>>

Returns a clone of the Arc wrapping the file growth lock.

This Arc should be passed to PartitionedStorageBackend instances so they can serialize file growth operations across all column families using the same file.

§Returns

An Arc-wrapped Mutex that all backends for this file should use when calling set_len().

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.