pub struct Catalog {
version: CatalogVersion,
database_by_name: HashMap<String, DatabaseCatalog>,
db_name_by_id: HashMap<u32, String>,
table_by_id: HashMap<TableId, Arc<TableCatalog>>,
table_stats: HummockVersionStats,
}
Expand description
Root catalog of database catalog. It manages all database/schema/table in memory on frontend.
It is protected by a RwLock
. Only crate::observer::FrontendObserverNode
will acquire the write lock and sync it with the meta catalog. In other situations, it is
read only.
- catalog (root catalog)
- database catalog
- schema catalog
- function catalog (i.e., user defined function)
- table/sink/source/index/view catalog
- column catalog
- schema catalog
- database catalog
Fields§
§version: CatalogVersion
§database_by_name: HashMap<String, DatabaseCatalog>
§db_name_by_id: HashMap<u32, String>
§table_by_id: HashMap<TableId, Arc<TableCatalog>>
all table catalogs in the cluster identified by universal unique table id.
table_stats: HummockVersionStats
Implementations§
source§impl Catalog
impl Catalog
fn get_database_mut(&mut self, db_id: u32) -> Option<&mut DatabaseCatalog>
pub fn clear(&mut self)
pub fn create_database(&mut self, db: &PbDatabase)
pub fn create_schema(&mut self, proto: &PbSchema)
pub fn create_table(&mut self, proto: &PbTable)
pub fn create_index(&mut self, proto: &PbIndex)
pub fn create_source(&mut self, proto: &PbSource)
pub fn create_sink(&mut self, proto: &PbSink)
pub fn create_subscription(&mut self, proto: &PbSubscription)
pub fn create_secret(&mut self, proto: &PbSecret)
pub fn create_view(&mut self, proto: &PbView)
pub fn create_function(&mut self, proto: &PbFunction)
pub fn create_connection(&mut self, proto: &PbConnection)
pub fn drop_connection( &mut self, db_id: u32, schema_id: u32, connection_id: u32, )
pub fn update_connection(&mut self, proto: &PbConnection)
pub fn update_secret(&mut self, proto: &PbSecret)
pub fn drop_database(&mut self, db_id: u32)
pub fn drop_schema(&mut self, db_id: u32, schema_id: u32)
pub fn drop_table(&mut self, db_id: u32, schema_id: u32, tb_id: TableId)
pub fn update_table(&mut self, proto: &PbTable)
pub fn update_database(&mut self, proto: &PbDatabase)
pub fn update_schema(&mut self, proto: &PbSchema)
pub fn update_index(&mut self, proto: &PbIndex)
pub fn drop_source(&mut self, db_id: u32, schema_id: u32, source_id: u32)
pub fn update_source(&mut self, proto: &PbSource)
pub fn drop_sink(&mut self, db_id: u32, schema_id: u32, sink_id: u32)
pub fn drop_secret(&mut self, db_id: u32, schema_id: u32, secret_id: SecretId)
pub fn update_sink(&mut self, proto: &PbSink)
pub fn drop_subscription( &mut self, db_id: u32, schema_id: u32, subscription_id: u32, )
pub fn update_subscription(&mut self, proto: &PbSubscription)
pub fn drop_index(&mut self, db_id: u32, schema_id: u32, index_id: IndexId)
pub fn drop_view(&mut self, db_id: u32, schema_id: u32, view_id: u32)
pub fn update_view(&mut self, proto: &PbView)
pub fn drop_function( &mut self, db_id: u32, schema_id: u32, function_id: FunctionId, )
pub fn update_function(&mut self, proto: &PbFunction)
pub fn get_database_by_name( &self, db_name: &str, ) -> Result<&DatabaseCatalog, CatalogError>
pub fn get_database_by_id( &self, db_id: &u32, ) -> Result<&DatabaseCatalog, CatalogError>
pub fn get_all_schema_names( &self, db_name: &str, ) -> Result<Vec<String>, CatalogError>
pub fn get_all_schema_info( &self, db_name: &str, ) -> Result<Vec<PbSchema>, CatalogError>
pub fn iter_schemas( &self, db_name: &str, ) -> Result<impl Iterator<Item = &SchemaCatalog>, CatalogError>
pub fn get_all_database_names(&self) -> Vec<String>
pub fn iter_databases(&self) -> impl Iterator<Item = &DatabaseCatalog>
pub fn get_schema_by_name( &self, db_name: &str, schema_name: &str, ) -> Result<&SchemaCatalog, CatalogError>
pub fn get_table_name_by_id( &self, table_id: TableId, ) -> Result<String, CatalogError>
pub fn get_schema_by_id( &self, db_id: &u32, schema_id: &u32, ) -> Result<&SchemaCatalog, CatalogError>
pub fn get_source_by_id( &self, db_id: &u32, schema_id: &u32, source_id: &u32, ) -> Result<&Arc<SourceCatalog>, CatalogError>
sourcepub fn first_valid_schema(
&self,
db_name: &str,
search_path: &SearchPath,
user_name: &str,
) -> Result<&SchemaCatalog, CatalogError>
pub fn first_valid_schema( &self, db_name: &str, search_path: &SearchPath, user_name: &str, ) -> Result<&SchemaCatalog, CatalogError>
Refer to SearchPath
.
sourcepub fn get_any_table_by_name<'a>(
&self,
db_name: &str,
schema_path: SchemaPath<'a>,
table_name: &str,
) -> Result<(&Arc<TableCatalog>, &'a str), CatalogError>
pub fn get_any_table_by_name<'a>( &self, db_name: &str, schema_path: SchemaPath<'a>, table_name: &str, ) -> Result<(&Arc<TableCatalog>, &'a str), CatalogError>
Used to get TableCatalog
for Materialized Views, Tables and Indexes.
Retrieves all tables, created or creating.
sourcepub fn get_created_table_by_name<'a>(
&self,
db_name: &str,
schema_path: SchemaPath<'a>,
table_name: &str,
) -> Result<(&Arc<TableCatalog>, &'a str), CatalogError>
pub fn get_created_table_by_name<'a>( &self, db_name: &str, schema_path: SchemaPath<'a>, table_name: &str, ) -> Result<(&Arc<TableCatalog>, &'a str), CatalogError>
Used to get TableCatalog
for Materialized Views, Tables and Indexes.
Retrieves only created tables.
pub fn get_any_table_by_id( &self, table_id: &TableId, ) -> Result<&Arc<TableCatalog>, CatalogError>
sourcepub fn get_created_table_by_id_with_db(
&self,
db_name: &str,
table_id: u32,
) -> Result<&Arc<TableCatalog>, CatalogError>
pub fn get_created_table_by_id_with_db( &self, db_name: &str, table_id: u32, ) -> Result<&Arc<TableCatalog>, CatalogError>
This function is similar to get_table_by_id
expect that a table must be in a given database.
pub fn get_schema_by_table_id( &self, db_name: &str, table_id: &TableId, ) -> Result<&SchemaCatalog, CatalogError>
pub fn alter_table_name_by_id(&mut self, table_id: &TableId, table_name: &str)
pub fn get_sys_table_by_name( &self, db_name: &str, schema_name: &str, table_name: &str, ) -> Result<&Arc<SystemTableCatalog>, CatalogError>
pub fn get_source_by_name<'a>( &self, db_name: &str, schema_path: SchemaPath<'a>, source_name: &str, ) -> Result<(&Arc<SourceCatalog>, &'a str), CatalogError>
pub fn get_sink_by_name<'a>( &self, db_name: &str, schema_path: SchemaPath<'a>, sink_name: &str, ) -> Result<(&Arc<SinkCatalog>, &'a str), CatalogError>
pub fn get_subscription_by_name<'a>( &self, db_name: &str, schema_path: SchemaPath<'a>, subscription_name: &str, ) -> Result<(&Arc<SubscriptionCatalog>, &'a str), CatalogError>
pub fn get_index_by_name<'a>( &self, db_name: &str, schema_path: SchemaPath<'a>, index_name: &str, ) -> Result<(&Arc<IndexCatalog>, &'a str), CatalogError>
pub fn get_index_by_id( &self, db_name: &str, index_id: u32, ) -> Result<&Arc<IndexCatalog>, CatalogError>
pub fn get_view_by_name<'a>( &self, db_name: &str, schema_path: SchemaPath<'a>, view_name: &str, ) -> Result<(&Arc<ViewCatalog>, &'a str), CatalogError>
pub fn get_view_by_id( &self, db_name: &str, view_id: u32, ) -> Result<Arc<ViewCatalog>, CatalogError>
pub fn get_secret_by_name<'a>( &self, db_name: &str, schema_path: SchemaPath<'a>, secret_name: &str, ) -> Result<(&Arc<SecretCatalog>, &'a str), CatalogError>
pub fn get_connection_by_name<'a>( &self, db_name: &str, schema_path: SchemaPath<'a>, connection_name: &str, ) -> Result<(&Arc<ConnectionCatalog>, &'a str), CatalogError>
pub fn get_function_by_name_inputs<'a>( &self, db_name: &str, schema_path: SchemaPath<'a>, function_name: &str, inputs: &mut [ExprImpl], ) -> Result<(&Arc<FunctionCatalog>, &'a str), CatalogError>
pub fn get_function_by_name_args<'a>( &self, db_name: &str, schema_path: SchemaPath<'a>, function_name: &str, args: &[DataType], ) -> Result<(&Arc<FunctionCatalog>, &'a str), CatalogError>
sourcepub fn get_functions_by_name<'a>(
&self,
db_name: &str,
schema_path: SchemaPath<'a>,
function_name: &str,
) -> Result<(Vec<&Arc<FunctionCatalog>>, &'a str), CatalogError>
pub fn get_functions_by_name<'a>( &self, db_name: &str, schema_path: SchemaPath<'a>, function_name: &str, ) -> Result<(Vec<&Arc<FunctionCatalog>>, &'a str), CatalogError>
Gets all functions with the given name.
sourcepub fn check_relation_name_duplicated(
&self,
db_name: &str,
schema_name: &str,
relation_name: &str,
) -> Result<(), CatalogError>
pub fn check_relation_name_duplicated( &self, db_name: &str, schema_name: &str, relation_name: &str, ) -> Result<(), CatalogError>
Check if the name duplicates with existing table, materialized view or source.
pub fn check_function_name_duplicated( &self, db_name: &str, schema_name: &str, function_name: &str, arg_types: &[DataType], ) -> Result<(), CatalogError>
sourcepub fn check_connection_name_duplicated(
&self,
db_name: &str,
schema_name: &str,
connection_name: &str,
) -> Result<(), CatalogError>
pub fn check_connection_name_duplicated( &self, db_name: &str, schema_name: &str, connection_name: &str, ) -> Result<(), CatalogError>
Check if the name duplicates with existing connection.
pub fn check_secret_name_duplicated( &self, db_name: &str, schema_name: &str, secret_name: &str, ) -> Result<(), CatalogError>
sourcepub fn set_version(&mut self, catalog_version: CatalogVersion)
pub fn set_version(&mut self, catalog_version: CatalogVersion)
Set the catalog cache’s catalog version.
pub fn table_stats(&self) -> &HummockVersionStats
pub fn set_table_stats(&mut self, table_stats: HummockVersionStats)
pub fn get_id_by_class_name( &self, db_name: &str, schema_path: SchemaPath<'_>, class_name: &str, ) -> Result<u32, CatalogError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Catalog
impl !RefUnwindSafe for Catalog
impl Send for Catalog
impl Sync for Catalog
impl Unpin for Catalog
impl !UnwindSafe for Catalog
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
§impl<T> Conv for T
impl<T> Conv for T
§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
§impl<T, U, I> LiftInto<U, I> for Twhere
U: LiftFrom<T, I>,
impl<T, U, I> LiftInto<U, I> for Twhere
U: LiftFrom<T, I>,
source§impl<M> MetricVecRelabelExt for M
impl<M> MetricVecRelabelExt for M
source§fn relabel(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level
.source§fn relabel_n(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
relabel_num: usize,
) -> RelabeledMetricVec<M>
fn relabel_n( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, relabel_num: usize, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
.source§fn relabel_debug_1(
self,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel_debug_1( self, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
with metric_level
set to
MetricLevel::Debug
and relabel_num
set to 1.§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<Source> Sculptor<HNil, HNil> for Source
impl<Source> Sculptor<HNil, HNil> for Source
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.