iceberg-cpp
Loading...
Searching...
No Matches
Public Member Functions | List of all members
iceberg::sql::CatalogStore Class Referenceabstract

Semantic, driver-agnostic storage interface for the SQL catalog. More...

#include <catalog_store.h>

Inheritance diagram for iceberg::sql::CatalogStore:
iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >

Public Member Functions

virtual Status Initialize ()=0
 Create the backing tables if they do not already exist.
 
virtual Result< std::vector< std::string > > ListNamespaceNames ()=0
 Return the distinct namespace identifiers known to this catalog.
 
virtual Result< std::vector< NamespaceProperty > > GetNamespaceProperties (std::string_view ns)=0
 Return all property rows stored for ns.
 
virtual Status InsertNamespaceProperty (std::string_view ns, std::string_view key, std::optional< std::string_view > value)=0
 Insert one property row for ns.
 
virtual Status DeleteNamespaceProperty (std::string_view ns, std::string_view key)=0
 Delete the property row identified by (ns, key), if present.
 
virtual Result< int64_t > DeleteNamespace (std::string_view ns)=0
 Delete all property rows for ns.
 
virtual Result< std::vector< std::string > > ListTableNames (std::string_view ns)=0
 Return the table names stored directly under ns.
 
virtual Result< bool > TableExists (std::string_view ns, std::string_view name)=0
 Whether a row exists for the table (ns, name).
 
virtual Result< std::optional< std::string > > GetTableMetadataLocation (std::string_view ns, std::string_view name)=0
 Return the current metadata location of (ns, name).
 
virtual Status InsertTable (std::string_view ns, std::string_view name, std::string_view metadata_location)=0
 Insert a new table row with the given metadata location.
 
virtual Result< int64_t > UpdateTableMetadataLocation (std::string_view ns, std::string_view name, std::string_view new_location, std::string_view new_previous_location, std::string_view expected_current_location)=0
 Conditionally update a table's metadata location (optimistic CAS).
 
virtual Result< int64_t > DeleteTable (std::string_view ns, std::string_view name)=0
 Delete the table row (ns, name), if present.
 
virtual Result< int64_t > RenameTable (std::string_view from_ns, std::string_view from_name, std::string_view to_ns, std::string_view to_name)=0
 Move a table row to a new namespace and/or name.
 
virtual Status RunInTransaction (const std::function< Status()> &body)=0
 Execute body atomically inside a single transaction.
 

Detailed Description

Semantic, driver-agnostic storage interface for the SQL catalog.

A store instance is scoped to one catalog name and persists namespace and table rows. Implementations must be safe for concurrent calls from SqlCatalog.

Unique or primary-key constraint violations from insert and rename operations must be reported as ErrorKind::kAlreadyExists. Other database failures should be reported as ErrorKind::kIOError.

Member Function Documentation

◆ DeleteNamespace()

virtual Result< int64_t > iceberg::sql::CatalogStore::DeleteNamespace ( std::string_view  ns)
pure virtual

Delete all property rows for ns.

Parameters
nsA namespace identifier in the store's string form.
Returns
The number of rows deleted.

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.

◆ DeleteNamespaceProperty()

virtual Status iceberg::sql::CatalogStore::DeleteNamespaceProperty ( std::string_view  ns,
std::string_view  key 
)
pure virtual

Delete the property row identified by (ns, key), if present.

Parameters
nsA namespace identifier in the store's string form.
keyProperty key.
Returns
Status indicating success if the row was deleted or did not exist.

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.

◆ DeleteTable()

virtual Result< int64_t > iceberg::sql::CatalogStore::DeleteTable ( std::string_view  ns,
std::string_view  name 
)
pure virtual

Delete the table row (ns, name), if present.

Parameters
nsA namespace identifier in the store's string form.
nameTable name.
Returns
The number of rows deleted.

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.

◆ GetNamespaceProperties()

virtual Result< std::vector< NamespaceProperty > > iceberg::sql::CatalogStore::GetNamespaceProperties ( std::string_view  ns)
pure virtual

Return all property rows stored for ns.

Parameters
nsA namespace identifier in the store's string form.
Returns
The property rows stored for the namespace.

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.

◆ GetTableMetadataLocation()

virtual Result< std::optional< std::string > > iceberg::sql::CatalogStore::GetTableMetadataLocation ( std::string_view  ns,
std::string_view  name 
)
pure virtual

