async fn insert_namespace(
        &self,
        namespace: &str,
        catalog: &dyn Catalog,
    ) -> Result<Arc<NamespaceData>> {
        let mut repos = catalog.repositories().await;
        let namespace = repos
            .namespaces()
            .get_by_name(namespace)
            .await
            .context(CatalogSnafu)?
            .context(NamespaceNotFoundSnafu { namespace })?;

        let mut n = self.namespaces.write();

        let data = match n.entry(namespace.name) {
            Entry::Vacant(v) => {
                let v = v.insert(Arc::new(NamespaceData::new(namespace.id, &*self.metrics)));
                self.namespace_count.inc(1);
                Arc::clone(v)
            }
            Entry::Occupied(v) => Arc::clone(v.get()),
        };

        Ok(data)
    }
/// Retrieves the namespace from the catalog and initializes an empty buffer, or
/// retrieves the buffer if some other caller gets it first
Retrieves the namespace from the catalog and initializes an empty buffer, or
retrieves the buffer if some other caller gets it first
Retrieves the namespace from the catalog and initializes an empty buffer or retrieves the buffer if some other caller gets it first
async fn insert_namespace(
        &self,
        namespace: &str,
        catalog: &dyn Catalog,
    ) -> Result<Arc<NamespaceData>> {
        let mut repos = catalog.repositories().await;
        let namespace = repos
            .namespaces()
            .get_by_name(namespace)
            .await
            .context(CatalogSnafu)?
            .context(NamespaceNotFoundSnafu { namespace })?;
        let mut n = self.namespaces.write();
        let data = match n.entry(namespace.name) {
            Entry::Vacant(v) => {
                let v = v.insert(Arc::new(NamespaceData::new(namespace.id, &*self.metrics)));
                self.namespace_count.inc(1);
                Arc::clone(v)
            }
            Entry::Occupied(v) => Arc::clone(v.get()),
        };
        Ok(data)
    }
async fn insert_namespace ( & self , namespace : & str , catalog : & dyn Catalog , ) -> Result < Arc < NamespaceData > > { let mut repos = catalog . repositories ( ) . await ; let namespace = repos . namespaces ( ) . get_by_name ( namespace ) . await . context ( CatalogSnafu ) ? . context ( NamespaceNotFoundSnafu { namespace } ) ? ; let mut n = self . namespaces . write ( ) ; let data = match n . entry ( namespace . name ) { Entry :: Vacant ( v ) => { let v = v . insert ( Arc :: new ( NamespaceData :: new ( namespace . id , & * self . metrics ) ) ) ; self . namespace_count . inc ( 1 ) ; Arc :: clone ( v ) } Entry :: Occupied ( v ) => Arc :: clone ( v . get ( ) ) , } ; Ok ( data ) }
Retrieves the namespace from the catalog and initializes an empty buffer, or
retrieves the buffer if some other caller gets it first
Retrieves the namespace from the catalog and initializes an empty buffer or retrieves the buffer if some other caller gets it first
&self
namespace
&str
catalog
&dyn Catalog
&self
namespace
&str
catalog
&dyn Catalog