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
impl SchemaManager
Sourcepub async fn new<P: AsRef<Path>>(path: P) -> Result<Self>
pub async fn new<P: AsRef<Path>>(path: P) -> Result<Self>
Create a new schema manager from a path
Sourcepub async fn new_with_storage(
storage: Arc<StorageEngine>,
config: &Config,
) -> Result<Self>
pub async fn new_with_storage( storage: Arc<StorageEngine>, config: &Config, ) -> Result<Self>
Create a new schema manager with storage
Sourcepub async fn new_with_registry(
storage: Arc<StorageEngine>,
registry: Arc<RwLock<SchemaRegistry>>,
_config: &Config,
) -> Result<Self>
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 instanceregistry- Pre-loaded schema registry from ingestion_config- Database configuration (currently unused)
Sourcepub async fn register_udt(&self, udt_def: UdtTypeDef)
pub async fn register_udt(&self, udt_def: UdtTypeDef)
Register a new UDT type definition into the shared registry (issue #1708).
Sourcepub async fn get_udt(&self, keyspace: &str, name: &str) -> Option<UdtTypeDef>
pub async fn get_udt(&self, keyspace: &str, name: &str) -> Option<UdtTypeDef>
Get a UDT definition from the shared registry (returns a cloned UdtTypeDef).
Sourcepub async fn load_schema(&self, table_name: &str) -> Result<TableSchema>
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.
Sourcepub async fn parse_and_register_cql_schema(
&self,
cql: &str,
) -> Result<TableSchema>
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.
Sourcepub async fn find_schema_by_table(
&self,
keyspace: &Option<String>,
table: &str,
) -> Result<Option<TableSchema>>
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.
Sourcepub fn extract_table_info(&self, cql: &str) -> Result<(Option<String>, String)>
pub fn extract_table_info(&self, cql: &str) -> Result<(Option<String>, String)>
Extract table information from CQL without full parsing
Sourcepub fn cql_type_to_internal(&self, cql_type: &str) -> Result<CqlTypeId>
pub fn cql_type_to_internal(&self, cql_type: &str) -> Result<CqlTypeId>
Convert CQL type string to internal type ID
Sourcepub async fn get_table_schema(&self, table_name: &str) -> Result<TableSchema>
pub async fn get_table_schema(&self, table_name: &str) -> Result<TableSchema>
Get table schema by name (async for compatibility)