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

Updates snapshot references. More...

#include <update_snapshot_reference.h>

Inheritance diagram for iceberg::UpdateSnapshotReference:
iceberg::PendingUpdate iceberg::ErrorCollector

Classes

struct  ApplyResult
 

Public Member Functions

UpdateSnapshotReferenceCreateBranch (const std::string &name, int64_t snapshot_id)
 Create a branch reference.
 
UpdateSnapshotReferenceCreateTag (const std::string &name, int64_t snapshot_id)
 Create a tag reference.
 
UpdateSnapshotReferenceRemoveBranch (const std::string &name)
 Remove a branch reference.
 
UpdateSnapshotReferenceRemoveTag (const std::string &name)
 Remove a tag reference.
 
UpdateSnapshotReferenceRenameBranch (const std::string &name, const std::string &new_name)
 Rename a branch reference.
 
UpdateSnapshotReferenceReplaceBranch (const std::string &name, int64_t snapshot_id)
 Replace a branch reference with a new snapshot ID.
 
UpdateSnapshotReferenceReplaceBranch (const std::string &from, const std::string &to)
 Replace a branch reference with another reference's snapshot ID.
 
UpdateSnapshotReferenceFastForward (const std::string &from, const std::string &to)
 Fast-forward a branch to another reference's snapshot ID.
 
UpdateSnapshotReferenceReplaceTag (const std::string &name, int64_t snapshot_id)
 Replace a tag reference with a new snapshot ID.
 
UpdateSnapshotReferenceSetMinSnapshotsToKeep (const std::string &name, int32_t min_snapshots_to_keep)
 Set the minimum number of snapshots to keep for a branch.
 
UpdateSnapshotReferenceSetMaxSnapshotAgeMs (const std::string &name, int64_t max_snapshot_age_ms)
 Set the maximum snapshot age in milliseconds for a branch.
 
UpdateSnapshotReferenceSetMaxRefAgeMs (const std::string &name, int64_t max_ref_age_ms)
 Set the maximum reference age in milliseconds.
 
Kind kind () const final
 Return the kind of this pending update.
 
bool IsRetryable () const override
 Snapshot reference updates are not retryable.
 
Result< ApplyResultApply ()
 Apply the pending changes and return the updated and removed references.
 
- Public Member Functions inherited from iceberg::PendingUpdate
virtual Status Commit ()
 Apply the pending changes and commit.
 
virtual Status Finalize (Result< const TableMetadata * > commit_result)
 Finalize the pending update.
 
 PendingUpdate (const PendingUpdate &)=delete
 
PendingUpdateoperator= (const PendingUpdate &)=delete
 
 PendingUpdate (PendingUpdate &&) noexcept=default
 
PendingUpdateoperator= (PendingUpdate &&) noexcept=default
 
- Public Member Functions inherited from iceberg::ErrorCollector
 ErrorCollector (ErrorCollector &&)=default
 
ErrorCollectoroperator= (ErrorCollector &&)=default
 
 ErrorCollector (const ErrorCollector &)=default
 