Return the current metadata location of (ns, name).

Parameters
nsA namespace identifier in the store's string form.
nameTable name.
Returns
The metadata location, or std::nullopt if the table has no row or its metadata_location column is NULL.

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.

◆ Initialize()

virtual Status iceberg::sql::CatalogStore::Initialize ( )
pure virtual

Create the backing tables if they do not already exist.

Returns
Status indicating success if the tables are ready.

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.

◆ InsertNamespaceProperty()

virtual Status iceberg::sql::CatalogStore::InsertNamespaceProperty ( std::string_view  ns,
std::string_view  key,
std::optional< std::string_view >  value 
)
pure virtual

Insert one property row for ns.

A primary-key collision (same namespace + key) must be reported as ErrorKind::kAlreadyExists.

Parameters
nsA namespace identifier in the store's string form.
keyProperty key.
valueProperty value, or std::nullopt for SQL NULL.
Returns
Status indicating success if the row was inserted.

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.

◆ InsertTable()

virtual Status iceberg::sql::CatalogStore::InsertTable ( std::string_view  ns,
std::string_view  name,
std::string_view  metadata_location 
)
pure virtual

Insert a new table row with the given metadata location.

The previous_metadata_location column is set to NULL. A primary-key collision must be reported as ErrorKind::kAlreadyExists.

Parameters
nsA namespace identifier in the store's string form.
nameTable name.
metadata_locationTable metadata location.
Returns
Status indicating success if the row was inserted.

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.

◆ ListNamespaceNames()

virtual Result< std::vector< std::string > > iceberg::sql::CatalogStore::ListNamespaceNames ( )
pure virtual

Return the distinct namespace identifiers known to this catalog.

Returns
A list of namespace identifiers in the store's string form.

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.

◆ ListTableNames()

virtual Result< std::vector< std::string > > iceberg::sql::CatalogStore::ListTableNames ( std::string_view  ns)
pure virtual

Return the table names stored directly under ns.

Parameters
nsA namespace identifier in the store's string form.
Returns
A list of table names.

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.

◆ RenameTable()

virtual Result< int64_t > iceberg::sql::CatalogStore::RenameTable ( std::string_view  from_ns,
std::string_view  from_name,
std::string_view  to_ns,
std::string_view  to_name 
)
pure virtual

Move a table row to a new namespace and/or name.

A primary-key collision with an existing target must be reported as ErrorKind::kAlreadyExists.

Parameters
from_nsSource namespace identifier in the store's string form.
from_nameSource table name.
to_nsTarget namespace identifier in the store's string form.
to_nameTarget table name.
Returns
The number of rows updated (1 on success, 0 if the source is gone).

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.

◆ RunInTransaction()

virtual Status iceberg::sql::CatalogStore::RunInTransaction ( const std::function< Status()> &  body)
pure virtual

Execute body atomically inside a single transaction.

The implementation begins a transaction, invokes body (which issues store operations on this same instance), then commits if body returns success or rolls back otherwise. Implementations are not required to support nesting.

Parameters
bodyTransaction body to execute.
Returns
Status returned by body, or a transaction error.

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.

◆ TableExists()

virtual Result< bool > iceberg::sql::CatalogStore::TableExists ( std::string_view  ns,
std::string_view  name 
)
pure virtual

Whether a row exists for the table (ns, name).

Parameters
nsA namespace identifier in the store's string form.
nameTable name.
Returns
true if the table row exists, false otherwise.

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.

◆ UpdateTableMetadataLocation()

virtual Result< int64_t > iceberg::sql::CatalogStore::UpdateTableMetadataLocation ( std::string_view  ns,
std::string_view  name,
std::string_view  new_location,
std::string_view  new_previous_location,
std::string_view  expected_current_location 
)
pure virtual

Conditionally update a table's metadata location (optimistic CAS).

The update only applies when the stored metadata_location still equals expected_current_location.

Parameters
nsA namespace identifier in the store's string form.
nameTable name.
new_locationNew table metadata location.
new_previous_locationNew previous metadata location.
expected_current_locationExpected current metadata location.
Returns
The number of rows updated (1 on success, 0 on a stale base).

Implemented in iceberg::sql::Sqlpp23CatalogStore< ConnectionSource, Traits >.


The documentation for this class was generated from the following file: