async fn insert_table(
        &self,
        sequencer_id: SequencerId,
        table_name: &str,
        catalog: &dyn Catalog,
    ) -> Result<Arc<tokio::sync::RwLock<TableData>>> {
        let mut repos = catalog.repositories().await;
        let info = repos
            .tables()
            .get_table_persist_info(sequencer_id, self.namespace_id, table_name)
            .await
            .context(CatalogSnafu)?
            .context(TableNotFoundSnafu { table_name })?;

        let mut t = self.tables.write();

        let data = match t.entry(table_name.to_string()) {
            Entry::Vacant(v) => {
                let v = v.insert(Arc::new(tokio::sync::RwLock::new(TableData::new(
                    info.table_id,
                    info.tombstone_max_sequence_number,
                ))));
                self.table_count.inc(1);
                Arc::clone(v)
            }
            Entry::Occupied(v) => Arc::clone(v.get()),
        };

        Ok(data)
    }
/// Inserts the table or returns it if it happens to be inserted by some other thread
Inserts the table or returns it if it happens to be inserted by some other thread
Inserts the table or returns it if it happens to be inserted by some other thread
async fn insert_table(
        &self,
        sequencer_id: SequencerId,
        table_name: &str,
        catalog: &dyn Catalog,
    ) -> Result<Arc<tokio::sync::RwLock<TableData>>> {
        let mut repos = catalog.repositories().await;
        let info = repos
            .tables()
            .get_table_persist_info(sequencer_id, self.namespace_id, table_name)
            .await
            .context(CatalogSnafu)?
            .context(TableNotFoundSnafu { table_name })?;
        let mut t = self.tables.write();
        let data = match t.entry(table_name.to_string()) {
            Entry::Vacant(v) => {
                let v = v.insert(Arc::new(tokio::sync::RwLock::new(TableData::new(
                    info.table_id,
                    info.tombstone_max_sequence_number,
                ))));
                self.table_count.inc(1);
                Arc::clone(v)
            }
            Entry::Occupied(v) => Arc::clone(v.get()),
        };
        Ok(data)
    }
async fn insert_table ( & self , sequencer_id : SequencerId , table_name : & str , catalog : & dyn Catalog , ) -> Result < Arc < tokio :: sync :: RwLock < TableData > > > { let mut repos = catalog . repositories ( ) . await ; let info = repos . tables ( ) . get_table_persist_info ( sequencer_id , self . namespace_id , table_name ) . await . context ( CatalogSnafu ) ? . context ( TableNotFoundSnafu { table_name } ) ? ; let mut t = self . tables . write ( ) ; let data = match t . entry ( table_name . to_string ( ) ) { Entry :: Vacant ( v ) => { let v = v . insert ( Arc :: new ( tokio :: sync :: RwLock :: new ( TableData :: new ( info . table_id , info . tombstone_max_sequence_number , ) ) ) ) ; self . table_count . inc ( 1 ) ; Arc :: clone ( v ) } Entry :: Occupied ( v ) => Arc :: clone ( v . get ( ) ) , } ; Ok ( data ) }
Inserts the table or returns it if it happens to be inserted by some other thread
Inserts the table or returns it if it happens to be inserted by some other thread
&self
sequencer_id
SequencerId
table_name
&str
catalog
&dyn Catalog
&self
sequencer_id
SequencerId
table_name
&str
catalog
&dyn Catalog