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
impl FileHandlePool
Sourcepub fn new(path: PathBuf, max_size: usize) -> Self
pub fn new(path: PathBuf, max_size: usize) -> Self
Creates a new file handle pool.
§Arguments
path- Path to the database filemax_size- Maximum number of file handles to keep open
Sourcepub fn acquire(
&self,
cf_name: &str,
) -> Result<Arc<dyn StorageBackend>, DatabaseError>
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.
Sourcepub fn touch(&self, cf_name: &str)
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.
Sourcepub fn release(&self, cf_name: &str)
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.
Sourcepub fn file_growth_lock(&self) -> Arc<Mutex<()>>
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().