Skip to main content

StorageEngine

Struct StorageEngine 

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

Main storage engine that coordinates all storage components

NOTE: Issue #176 removed write infrastructure (compaction, manifest). This is now a read-only storage layer focused on SSTable access.

Implementations§

Source§

impl StorageEngine

Source

pub async fn open( path: &Path, config: &Config, platform: Arc<Platform>, schema_registry: Option<Arc<RwLock<SchemaRegistry>>>, ) -> Result<Self>

Open a storage engine at the given path

This method discovers SSTables by scanning the storage directory. For pre-discovered SSTables, use open_with_sstables instead.

NOTE: Issue #176 removed write infrastructure (compaction, manifest). This is now a read-only storage layer focused on SSTable access.

Source

pub async fn open_with_sstables( path: &Path, discovered_table_dirs: Vec<PathBuf>, config: &Config, platform: Arc<Platform>, schema_registry: Option<Arc<RwLock<SchemaRegistry>>>, ) -> Result<Self>

Open a storage engine with pre-discovered SSTable table directories

This method is used when SSTables have been discovered externally (e.g., by DiscoveryService) and allows the storage engine to be initialized with specific table directories rather than scanning the storage directory. Each table directory will be scanned for Data.db files.

§Arguments
  • path - Base storage path for manifest and SSTable operations
  • discovered_table_dirs - Vector of table directory paths (each containing SSTable files)
  • config - Storage configuration
  • platform - Platform abstraction for I/O operations
§Returns

A StorageEngine instance with all components initialized, including SSTable readers for all Data.db files found in the discovered table directories.

§Example
let config = Config::default();
let platform = Arc::new(Platform::new(&config).await?);
let storage_path = Path::new("/var/lib/cqlite/storage");
let discovered_table_dirs = vec![
    PathBuf::from("/var/lib/cassandra/keyspace1/table1-abc123"),
    PathBuf::from("/var/lib/cassandra/keyspace1/table2-def456"),
];

let engine = StorageEngine::open_with_sstables(
    storage_path,
    discovered_table_dirs,
    &config,
    platform,
    #[cfg(feature = "state_machine")]
    None,
).await?;
Source

pub async fn get( &self, table_id: &TableId, key: &RowKey, ) -> Result<Option<Value>>

Get a value by key

Source

pub async fn scan( &self, table_id: &TableId, start_key: Option<&RowKey>, end_key: Option<&RowKey>, limit: Option<usize>, schema: Option<&TableSchema>, ) -> Result<Vec<(RowKey, Value)>>

Scan a range of keys

§Arguments
  • table_id - The table to scan
  • start_key - Optional start key for range scan
  • end_key - Optional end key for range scan
  • limit - Optional limit on number of results
  • schema - Optional table schema for schema-aware parsing. When provided, enables accurate type detection and avoids heuristic-based parsing. Strongly recommended for Cassandra 5.0+ formats.
Source

pub async fn stats(&self) -> Result<StorageStats>

Get storage statistics

NOTE: Issue #176 removed compaction stats (compaction.rs deleted).

Source

pub async fn shutdown(&self) -> Result<()>

Shutdown the storage engine

NOTE: Issue #176 removed compaction shutdown (compaction.rs deleted). Issue #175 removed flush operations (WAL/MemTable deleted).

Source

pub async fn set_schema_registry( &self, registry: Arc<RwLock<SchemaRegistry>>, ) -> Result<()>

Set the schema registry for schema-aware operations

This method propagates the schema registry to the SSTable manager, which will apply it to all SSTable readers for schema-aware parsing.

Trait Implementations§

Source§

impl Debug for StorageEngine

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.