MemoryCatalog

Struct MemoryCatalog 

Source
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

Source

pub fn new() -> Self

Create a new empty in-memory catalog.

Source

pub fn table_count(&self) -> usize

Get the number of tables in the catalog.

Source

pub fn index_count(&self) -> usize

Get the number of indexes in the catalog.

Source

pub fn table_names(&self) -> Vec<&str>

Get all table names in the catalog.

Source

pub fn index_names(&self) -> Vec<&str>

Get all index names in the catalog.

Source

pub fn clear(&mut self)

Clear all tables and indexes from the catalog.

Trait Implementations§

Source§

impl Catalog for MemoryCatalog

Source§

fn create_table(&mut self, table: TableMetadata) -> Result<(), PlannerError>

Create a new table in the catalog. Read more
Source§

fn get_table(&self, name: &str) -> Option<&TableMetadata>

Get a table by name. Read more
Source§

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>

Create a new index in the catalog. Read more
Source§

fn get_index(&self, name: &str) -> Option<&IndexMetadata>

Get an index by name. Read more
Source§

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>

Drop an index from the catalog. Read more
Source§

fn table_exists(&self, name: &str) -> bool

Check if a table exists.
Source§

fn index_exists(&self, name: &str) -> bool

Check if an index exists.
Source§

fn next_table_id(&mut self) -> u32

Generate the next unique table ID. Read more
Source§

fn next_index_id(&mut self) -> u32

Generate the next unique index ID. Read more
Source§

impl Debug for MemoryCatalog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MemoryCatalog

Source§

fn default() -> MemoryCatalog

Returns the “default value” for a type. 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,