iceberg-cpp
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
iceberg::InMemoryCatalog Class Reference

An in-memory implementation of the Iceberg Catalog interface. More...

#include <in_memory_catalog.h>

Inheritance diagram for iceberg::InMemoryCatalog:
iceberg::Catalog

Public Member Functions

 InMemoryCatalog (std::string const &name, std::shared_ptr< FileIO > const &file_io, std::string const &warehouse_location, std::unordered_map< std::string, std::string > const &properties)
 
std::string_view name () const override
 Return the name for this catalog.
 
Status CreateNamespace (const Namespace &ns, const std::unordered_map< std::string, std::string > &properties) override
 Create a namespace with associated properties.
 
Result< std::vector< Namespace > > ListNamespaces (const Namespace &ns) const override
 List child namespaces from the given namespace.
 
Status DropNamespace (const Namespace &ns) override
 Drop a namespace.
 
Result< bool > NamespaceExists (const Namespace &ns) const override
 Check whether the namespace exists.
 
Result< std::unordered_map< std::string, std::string > > GetNamespaceProperties (const Namespace &ns) const override
 Get metadata properties for a namespace.
 
Status UpdateNamespaceProperties (const Namespace &ns, const std::unordered_map< std::string, std::string > &updates, const std::unordered_set< std::string > &removals) override
 Update a namespace's properties by applying additions and removals.
 
Result< std::vector< TableIdentifier > > ListTables (const Namespace &ns) const override
 Return all the identifiers under this namespace.
 
Result< std::shared_ptr< Table > > CreateTable (const TableIdentifier &identifier, const std::shared_ptr< Schema > &schema, const std::shared_ptr< PartitionSpec > &spec, const std::shared_ptr< SortOrder > &order, const std::string &location, const std::unordered_map< std::string, std::string > &properties) override
 Create a table.
 
Result< std::shared_ptr< Table > > UpdateTable (const TableIdentifier &identifier, const std::vector< std::unique_ptr< TableRequirement > > &requirements, const std::vector< std::unique_ptr< TableUpdate > > &updates) override
 Update a table.
 
Result< std::shared_ptr< Transaction > > StageCreateTable (const TableIdentifier &identifier, const std::shared_ptr< Schema > &schema, const std::shared_ptr< PartitionSpec > &spec, const std::shared_ptr< SortOrder > &order, const std::string &location, const std::unordered_map< std::string, std::string > &properties) override
 Start a transaction to create a table.
 
Result< bool > TableExists (const TableIdentifier &identifier) const override
 Check whether table exists.
 
Status DropTable (const TableIdentifier &identifier, bool purge) override
 Drop a table; optionally delete data and metadata files.
 
Status RenameTable (const TableIdentifier &from, const TableIdentifier &to) override
 Rename a table.
 
Result< std::shared_ptr< Table > > LoadTable (const TableIdentifier &identifier) override
 Load a table.
 
Result< std::shared_ptr< Table > > RegisterTable (const TableIdentifier &identifier, const std::string &metadata_file_location) override
 Register a table with the catalog if it does not exist.
 

Static Public Member Functions

static std::shared_ptr< InMemoryCatalogMake (std::string const &name, std::shared_ptr< FileIO > const &file_io, std::string const &warehouse_location, std::unordered_map< std::string, std::string > const &properties)
 

Detailed Description

An in-memory implementation of the Iceberg Catalog interface.

This catalog stores all metadata purely in memory, with no persistence to disk or external systems. It is primarily intended for unit tests, prototyping, or demonstration purposes.

Note
This class is not suitable for production use. All data will be lost when the process exits.

Member Function Documentation

◆ CreateNamespace()

Status iceberg::InMemoryCatalog::CreateNamespace ( const Namespace ns,
const std::unordered_map< std::string, std::string > &  properties 
)
overridevirtual

Create a namespace with associated properties.

Parameters
nsthe namespace to create
propertiesa key-value map of metadata for the namespace
Returns
Status indicating success if created successfully; ErrorKind::kAlreadyExists if the namespace already exists; ErrorKind::kNotSupported if the operation is not supported

Implements iceberg::Catalog.

◆ CreateTable()

Result< std::shared_ptr< Table > > iceberg::InMemoryCatalog::CreateTable ( const TableIdentifier identifier,
const std::shared_ptr< Schema > &  schema,
const std::shared_ptr< PartitionSpec > &  spec,
const std::shared_ptr< SortOrder > &  order,
const std::string &  location,
const std::unordered_map< std::string, std::string > &  properties 
)
overridevirtual

Create a table.

Parameters
identifiera table identifier
schemaa schema
speca partition spec
ordera sort order
locationa location for the table; leave empty if unspecified
propertiesa string map of table properties
Returns
a Table instance or ErrorKind::kAlreadyExists if the table already exists

Implements iceberg::Catalog.

◆ DropNamespace()

Status iceberg::InMemoryCatalog::DropNamespace ( const Namespace ns)
overridevirtual

Drop a namespace.

Parameters
nsthe namespace to drop
Returns
Status indicating success if dropped successfully; ErrorKind::kNoSuchNamespace if the namespace does not exist; ErrorKind::kNotAllowed if the namespace is not empty

Implements iceberg::Catalog.

◆ DropTable()

Status iceberg::InMemoryCatalog::DropTable ( const TableIdentifier identifier,
bool  purge 
)
overridevirtual

Drop a table; optionally delete data and metadata files.

