iceberg-cpp
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | 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.
 
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.
 

Protected Member Functions

 PendingUpdate (std::shared_ptr< TransactionContext > ctx)
 
const TableMetadatabase () const
 

Protected Attributes

std::shared_ptr< TransactionContextctx_
 
- Protected Attributes inherited from iceberg::ErrorCollector
std::vector< Errorerrors_
 

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.

Note
Implementations are expected to use builder pattern and errors should be handled by the ErrorCollector base class.

Member Function Documentation

◆ Commit()

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.

◆ Finalize()

Status iceberg::PendingUpdate::Finalize ( Result< const TableMetadata * >  commit_result)
virtual

Finalize the pending update.

This method is called after the update is committed. Implementations should override this method to clean up any resources.

Parameters
commit_resultThe committed table metadata when the commit succeeds, or the commit error when it fails.
Returns
Status indicating success or failure

Reimplemented in iceberg::ExpireSnapshots, and 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 files: