pub async fn new_empty<S>(
        object_store: Arc<ObjectStore>,
        server_id: ServerId,
        db_name: String,
        state_data: S::EmptyInput,
    ) -> Result<(Self, S)>
    where
        S: CatalogState + Send + Sync,
    {
        if Self::exists(&object_store, server_id, &db_name).await? {
            return Err(Error::AlreadyExists {});
        }
        let state = S::new_empty(&db_name, state_data);

        let catalog = Self {
            previous_tkey: RwLock::new(None),
            transaction_semaphore: Semaphore::new(1),
            object_store,
            server_id,
            db_name,
        };

        // add empty transaction
        let transaction = catalog.open_transaction().await;
        transaction
            .commit()
            .await
            .map_err(Box::new)
            .context(CommitError)?;

        Ok((catalog, state))
    }
/// Create new catalog w/o any data.
///
/// An empty transaction will be used to mark the catalog start so that concurrent open but still-empty catalogs can
/// easily be detected.
Create new catalog w/o any data.
An empty transaction will be used to mark the catalog start so that concurrent open but still-empty catalogs can
easily be detected.
Create new catalog w / o any data . An empty transaction will be used to mark the catalog start so that concurrent open but still - empty catalogs can easily be detected .
pub async fn new_empty<S>(
        object_store: Arc<ObjectStore>,
        server_id: ServerId,
        db_name: String,
        state_data: S::EmptyInput,
    ) -> Result<(Self, S)>
    where
        S: CatalogState + Send + Sync,
    {
        if Self::exists(&object_store, server_id, &db_name).await? {
            return Err(Error::AlreadyExists {});
        }
        let state = S::new_empty(&db_name, state_data);
        let catalog = Self {
            previous_tkey: RwLock::new(None),
            transaction_semaphore: Semaphore::new(1),
            object_store,
            server_id,
            db_name,
        };
        // add empty transaction
        let transaction = catalog.open_transaction().await;
        transaction
            .commit()
            .await
            .map_err(Box::new)
            .context(CommitError)?;
        Ok((catalog, state))
    }
pub async fn new_empty < S > ( object_store : Arc < ObjectStore > , server_id : ServerId , db_name : String , state_data : S :: EmptyInput , ) -> Result < ( Self , S ) > where S : CatalogState + Send + Sync , { if Self :: exists ( & object_store , server_id , & db_name ) . await ? { return Err ( Error :: AlreadyExists { } ) ; } let state = S :: new_empty ( & db_name , state_data ) ; let catalog = Self { previous_tkey : RwLock :: new ( None ) , transaction_semaphore : Semaphore :: new ( 1 ) , object_store , server_id , db_name , } ; // add empty transaction let transaction = catalog . open_transaction ( ) . await ; transaction . commit ( ) . await . map_err ( Box :: new ) . context ( CommitError ) ? ; Ok ( ( catalog , state ) ) }
Create new catalog w/o any data.
Create new catalog w / o any data .
object_store
Arc<ObjectStore>
server_id
ServerId
db_name
String
state_data
S::EmptyInput
object_store
Arc<ObjectStore>
server_id
ServerId
db_name
String
state_data
S::EmptyInput