If purge is set to true the implementation should delete all data and metadata files.

Parameters
identifiera table identifier
purgeif true, delete all data and metadata files in the table
Returns
Status indicating the outcome of the operation.
  • On success, the table was dropped (or did not exist).
  • On failure, contains error information.

Implements iceberg::Catalog.

◆ GetNamespaceProperties()

Result< std::unordered_map< std::string, std::string > > iceberg::InMemoryCatalog::GetNamespaceProperties ( const Namespace ns) const
overridevirtual

Get metadata properties for a namespace.

Parameters
nsthe namespace to look up
Returns
a key-value map of metadata properties; ErrorKind::kNoSuchNamespace if the namespace does not exist

Implements iceberg::Catalog.

◆ ListNamespaces()

Result< std::vector< Namespace > > iceberg::InMemoryCatalog::ListNamespaces ( const Namespace ns) const
overridevirtual

List child namespaces from the given namespace.

Parameters
nsthe parent namespace
Returns
a list of child namespaces; ErrorKind::kNoSuchNamespace if the given namespace does not exist

Implements iceberg::Catalog.

◆ ListTables()

Result< std::vector< TableIdentifier > > iceberg::InMemoryCatalog::ListTables ( const Namespace ns) const
overridevirtual

Return all the identifiers under this namespace.

Parameters
nsa namespace
Returns
a list of identifiers for tables or ErrorKind::kNoSuchNamespace if the namespace does not exist

Implements iceberg::Catalog.

◆ LoadTable()

Result< std::shared_ptr< Table > > iceberg::InMemoryCatalog::LoadTable ( const TableIdentifier identifier)
overridevirtual

Load a table.

Parameters
identifiera table identifier
Returns
instance of Table implementation referred to by identifier or ErrorKind::kNoSuchTable if the table does not exist

Implements iceberg::Catalog.

◆ name()

std::string_view iceberg::InMemoryCatalog::name ( ) const
overridevirtual

Return the name for this catalog.

Implements iceberg::Catalog.

◆ NamespaceExists()

Result< bool > iceberg::InMemoryCatalog::NamespaceExists ( const Namespace ns) const
overridevirtual

Check whether the namespace exists.

Parameters
nsthe namespace to check
Returns
true if the namespace exists, false otherwise

Implements iceberg::Catalog.

◆ RegisterTable()

Result< std::shared_ptr< Table > > iceberg::InMemoryCatalog::RegisterTable ( const TableIdentifier identifier,
const std::string &  metadata_file_location 
)
overridevirtual

Register a table with the catalog if it does not exist.

Parameters
identifiera table identifier
metadata_file_locationthe location of a metadata file
Returns
a Table instance or ErrorKind::kAlreadyExists if the table already exists

Implements iceberg::Catalog.

◆ RenameTable()

Status iceberg::InMemoryCatalog::RenameTable ( const TableIdentifier from,
const TableIdentifier to 
)
overridevirtual

Rename a table.

Parameters
fromthe current table identifier
tothe new table identifier
Returns
Status indicating the outcome of the operation.
  • On success, the table was renamed.
  • On failure, contains error information.

Implements iceberg::Catalog.

◆ StageCreateTable()

Result< std::shared_ptr< Transaction > > iceberg::InMemoryCatalog::StageCreateTable ( const TableIdentifier identifier,
const std::shared_ptr< Schema > &  schema,
const std::shared_ptr< PartitionSpec > &  spec,
const std::shared_ptr< SortOrder > &  order,
const std::string &  location,
const std::unordered_map< std::string, std::string > &  properties 
)
overridevirtual

Start a transaction to create a table.

Parameters
identifiera table identifier
schemaa schema
speca partition spec
ordera sort order
locationa location for the table; leave empty if unspecified
propertiesa string map of table properties
Returns
a Transaction to create the table or ErrorKind::kAlreadyExists if the table already exists

Implements iceberg::Catalog.

◆ TableExists()

Result< bool > iceberg::InMemoryCatalog::TableExists ( const TableIdentifier identifier) const
overridevirtual

Check whether table exists.

Parameters
identifiera table identifier
Returns
Result<bool> indicating table exists or not.
  • On success, the table existence was successfully checked (actual existence may be inferred elsewhere).
  • On failure, contains error information.

Implements iceberg::Catalog.

◆ UpdateNamespaceProperties()

Status iceberg::InMemoryCatalog::UpdateNamespaceProperties ( const Namespace ns,
const std::unordered_map< std::string, std::string > &  updates,
const std::unordered_set< std::string > &  removals 
)
overridevirtual

Update a namespace's properties by applying additions and removals.

Parameters
nsthe namespace to update
updatesa set of properties to add or overwrite
removalsa set of property keys to remove
Returns
Status indicating success if the update is successful; ErrorKind::kNoSuchNamespace if the namespace does not exist; ErrorKind::kUnsupported if the operation is not supported

Implements iceberg::Catalog.

◆ UpdateTable()

Result< std::shared_ptr< Table > > iceberg::InMemoryCatalog::UpdateTable ( const TableIdentifier identifier,
const std::vector< std::unique_ptr< TableRequirement > > &  requirements,
const std::vector< std::unique_ptr< TableUpdate > > &  updates 
)
overridevirtual

Update a table.

Parameters
identifiera table identifier
requirementsa list of table requirements
updatesa list of table updates
Returns
a Table instance or ErrorKind::kAlreadyExists if the table already exists

Implements iceberg::Catalog.


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