pub struct SSTableManager { /* private fields */ }Expand description
SSTable manager that handles multiple SSTable files
Implementations§
Source§impl SSTableManager
impl SSTableManager
Sourcepub async fn new(
path: &Path,
config: &Config,
platform: Arc<Platform>,
schema_registry: Option<Arc<RwLock<SchemaRegistry>>>,
) -> Result<Self>
pub async fn new( path: &Path, config: &Config, platform: Arc<Platform>, schema_registry: Option<Arc<RwLock<SchemaRegistry>>>, ) -> Result<Self>
Create a new SSTable manager
Sourcepub 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>
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- Configurationplatform- 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?;pub async fn create_from_memtable( &self, _data: Vec<(TableId, RowKey, Value)>, ) -> Result<SSTableId>
Sourcepub async fn get(
&self,
table_id: &TableId,
key: &RowKey,
) -> Result<Option<Value>>
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:
- Exact match on the full
table_idstring (e.g."test_basic.simple_table") - Unqualified table name (e.g.
"simple_table") — for backward compatibility with flat/non-Cassandra directory layouts that have no keyspace parent.
Sourcepub 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)>>
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 scanstart_key- Optional start key for range scanend_key- Optional end key for range scanlimit- Optional limit on number of resultsschema- 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):
- Exact match on the full
table_idstring (e.g."test_basic.simple_table") - Unqualified table name (e.g.
"simple_table") — for backward compatibility with flat/non-Cassandra directory layouts that have no keyspace parent.
Sourcepub async fn list_sstables(&self) -> Vec<SSTableId>
pub async fn list_sstables(&self) -> Vec<SSTableId>
Get list of all SSTable IDs
Sourcepub async fn remove_sstable(&self, sstable_id: &SSTableId) -> Result<()>
pub async fn remove_sstable(&self, sstable_id: &SSTableId) -> Result<()>
Remove an SSTable
Sourcepub async fn stats(&self) -> Result<SSTableStats>
pub async fn stats(&self) -> Result<SSTableStats>
Get SSTable statistics
Sourcepub async fn set_schema_registry(
&self,
registry: Arc<RwLock<SchemaRegistry>>,
) -> Result<()>
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.