|
iceberg-cpp
|
Builder class for constructing TableMetadata objects. More...
#include <table_metadata.h>
Classes | |
| class | Impl |
Public Member Functions | |
| TableMetadataBuilder & | ApplyChangesForCreate (const TableMetadata &base) |
| Apply changes required to create this table metadata. | |
| TableMetadataBuilder & | SetMetadataLocation (std::string_view metadata_location) |
| Set the metadata location of the table. | |
| TableMetadataBuilder & | SetPreviousMetadataLocation (std::string_view previous_metadata_location) |
| Set the previous metadata location of the table. | |
| TableMetadataBuilder & | AssignUUID () |
| Assign a UUID to the table. | |
| TableMetadataBuilder & | AssignUUID (std::string_view uuid) |
| Assign a specific UUID to the table. | |
| TableMetadataBuilder & | UpgradeFormatVersion (int8_t new_format_version) |
| Upgrade the format version of the table. | |
| TableMetadataBuilder & | SetCurrentSchema (const std::shared_ptr< Schema > &schema, int32_t new_last_column_id) |
| Set the current schema for the table. | |
| TableMetadataBuilder & | SetCurrentSchema (int32_t schema_id) |
| Set the current schema by schema ID. | |
| TableMetadataBuilder & | AddSchema (const std::shared_ptr< Schema > &schema) |
| Add a schema to the table. | |
| TableMetadataBuilder & | SetDefaultPartitionSpec (std::shared_ptr< PartitionSpec > spec) |
| Set the default partition spec for the table. | |
| TableMetadataBuilder & | SetDefaultPartitionSpec (int32_t spec_id) |
| Set the default partition spec by spec ID. | |
| TableMetadataBuilder & | AddPartitionSpec (std::shared_ptr< PartitionSpec > spec) |
| Add a partition spec to the table. | |
| TableMetadataBuilder & | RemovePartitionSpecs (const std::vector< int32_t > &spec_ids) |
| Remove partition specs from the table. | |
| TableMetadataBuilder & | RemoveSchemas (const std::unordered_set< int32_t > &schema_ids) |
| Remove schemas from the table. | |
| TableMetadataBuilder & | SetDefaultSortOrder (std::shared_ptr< SortOrder > order) |
| Set the default sort order for the table. | |
| TableMetadataBuilder & | SetDefaultSortOrder (int32_t order_id) |
| Set the default sort order by order ID. | |
| TableMetadataBuilder & | AddSortOrder (std::shared_ptr< SortOrder > order) |
| Add a sort order to the table. | |
| TableMetadataBuilder & | AddSnapshot (std::shared_ptr< Snapshot > snapshot) |
| Add a snapshot to the table. | |
| TableMetadataBuilder & | SetBranchSnapshot (int64_t snapshot_id, const std::string &branch) |
| Set a branch to point to a specific snapshot. | |
| TableMetadataBuilder & | SetBranchSnapshot (std::shared_ptr< Snapshot > snapshot, const std::string &branch) |
| Set a branch to point to a specific snapshot. | |
| TableMetadataBuilder & | SetRef (const std::string &name, std::shared_ptr< SnapshotRef > ref) |
| Set a snapshot reference. | |
| TableMetadataBuilder & | RemoveRef (const std::string &name) |
| Remove a snapshot reference. | |
| TableMetadataBuilder & | RemoveSnapshots (const std::vector< std::shared_ptr< Snapshot > > &snapshots_to_remove) |
| Remove snapshots from the table. | |
| TableMetadataBuilder & | RemoveSnapshots (const std::vector< int64_t > &snapshot_ids) |
| Remove snapshots from the table. | |
| TableMetadataBuilder & | SuppressHistoricalSnapshots () |
| Suppresses snapshots that are historical, removing the metadata for lazy snapshot loading. | |
| TableMetadataBuilder & | SetStatistics (std::shared_ptr< StatisticsFile > statistics_file) |
| Set table statistics. | |
| TableMetadataBuilder & | RemoveStatistics (int64_t snapshot_id) |
| Remove table statistics by snapshot ID. | |
| TableMetadataBuilder & | SetPartitionStatistics (const std::shared_ptr< PartitionStatisticsFile > &partition_statistics_file) |
| Set partition statistics. | |
| TableMetadataBuilder & | RemovePartitionStatistics (int64_t snapshot_id) |
| Remove partition statistics by snapshot ID. | |
| TableMetadataBuilder & | SetProperties (const std::unordered_map< std::string, std::string > &updated) |
| Set table properties. | |
| TableMetadataBuilder & | RemoveProperties (const std::unordered_set< std::string > &removed) |
| Remove table properties. | |
| TableMetadataBuilder & | SetLocation (std::string_view location) |
| Set the table location. | |
| TableMetadataBuilder & | AddEncryptionKey (std::shared_ptr< EncryptedKey > key) |
| Add an encryption key to the table. | |
| TableMetadataBuilder & | RemoveEncryptionKey (std::string_view key_id) |
| Remove an encryption key from the table by key ID. | |
| Result< std::unique_ptr< TableMetadata > > | Build () |
| Build the TableMetadata object. | |
| const std::vector< std::unique_ptr< TableUpdate > > & | changes () const |
| Returns the changes made to the table metadata. | |
| const TableMetadata * | base () const |
| Returns the base metadata without any changes. | |
| const TableMetadata & | current () const |
| Returns the current metadata with staged changes applied. | |
| ~TableMetadataBuilder () override | |
| Destructor. | |
| TableMetadataBuilder (const TableMetadataBuilder &)=delete | |
| TableMetadataBuilder & | operator= (const TableMetadataBuilder &)=delete |
| TableMetadataBuilder (TableMetadataBuilder &&) noexcept | |
| TableMetadataBuilder & | operator= (TableMetadataBuilder &&) noexcept |
Public Member Functions inherited from iceberg::ErrorCollector | |
| ErrorCollector (ErrorCollector &&)=default | |
| ErrorCollector & | operator= (ErrorCollector &&)=default |
| ErrorCollector (const ErrorCollector &)=default | |
| ErrorCollector & | operator= (const ErrorCollector &)=default |
| template<typename... Args> | |
| auto & | AddError (this auto &self, ErrorKind kind, const std::format_string< Args... > fmt, Args &&... args) |
| Add a specific error and return reference to derived class. | |
| auto & | AddError (this auto &self, Error err) |
| Add an existing error object and return reference to derived class. | |
| auto & | AddError (this auto &self, std::unexpected< Error > err) |
| Add an unexpected result's error and return reference to derived class. | |
| bool | has_errors () const |
| Check if any errors have been collected. | |
| size_t | error_count () const |
| Get the number of errors collected. | |
| Status | CheckErrors () const |
| Check for accumulated errors and return them if any exist. | |
| void | ClearErrors () |
| Clear all accumulated errors. | |
| const std::vector< Error > & | errors () const |
| Get read-only access to all collected errors. | |
Static Public Member Functions | |
| static std::unique_ptr< TableMetadataBuilder > | BuildFromEmpty (int8_t format_version=TableMetadata::kDefaultTableFormatVersion) |
| Create a builder for a new table. | |
| static std::unique_ptr< TableMetadataBuilder > | BuildFrom (const TableMetadata *base) |
| Create a builder from existing table metadata. | |
Additional Inherited Members | |
Protected Attributes inherited from iceberg::ErrorCollector | |
| std::vector< Error > | errors_ |
Builder class for constructing TableMetadata objects.
This builder provides a fluent interface for creating and modifying table metadata. It supports both creating new tables and building from existing metadata.
Each modification method generates a corresponding TableUpdate that is tracked in a changes list. This allows the builder to maintain a complete history of all modifications made to the table metadata, which is important for tracking table evolution and for serialization purposes.
If a modification violates Iceberg table constraints (e.g., setting a current schema ID that does not exist), an error will be recorded and returned when Build() is called.
| TableMetadataBuilder & iceberg::TableMetadataBuilder::AddEncryptionKey | ( | std::shared_ptr< EncryptedKey > | key | ) |
Add an encryption key to the table.
| key | The encryption key to add |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::AddPartitionSpec | ( | std::shared_ptr< PartitionSpec > | spec | ) |
Add a partition spec to the table.
| spec | The partition spec to add |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::AddSchema | ( | const std::shared_ptr< Schema > & | schema | ) |
Add a schema to the table.
| schema | The schema to add |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::AddSnapshot | ( | std::shared_ptr< Snapshot > | snapshot | ) |
Add a snapshot to the table.
| snapshot | The snapshot to add |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::AddSortOrder | ( | std::shared_ptr< SortOrder > | order | ) |
Add a sort order to the table.
| order | The sort order to add |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::ApplyChangesForCreate | ( | const TableMetadata & | base | ) |
Apply changes required to create this table metadata.
| base | The table metadata to build from |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::AssignUUID | ( | ) |
Assign a UUID to the table.
If no UUID is provided, a random UUID will be generated.
| TableMetadataBuilder & iceberg::TableMetadataBuilder::AssignUUID | ( | std::string_view | uuid | ) |
Assign a specific UUID to the table.
| uuid | The UUID string to assign |
| Result< std::unique_ptr< TableMetadata > > iceberg::TableMetadataBuilder::Build | ( | ) |
Build the TableMetadata object.
|
static |
Create a builder from existing table metadata.
| base | The base table metadata to build from |
|
static |
Create a builder for a new table.
| format_version | The format version for the table |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::RemoveEncryptionKey | ( | std::string_view | key_id | ) |
Remove an encryption key from the table by key ID.
| key_id | The ID of the encryption key to remove |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::RemovePartitionSpecs | ( | const std::vector< int32_t > & | spec_ids | ) |
Remove partition specs from the table.
| spec_ids | The IDs of partition specs to remove |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::RemovePartitionStatistics | ( | int64_t | snapshot_id | ) |
Remove partition statistics by snapshot ID.
| snapshot_id | The snapshot ID whose partition statistics to remove |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::RemoveProperties | ( | const std::unordered_set< std::string > & | removed | ) |
Remove table properties.
| removed | Set of property keys to remove |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::RemoveRef | ( | const std::string & | name | ) |
Remove a snapshot reference.
| name | The name of the reference to remove |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::RemoveSchemas | ( | const std::unordered_set< int32_t > & | schema_ids | ) |
Remove schemas from the table.
| schema_ids | The IDs of schemas to remove |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::RemoveSnapshots | ( | const std::vector< int64_t > & | snapshot_ids | ) |
Remove snapshots from the table.
| snapshot_ids | The IDs of snapshots to remove |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::RemoveSnapshots | ( | const std::vector< std::shared_ptr< Snapshot > > & | snapshots_to_remove | ) |
Remove snapshots from the table.
| snapshots_to_remove | The snapshots to remove |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::RemoveStatistics | ( | int64_t | snapshot_id | ) |
Remove table statistics by snapshot ID.
| snapshot_id | The snapshot ID whose statistics to remove |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetBranchSnapshot | ( | int64_t | snapshot_id, |
| const std::string & | branch | ||
| ) |
Set a branch to point to a specific snapshot.
| snapshot_id | The snapshot ID the branch should reference |
| branch | The name of the branch |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetBranchSnapshot | ( | std::shared_ptr< Snapshot > | snapshot, |
| const std::string & | branch | ||
| ) |
Set a branch to point to a specific snapshot.
| snapshot | The snapshot the branch should reference |
| branch | The name of the branch |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetCurrentSchema | ( | const std::shared_ptr< Schema > & | schema, |
| int32_t | new_last_column_id | ||
| ) |
Set the current schema for the table.
| schema | The schema to set as current |
| new_last_column_id | The highest column ID in the schema |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetCurrentSchema | ( | int32_t | schema_id | ) |
Set the current schema by schema ID.
| schema_id | The ID of the schema to set as current |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetDefaultPartitionSpec | ( | int32_t | spec_id | ) |
Set the default partition spec by spec ID.
| spec_id | The ID of the partition spec to set as default |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetDefaultPartitionSpec | ( | std::shared_ptr< PartitionSpec > | spec | ) |
Set the default partition spec for the table.
| spec | The partition spec to set as default |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetDefaultSortOrder | ( | int32_t | order_id | ) |
Set the default sort order by order ID.
| order_id | The ID of the sort order to set as default |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetDefaultSortOrder | ( | std::shared_ptr< SortOrder > | order | ) |
Set the default sort order for the table.
| order | The sort order to set as default |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetLocation | ( | std::string_view | location | ) |
Set the table location.
| location | The table base location |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetMetadataLocation | ( | std::string_view | metadata_location | ) |
Set the metadata location of the table.
| metadata_location | The new metadata location |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetPartitionStatistics | ( | const std::shared_ptr< PartitionStatisticsFile > & | partition_statistics_file | ) |
Set partition statistics.
| partition_statistics_file | The partition statistics file to set |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetPreviousMetadataLocation | ( | std::string_view | previous_metadata_location | ) |
Set the previous metadata location of the table.
| previous_metadata_location | The previous metadata location |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetProperties | ( | const std::unordered_map< std::string, std::string > & | updated | ) |
Set table properties.
| updated | Map of properties to set or update |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetRef | ( | const std::string & | name, |
| std::shared_ptr< SnapshotRef > | ref | ||
| ) |
Set a snapshot reference.
| name | The name of the reference |
| ref | The snapshot reference to set |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SetStatistics | ( | std::shared_ptr< StatisticsFile > | statistics_file | ) |
Set table statistics.
| statistics_file | The statistics file to set |
| TableMetadataBuilder & iceberg::TableMetadataBuilder::SuppressHistoricalSnapshots | ( | ) |
Suppresses snapshots that are historical, removing the metadata for lazy snapshot loading.
Note that the snapshots are not considered removed from metadata and no RemoveSnapshot changes are created. A snapshot is historical if no ref directly references its ID.
| TableMetadataBuilder & iceberg::TableMetadataBuilder::UpgradeFormatVersion | ( | int8_t | new_format_version | ) |
Upgrade the format version of the table.
| new_format_version | The new format version (must be >= current version) |