pub struct MemoryCatalog { /* private fields */ }Expand description
In-memory catalog implementation using HashMaps.
This is the default catalog implementation for v0.1.2. It stores all metadata in memory and does not persist across restarts.
§Thread Safety
MemoryCatalog is not thread-safe. For concurrent access, wrap it in
appropriate synchronization primitives (e.g., Arc<RwLock<MemoryCatalog>>).
§Example
use alopex_sql::catalog::{Catalog, MemoryCatalog, TableMetadata, ColumnMetadata};
use alopex_sql::planner::types::ResolvedType;
let mut catalog = MemoryCatalog::new();
// Create a table
let table = TableMetadata::new("users", vec![
ColumnMetadata::new("id", ResolvedType::Integer),
ColumnMetadata::new("name", ResolvedType::Text),
]);
catalog.create_table(table).unwrap();
// Access the table
assert!(catalog.table_exists("users"));
let table = catalog.get_table("users").unwrap();
assert_eq!(table.column_count(), 2);Implementations§
Source§impl MemoryCatalog
impl MemoryCatalog
Sourcepub fn table_count(&self) -> usize
pub fn table_count(&self) -> usize
Get the number of tables in the catalog.
Sourcepub fn index_count(&self) -> usize
pub fn index_count(&self) -> usize
Get the number of indexes in the catalog.
Sourcepub fn table_names(&self) -> Vec<&str>
pub fn table_names(&self) -> Vec<&str>
Get all table names in the catalog.
Sourcepub fn index_names(&self) -> Vec<&str>
pub fn index_names(&self) -> Vec<&str>
Get all index names in the catalog.
Trait Implementations§
Source§impl Catalog for MemoryCatalog
impl Catalog for MemoryCatalog
Source§fn create_table(&mut self, table: TableMetadata) -> Result<(), PlannerError>
fn create_table(&mut self, table: TableMetadata) -> Result<(), PlannerError>
Create a new table in the catalog. Read more
Source§fn drop_table(&mut self, name: &str) -> Result<(), PlannerError>
fn drop_table(&mut self, name: &str) -> Result<(), PlannerError>
Drop a table from the catalog. Read more
Source§fn create_index(&mut self, index: IndexMetadata) -> Result<(), PlannerError>
fn create_index(&mut self, index: IndexMetadata) -> Result<(), PlannerError>
Create a new index in the catalog. Read more
Source§fn get_indexes_for_table(&self, table: &str) -> Vec<&IndexMetadata>
fn get_indexes_for_table(&self, table: &str) -> Vec<&IndexMetadata>
Get all indexes for a table. Read more
Source§fn drop_index(&mut self, name: &str) -> Result<(), PlannerError>
fn drop_index(&mut self, name: &str) -> Result<(), PlannerError>
Drop an index from the catalog. Read more
Source§fn table_exists(&self, name: &str) -> bool
fn table_exists(&self, name: &str) -> bool
Check if a table exists.
Source§fn index_exists(&self, name: &str) -> bool
fn index_exists(&self, name: &str) -> bool
Check if an index exists.
Source§fn next_table_id(&mut self) -> u32
fn next_table_id(&mut self) -> u32
Generate the next unique table ID. Read more
Source§fn next_index_id(&mut self) -> u32
fn next_index_id(&mut self) -> u32
Generate the next unique index ID. Read more
Source§impl Debug for MemoryCatalog
impl Debug for MemoryCatalog
Source§impl Default for MemoryCatalog
impl Default for MemoryCatalog
Source§fn default() -> MemoryCatalog
fn default() -> MemoryCatalog
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MemoryCatalog
impl RefUnwindSafe for MemoryCatalog
impl Send for MemoryCatalog
impl Sync for MemoryCatalog
impl Unpin for MemoryCatalog
impl UnwindSafe for MemoryCatalog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more