Skip to main content

SSTableManager

Struct SSTableManager 

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

SSTable manager that handles multiple SSTable files

Implementations§

Source§

impl SSTableManager

Source

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

Create a new SSTable manager

Source

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

Create a new SSTable manager from pre-discovered table directories

This method accepts a list of table directory paths (from DiscoveryService) and loads SSTables from those specific directories. It does not perform filesystem scanning beyond the provided directories - this avoids duplicate scanning when integrating with the discovery/engine lifecycle.

Use this method when you have pre-discovered table directories and want to avoid redundant filesystem scanning. Use new() when you want automatic discovery from a single base directory.

§Arguments
  • storage_path - Base storage path (used for context, not for scanning)
  • table_dirs - List of table directory paths from DiscoveryService (e.g., /data/keyspace1/table1-abc123)
  • config - Configuration
  • platform - Platform abstraction
§Returns

A new SSTableManager with SSTables loaded from the specified directories

§Errors

Returns an error if any of the specified directories cannot be read. Individual SSTable loading errors are logged but do not fail the entire operation.

§Example
use cqlite_core::storage::sstable::SSTableManager;
use cqlite_core::{Config, Platform};
use std::sync::Arc;
use std::path::PathBuf;

let config = Config::default();
let platform = Arc::new(Platform::new(&config).await?);

// Get table directories from DiscoveryService
let table_dirs = vec![
    PathBuf::from("/data/keyspace1/table1-abc123"),
    PathBuf::from("/data/keyspace1/table2-def456"),
];

let manager = SSTableManager::new_from_discovered_paths(
    &PathBuf::from("/data"),
    table_dirs,
    &config,
    platform,
    #[cfg(feature = "state_machine")]
    None,
).await?;
Source

pub async fn create_from_memtable( &self, _data: Vec<(TableId, RowKey, Value)>, ) -> Result<SSTableId>

Source

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

Get a value by key from all SSTables (simple version without tombstone merging)

Uses table_readers (keyed by fully-qualified "keyspace.table") so that only the SSTables for the requested table are searched (Issue #680). Same-named tables in different keyspaces (e.g. test_basic.simple_table and test_oa.simple_table) are now correctly distinguished.

Lookup order:

  1. Exact match on the full table_id string (e.g. "test_basic.simple_table")
  2. Unqualified table name (e.g. "simple_table") — for backward compatibility with flat/non-Cassandra directory layouts that have no keyspace parent.
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 from all SSTables (simple version without tombstone merging)

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

Lookup order (Issue #680):

  1. Exact match on the full table_id string (e.g. "test_basic.simple_table")
  2. Unqualified table name (e.g. "simple_table") — for backward compatibility with flat/non-Cassandra directory layouts that have no keyspace parent.
Source

pub async fn list_sstables(&self) -> Vec<SSTableId>

Get list of all SSTable IDs

Source

pub async fn remove_sstable(&self, sstable_id: &SSTableId) -> Result<()>

Remove an SSTable

Source

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

Get SSTable statistics

Source

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

Set the schema registry for schema-aware operations

This method stores the schema registry and applies it to all existing SSTable readers. Future readers loaded via load_existing_sstables or load_from_table_directories will also receive the schema registry during creation.

Source

pub async fn merge_sstables( &self, _source_ids: Vec<SSTableId>, _target_id: SSTableId, ) -> Result<()>

Trait Implementations§

Source§

impl Debug for SSTableManager

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.