Skip to main content

SchemaManager

Struct SchemaManager 

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

Schema management service for handling table schemas and UDT definitions.

Issue #1708 (one schema source of truth): the manager holds an Arc<RwLock<SchemaRegistry>> and RESOLVES every schema/UDT lookup THROUGH that registry (and REGISTERS manager-side loads INTO it). It keeps NO by-value schema/UDT copy of its own, so registry-side TTL-refresh / auto-discovery and manager-side loads are always mutually visible — the two can never silently diverge. The registry owns freshness (TTL/refresh); the manager delegates.

Implementations§

Source§

impl SchemaManager

Source

pub async fn new<P: AsRef<Path>>(path: P) -> Result<Self>

Create a new schema manager from a path

Source

pub async fn new_with_storage( storage: Arc<StorageEngine>, config: &Config, ) -> Result<Self>

Create a new schema manager with storage

Source

pub async fn new_with_registry( storage: Arc<StorageEngine>, registry: Arc<RwLock<SchemaRegistry>>, _config: &Config, ) -> Result<Self>

Create a new schema manager with a pre-loaded SchemaRegistry

This constructor is used when schemas are loaded from external .cql files during ingestion, allowing the pre-loaded schemas to be used by the query engine.

Issue #1708: the registry is SHARED by reference (not snapshotted). Every subsequent registry-side update is immediately visible to this manager, and every manager-side load is registered back into this same registry.

§Arguments
  • storage - The storage engine instance
  • registry - Pre-loaded schema registry from ingestion
  • _config - Database configuration (currently unused)
Source

pub async fn register_udt(&self, udt_def: UdtTypeDef)

Register a new UDT type definition into the shared registry (issue #1708).

Source

pub async fn get_udt(&self, keyspace: &str, name: &str) -> Option<UdtTypeDef>

Get a UDT definition from the shared registry (returns a cloned UdtTypeDef).

Source

pub async fn load_schema(&self, table_name: &str) -> Result<TableSchema>

Load schema for a table.

Returns Err(Error::Schema(..)) for an unknown table. CQLite never fabricates a schema for a table nobody defined — doing so would return fabricated-shape rows for undefined tables, violating the no-heuristics mandate. This mirrors the I3 (#1626) hard-fail precedent (issue #1710).

This resolves THROUGH the shared registry (issue #1708), so a registry-side TTL-refresh / auto-discovery is always observed and a stale by-value snapshot can never be served. No write happens on the unknown-table path.

Source

pub async fn parse_and_register_cql_schema( &self, cql: &str, ) -> Result<TableSchema>

Parse and register a schema from a CQL CREATE TABLE statement.

Registers INTO the shared registry (issue #1708) so the parsed schema is immediately visible to every other holder of the registry (parsing paths, other managers), not stored in a private manager-only map.

Source

pub async fn find_schema_by_table( &self, keyspace: &Option<String>, table: &str, ) -> Result<Option<TableSchema>>

Find schema by table name with optional keyspace matching.

Resolves THROUGH the shared registry (issue #1708); the registry owns freshness (issue #1708 roborev Medium): a fresh matched entry is cloned once (issue #1587), an EXPIRED entry is refreshed rather than served stale, and an unregistered table yields Ok(None) with NO fabrication (issue #1710). The registry’s refresh error (if any) propagates as Err.

Source

pub fn extract_table_info(&self, cql: &str) -> Result<(Option<String>, String)>

Extract table information from CQL without full parsing

Source

pub fn cql_type_to_internal(&self, cql_type: &str) -> Result<CqlTypeId>

Convert CQL type string to internal type ID

Source

pub async fn get_table_schema(&self, table_name: &str) -> Result<TableSchema>

Get table schema by name (async for compatibility)

Trait Implementations§

Source§

impl Debug for SchemaManager

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