Skip to main content

SchemaRegistry

Struct SchemaRegistry 

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

Thread-safe registry of table schemas.

All tables that should be replicated from OLTP to OLAP must be registered here with their Arrow schema and primary key definition.

Implementations§

Source§

impl SchemaRegistry

Source

pub fn new() -> Self

Create an empty SchemaRegistry.

Source

pub fn register(&self, schema: TableSchema) -> Result<(), CoreError>

Register a TableSchema.

Calls TableSchema::validate before inserting. The registry holds an Arc clone of the schema so subsequent get calls are cheap.

§Errors

Returns CoreError::TableAlreadyRegistered if a table with the same name is already present. Returns CoreError::SchemaValidation if validation fails.

Source

pub fn get(&self, table_name: &str) -> Result<Arc<TableSchema>, CoreError>

Look up a TableSchema by table name.

Returns an Arc clone — the call is cheap and does not copy the schema.

§Errors

Returns CoreError::TableNotFound if table_name has not been registered.

Source

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

List all registered table names.

Source

pub fn unregister( &self, table_name: &str, ) -> Result<Arc<TableSchema>, CoreError>

Remove a table from the registry and return its schema.

§Errors

Returns CoreError::TableNotFound if table_name is not registered.

Source

pub fn update(&self, schema: TableSchema) -> Result<(), CoreError>

Replace an existing table’s schema in-place (used during schema evolution).

Validates schema before replacing. Does not apply DDL to any engine; callers must also call the corresponding OlapEngine::add_column / OlapEngine::drop_column methods.

§Errors

Returns CoreError::TableNotFound if the table is not registered. Returns CoreError::SchemaValidation if the new schema is invalid.

Source

pub fn add_column( &self, table_name: &str, column_name: &str, data_type: DataType, ) -> Result<Arc<TableSchema>, CoreError>

Add a nullable column to a registered table’s schema.

The column is appended at the end of the field list. New columns are always marked nullable so that existing rows (which lack the column) remain valid.

Returns the updated schema arc.

§Errors

Returns CoreError::TableNotFound if the table is not registered. Returns CoreError::SchemaValidation if column_name is invalid or already exists.

Source

pub fn drop_column( &self, table_name: &str, column_name: &str, ) -> Result<Arc<TableSchema>, CoreError>

Remove a column from a registered table’s schema.

Returns the updated schema arc. Note that the SQLite OLTP engine requires CDC triggers to be torn down before issuing DROP COLUMN (SQLite rejects DROP COLUMN while triggers reference the column).

§Errors

Returns CoreError::TableNotFound if the table is not registered. Returns CoreError::SchemaValidation if column_name is a primary key column or does not exist in the schema.

Source§

impl SchemaRegistry

Source

pub fn save_to_disk(&self, path: &str) -> Result<(), CoreError>

Persist the current registry contents to a JSON file at path.

The file is written atomically via a temp file + rename so a crash mid-write cannot produce a corrupt file.

§Errors

Returns CoreError::SchemaValidation if serialization fails or the file cannot be written or renamed (e.g., permission denied, disk full).

Source

pub fn load_from_disk(path: &str) -> Result<SchemaRegistry, CoreError>

Load a previously persisted registry from a JSON file at path.

Returns an empty SchemaRegistry if the file does not exist (fresh start). This design means that the first run behaves identically to subsequent runs — no special-casing is needed at call sites.

§Errors

Returns CoreError::SchemaValidation if the file exists but cannot be read, is not valid JSON, contains an unknown Arrow type string, or contains schemas that fail TableSchema::validate.

Trait Implementations§

Source§

impl Clone for SchemaRegistry

Source§

fn clone(&self) -> SchemaRegistry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SchemaRegistry

Source§

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

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

impl Default for SchemaRegistry

Source§

fn default() -> Self

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> Allocation for T
where T: RefUnwindSafe + Send + Sync,