ErrorCollectoroperator= (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< UpdateSnapshotReference > > Make (std::shared_ptr< TransactionContext > ctx)
 

Additional Inherited Members

- Public Types inherited from iceberg::PendingUpdate
enum class  Kind : uint8_t {
  kExpireSnapshots , kSetSnapshot , kUpdateLocation , kUpdatePartitionSpec ,
  kUpdatePartitionStatistics , kUpdateProperties , kUpdateSchema , kUpdateSnapshot ,
  kUpdateSnapshotReference , kUpdateSortOrder , kUpdateStatistics
}
 
- Protected Member Functions inherited from iceberg::PendingUpdate
 PendingUpdate (std::shared_ptr< TransactionContext > ctx)
 
const TableMetadatabase () const
 
- Protected Attributes inherited from iceberg::PendingUpdate
std::shared_ptr< TransactionContextctx_
 
- Protected Attributes inherited from iceberg::ErrorCollector
std::vector< Errorerrors_
 

Detailed Description

Updates snapshot references.

TODO(xxx): Add SetSnapshot operations such as SetCurrentSnapshot, RollBackTime, RollbackTo to this class so that we can support those operations for refs.

Member Function Documentation

◆ CreateBranch()

UpdateSnapshotReference & iceberg::UpdateSnapshotReference::CreateBranch ( const std::string &  name,
int64_t  snapshot_id 
)

Create a branch reference.

Parameters
nameThe branch name
snapshot_idThe snapshot ID for the branch
Returns
Reference to this for method chaining

◆ CreateTag()

UpdateSnapshotReference & iceberg::UpdateSnapshotReference::CreateTag ( const std::string &  name,
int64_t  snapshot_id 
)

Create a tag reference.

Parameters
nameThe tag name
snapshot_idThe snapshot ID for the tag
Returns
Reference to this for method chaining

◆ FastForward()

UpdateSnapshotReference & iceberg::UpdateSnapshotReference::FastForward ( const std::string &  from,
const std::string &  to 
)

Fast-forward a branch to another reference's snapshot ID.

This is similar to ReplaceBranch but validates that the target snapshot is an ancestor of the current branch snapshot.

Parameters
fromThe branch name to update
toThe reference name to copy the snapshot ID from
Returns
Reference to this for method chaining

◆ IsRetryable()

bool iceberg::UpdateSnapshotReference::IsRetryable ( ) const
inlineoverridevirtual

Snapshot reference updates are not retryable.

The update snapshots the ref map at construction time and validates rename or fast-forward operations against that captured state. Replaying after a refresh can clobber or reinterpret concurrent ref changes.

Implements iceberg::PendingUpdate.

◆ kind()

Kind iceberg::UpdateSnapshotReference::kind ( ) const
inlinefinalvirtual

Return the kind of this pending update.

Implements iceberg::PendingUpdate.

◆ RemoveBranch()

UpdateSnapshotReference & iceberg::UpdateSnapshotReference::RemoveBranch ( const std::string &  name)

Remove a branch reference.

Parameters
nameThe branch name to remove
Returns
Reference to this for method chaining

◆ RemoveTag()

UpdateSnapshotReference & iceberg::UpdateSnapshotReference::RemoveTag ( const std::string &  name)

Remove a tag reference.

Parameters
nameThe tag name to remove
Returns
Reference to this for method chaining

◆ RenameBranch()

UpdateSnapshotReference & iceberg::UpdateSnapshotReference::RenameBranch ( const std::string &  name,
const std::string &  new_name 
)

Rename a branch reference.

Parameters
nameThe current branch name
new_nameThe new branch name
Returns
Reference to this for method chaining

◆ ReplaceBranch() [1/2]

UpdateSnapshotReference & iceberg::UpdateSnapshotReference::ReplaceBranch ( const std::string &  from,
const std::string &  to 
)

Replace a branch reference with another reference's snapshot ID.

Parameters
fromThe branch name to update
toThe reference name to copy the snapshot ID from
Returns
Reference to this for method chaining

◆ ReplaceBranch() [2/2]

UpdateSnapshotReference & iceberg::UpdateSnapshotReference::ReplaceBranch ( const std::string &  name,
int64_t  snapshot_id 
)

Replace a branch reference with a new snapshot ID.

Parameters
nameThe branch name
snapshot_idThe new snapshot ID
Returns
Reference to this for method chaining

◆ ReplaceTag()

UpdateSnapshotReference & iceberg::UpdateSnapshotReference::ReplaceTag ( const std::string &  name,
int64_t  snapshot_id 
)

Replace a tag reference with a new snapshot ID.

Parameters
nameThe tag name
snapshot_idThe new snapshot ID
Returns
Reference to this for method chaining

◆ SetMaxRefAgeMs()

UpdateSnapshotReference & iceberg::UpdateSnapshotReference::SetMaxRefAgeMs ( const std::string &  name,
int64_t  max_ref_age_ms 
)

Set the maximum reference age in milliseconds.

Parameters
nameThe reference name
max_ref_age_msThe maximum reference age in milliseconds
Returns
Reference to this for method chaining

◆ SetMaxSnapshotAgeMs()

UpdateSnapshotReference & iceberg::UpdateSnapshotReference::SetMaxSnapshotAgeMs ( const std::string &  name,
int64_t  max_snapshot_age_ms 
)

Set the maximum snapshot age in milliseconds for a branch.

Parameters
nameThe branch name
max_snapshot_age_msThe maximum snapshot age in milliseconds
Returns
Reference to this for method chaining

◆ SetMinSnapshotsToKeep()

UpdateSnapshotReference & iceberg::UpdateSnapshotReference::SetMinSnapshotsToKeep ( const std::string &  name,
int32_t  min_snapshots_to_keep 
)

Set the minimum number of snapshots to keep for a branch.

Parameters
nameThe branch name
min_snapshots_to_keepThe minimum number of snapshots to keep
Returns
Reference to this for method chaining

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