|
iceberg-cpp
|
API for managing snapshots. More...
#include <snapshot_manager.h>
Public Member Functions | |
| SnapshotManager & | Cherrypick (int64_t snapshot_id) |
| Apply supported changes in given snapshot and create a new snapshot which will be set as the current snapshot on commit. | |
| SnapshotManager & | SetCurrentSnapshot (int64_t snapshot_id) |
| Roll this table's data back to a specific snapshot identified by id. | |
| SnapshotManager & | RollbackToTime (int64_t timestamp_ms) |
| Roll this table's data back to the last snapshot before the given timestamp. | |
| SnapshotManager & | RollbackTo (int64_t snapshot_id) |
| Rollback table's state to a specific snapshot identified by id. | |
| SnapshotManager & | CreateBranch (const std::string &name) |
| Create a new branch. The branch will point to current snapshot if the current snapshot is not NULL. Otherwise, the branch will point to a newly created empty snapshot. | |
| SnapshotManager & | CreateBranch (const std::string &name, int64_t snapshot_id) |
| Create a new branch pointing to the given snapshot id. | |
| SnapshotManager & | CreateTag (const std::string &name, int64_t snapshot_id) |
| Create a new tag pointing to the given snapshot id. | |
| SnapshotManager & | RemoveBranch (const std::string &name) |
| Remove a branch by name. | |
| SnapshotManager & | RemoveTag (const std::string &name) |
| Remove the tag with the given name. | |
| SnapshotManager & | ReplaceTag (const std::string &name, int64_t snapshot_id) |
| Replace the tag with the given name to point to the specified snapshot. | |
| SnapshotManager & | ReplaceBranch (const std::string &name, int64_t snapshot_id) |
| Replace the branch with the given name to point to the specified snapshot. | |
| SnapshotManager & | ReplaceBranch (const std::string &from, const std::string &to) |
| Replace the 'from' branch to point to the 'to' snapshot. The 'to' will remain unchanged, and 'from' branch will retain its retention properties. If the 'from' branch does not exist, it will be created with default retention properties. | |
| SnapshotManager & | FastForwardBranch (const std::string &from, const std::string &to) |
| Perform a fast-forward of 'from' up to the 'to' snapshot if 'from' is an ancestor of 'to'. The 'to' will remain unchanged, and 'from' will retain its retention properties. If the 'from' branch does not exist, it will be created with default retention properties. | |
| SnapshotManager & | RenameBranch (const std::string &name, const std::string &new_name) |
| Rename a branch. | |
| SnapshotManager & | SetMinSnapshotsToKeep (const std::string &branch_name, int32_t min_snapshots_to_keep) |
| Update the minimum number of snapshots to keep for a branch. | |
| SnapshotManager & | SetMaxSnapshotAgeMs (const std::string &branch_name, int64_t max_snapshot_age_ms) |
| Update the max snapshot age for a branch. | |
| SnapshotManager & | SetMaxRefAgeMs (const std::string &name, int64_t max_ref_age_ms) |
| Update the retention policy for a reference. | |
| Status | Commit () |
| Commit all pending changes. | |
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 Result< std::shared_ptr< SnapshotManager > > | Make (std::shared_ptr< Table > table) |
| Create a SnapshotManager that owns its own transaction. | |
| static Result< std::shared_ptr< SnapshotManager > > | Make (std::shared_ptr< Transaction > transaction) |
| Create a SnapshotManager from an existing transaction. | |
Additional Inherited Members | |
Protected Attributes inherited from iceberg::ErrorCollector | |
| std::vector< Error > | errors_ |
API for managing snapshots.
Allows rolling table data back to a stated at an older table snapshot.
Rollback: This API does not allow conflicting calls to SetCurrentSnapshot and RollbackToTime. When committing, these changes will be applied to the current table metadata. Commit conflicts will not be resolved and will result in a
Cherrypick: In an audit workflow, new data is written to an orphan snapshot that is not committed as the table's current state until it is audited. After auditing a change, it may need to be applied or cherry-picked on top of the latest snapshot instead of the one that was current when the audited changes were created. This class adds support for cherry-picking the changes from an orphan snapshot by applying them to the current snapshot. The output of the operation is a new snapshot with the changes from cherry-picked snapshot.
| SnapshotManager & iceberg::SnapshotManager::Cherrypick | ( | int64_t | snapshot_id | ) |
| SnapshotManager & iceberg::SnapshotManager::CreateBranch | ( | const std::string & | name | ) |
Create a new branch. The branch will point to current snapshot if the current snapshot is not NULL. Otherwise, the branch will point to a newly created empty snapshot.
| name | branch name |
| SnapshotManager & iceberg::SnapshotManager::CreateBranch | ( | const std::string & | name, |
| int64_t | snapshot_id | ||
| ) |
Create a new branch pointing to the given snapshot id.
| name | branch name |
| snapshot_id | id of the snapshot which will be the head of the branch |
| SnapshotManager & iceberg::SnapshotManager::CreateTag | ( | const std::string & | name, |
| int64_t | snapshot_id | ||
| ) |
Create a new tag pointing to the given snapshot id.
| name | tag name |
| snapshot_id | snapshot id for the head of the new tag |
| SnapshotManager & iceberg::SnapshotManager::FastForwardBranch | ( | const std::string & | from, |
| const std::string & | to | ||
| ) |
Perform a fast-forward of 'from' up to the 'to' snapshot if 'from' is an ancestor of 'to'. The 'to' will remain unchanged, and 'from' will retain its retention properties. If the 'from' branch does not exist, it will be created with default retention properties.
| from | branch to fast-forward |
| to | ref for the 'from' branch to be fast forwarded to |
|
static |
Create a SnapshotManager from an existing transaction.
| SnapshotManager & iceberg::SnapshotManager::RemoveBranch | ( | const std::string & | name | ) |
| SnapshotManager & iceberg::SnapshotManager::RemoveTag | ( | const std::string & | name | ) |
Remove the tag with the given name.
| name | tag name |
| SnapshotManager & iceberg::SnapshotManager::RenameBranch | ( | const std::string & | name, |
| const std::string & | new_name | ||
| ) |
Rename a branch.
| name | name of branch to rename |
| new_name | the desired new name of the branch |
| SnapshotManager & iceberg::SnapshotManager::ReplaceBranch | ( | const std::string & | from, |
| const std::string & | to | ||
| ) |
Replace the 'from' branch to point to the 'to' snapshot. The 'to' will remain unchanged, and 'from' branch will retain its retention properties. If the 'from' branch does not exist, it will be created with default retention properties.
| from | branch to replace |
| to | the branch 'from' should be replaced with |
| SnapshotManager & iceberg::SnapshotManager::ReplaceBranch | ( | const std::string & | name, |
| int64_t | snapshot_id | ||
| ) |
Replace the branch with the given name to point to the specified snapshot.
| name | branch to replace |
| snapshot_id | new snapshot id for the given branch |
| SnapshotManager & iceberg::SnapshotManager::ReplaceTag | ( | const std::string & | name, |
| int64_t | snapshot_id | ||
| ) |
Replace the tag with the given name to point to the specified snapshot.
| name | tag to replace |
| snapshot_id | new snapshot id for the given tag |
| SnapshotManager & iceberg::SnapshotManager::RollbackTo | ( | int64_t | snapshot_id | ) |
Rollback table's state to a specific snapshot identified by id.
| snapshot_id | long id of snapshot to roll back table to. Must be an ancestor of the current snapshot |
| SnapshotManager & iceberg::SnapshotManager::RollbackToTime | ( | int64_t | timestamp_ms | ) |
Roll this table's data back to the last snapshot before the given timestamp.
| timestamp_ms | a long timestamp in milliseconds |
| SnapshotManager & iceberg::SnapshotManager::SetCurrentSnapshot | ( | int64_t | snapshot_id | ) |
Roll this table's data back to a specific snapshot identified by id.
| snapshot_id | long id of the snapshot to roll back table data to |
| SnapshotManager & iceberg::SnapshotManager::SetMaxRefAgeMs | ( | const std::string & | name, |
| int64_t | max_ref_age_ms | ||
| ) |
Update the retention policy for a reference.
| name | branch name |
| max_ref_age_ms | retention age in milliseconds of the tag reference itself |
| SnapshotManager & iceberg::SnapshotManager::SetMaxSnapshotAgeMs | ( | const std::string & | branch_name, |
| int64_t | max_snapshot_age_ms | ||
| ) |
Update the max snapshot age for a branch.
| branch_name | branch name |
| max_snapshot_age_ms | maximum snapshot age in milliseconds to retain on branch |
| SnapshotManager & iceberg::SnapshotManager::SetMinSnapshotsToKeep | ( | const std::string & | branch_name, |
| int32_t | min_snapshots_to_keep | ||
| ) |
Update the minimum number of snapshots to keep for a branch.
| branch_name | branch name |
| min_snapshots_to_keep | minimum number of snapshots to retain on the branch |