iceberg-cpp
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
iceberg::PendingUpdate Class Referenceabstract

Base class for all kinds of table metadata updates. More...

#include <pending_update.h>

Inheritance diagram for iceberg::PendingUpdate:
iceberg::ErrorCollector iceberg::ExpireSnapshots iceberg::SetSnapshot iceberg::SnapshotUpdate iceberg::UpdateLocation iceberg::UpdatePartitionSpec iceberg::UpdatePartitionStatistics iceberg::UpdateProperties iceberg::UpdateSchema iceberg::UpdateSnapshotReference iceberg::UpdateSortOrder iceberg::UpdateStatistics

Public Types

enum class  Kind : uint8_t {
  kExpireSnapshots , kSetSnapshot , kUpdateLocation , kUpdatePartitionSpec ,
  kUpdatePartitionStatistics , kUpdateProperties , kUpdateSchema , kUpdateSnapshot ,
  kUpdateSnapshotReference , kUpdateSortOrder , kUpdateStatistics
}
 

Public Member Functions

virtual Kind kind () const =0
 Return the kind of this pending update.
 
virtual bool IsRetryable () const =0
 Whether this update can be retried after a commit conflict.
 
virtual Status Commit ()
 Apply the pending changes and commit.
 
 PendingUpdate (const PendingUpdate &)=delete
 
PendingUpdate & operator= (const PendingUpdate &)=delete
 
 PendingUpdate (PendingUpdate &&)=delete
 
PendingUpdate & operator= (PendingUpdate &&)=delete
 
- 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.
 
auto & AddError (this auto &self, Error err)
 Add an existing error object.
 
auto & AddError (this auto &self, ::iceberg::unexpected< Error > err)
 Add an unexpected result's error.
 
auto & AddError (this auto &self, std::unexpected< Error > err)
 
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.
 

Protected Member Functions

 PendingUpdate (std::shared_ptr< TransactionContext > ctx)
 
const TableMetadata & base () const
 
Status CheckCommitAllowed () const
 
virtual Status CleanStaged ()
 Discard this generation's staging, retaining applied operation intent.
 
virtual Status Finalize (const TableMetadata &committed)
 Complete a known successful commit. Called only by Transaction with the final committed table metadata.
 

Protected Attributes

std::shared_ptr< TransactionContext > ctx_
 
- Protected Attributes inherited from iceberg::ErrorCollector
std::vector< Error > errors_
 

Friends

class Transaction
 

Detailed Description

Base class for all kinds of table metadata updates.

Any created PendingUpdate instance is tracked by the Transaction instance and commit is also delegated to the Transaction instance.

Lifecycle: an update is configured through its fluent mutators, then committed exactly once. After that point the update is owned by its transaction until the transaction reaches a terminal state.

Note
Implementations are expected to use builder pattern and errors should be handled by the ErrorCollector base class. Configuration errors are collected and surfaced by Commit(). Callers must not mutate input objects or reconfigure an update after its first commit.

Member Function Documentation

◆ CleanStaged()

virtual Status iceberg::PendingUpdate::CleanStaged ( )
inlineprotectedvirtual

Discard this generation's staging, retaining applied operation intent.

Reimplemented in iceberg::SnapshotUpdate.

◆ Commit()

virtual Status iceberg::PendingUpdate::Commit ( )
virtual

Apply the pending changes and commit.

Returns
An OK status if the commit was successful, or an error:
  • ValidationFailed: if it cannot be applied to the current table metadata.
  • CommitFailed: if it cannot be committed due to conflicts.
  • CommitStateUnknown: unknown status, no cleanup should be done.
Note
The update must be owned by a std::shared_ptr before calling Commit(). An Apply failure is terminal and cannot be corrected within the same transaction.

Reimplemented in iceberg::SnapshotUpdate.

◆ Finalize()

virtual Status iceberg::PendingUpdate::Finalize ( const TableMetadata &  committed)
protectedvirtual

Complete a known successful commit. Called only by Transaction with the final committed table metadata.

Reimplemented in iceberg::SnapshotUpdate.

◆ IsRetryable()

virtual bool iceberg::PendingUpdate::IsRetryable ( ) const
pure virtual

◆ kind()

virtual Kind iceberg::PendingUpdate::kind ( ) const
pure virtual

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