27#include <unordered_map>
28#include <unordered_set>
71 std::shared_ptr<TransactionContext> ctx);
76 std::vector<std::string> refs_to_remove;
77 std::vector<int64_t> snapshot_ids_to_remove;
78 std::vector<int32_t> partition_spec_ids_to_remove;
79 std::unordered_set<int32_t> schema_ids_to_remove;
80 std::shared_ptr<const TableMetadata> metadata_before_expiration;
158 Kind
kind() const final {
return Kind::kExpireSnapshots; }
179 using SnapshotToRef = std::unordered_map<std::string, std::shared_ptr<SnapshotRef>>;
184 int64_t snapshot_id,
TimePointMs expire_snapshot_older_than,
185 int32_t min_snapshots_to_keep)
const;
188 const SnapshotToRef& refs)
const;
191 const SnapshotToRef& refs)
const;
194 const int64_t default_max_ref_age_ms_;
195 int32_t default_min_num_snapshots_;
197 std::function<void(
const std::string&)> delete_func_;
198 std::vector<int64_t> snapshot_ids_to_expire_;
199 enum CleanupLevel cleanup_level_ { CleanupLevel::kAll };
200 OptionalExecutor plan_executor_;
201 bool clean_expired_metadata_{
false};
202 bool specified_snapshot_id_{
false};
203 OptionalExecutor delete_executor_;
206 std::optional<ApplyResult> apply_result_;
Schedules iceberg-cpp internal planning tasks.
Definition executor.h:46
API for removing old snapshots from a table.
Definition expire_snapshots.h:68
Status Finalize(Result< const TableMetadata * > commit_result) override
Finalize the expire snapshots update, cleaning up expired files.
ExpireSnapshots & RetainLast(int num_snapshots)
Retains the most recent ancestors of the current snapshot.
bool IsRetryable() const override
Whether this update can be retried after a commit conflict.
Definition expire_snapshots.h:159
ExpireSnapshots & PlanWith(Executor &executor)
Configure an executor for planning expired snapshot metadata.
ExpireSnapshots & CleanExpiredMetadata(bool clean)
Enable cleaning up unused metadata, such as partition specs, schemas, etc.
Result< ApplyResult > Apply()
Apply the pending changes and return the results.
ExpireSnapshots & DeleteWith(std::function< void(const std::string &)> delete_func)
Passes an alternative delete implementation that will be used for manifests and data files.
Kind kind() const final
Return the kind of this pending update.
Definition expire_snapshots.h:158
ExpireSnapshots & CleanupLevel(enum CleanupLevel level)
Configures the cleanup level for expired files.
ExpireSnapshots & ExpireSnapshotId(int64_t snapshot_id)
Expires a specific Snapshot identified by id.
ExpireSnapshots & ExpireOlderThan(int64_t timestamp_millis)
Expires all snapshots older than the given timestamp.
ExpireSnapshots & ExecuteDeleteWith(Executor &executor)
Configure an executor for DeleteWith() callbacks.
Base class for all kinds of table metadata updates.
Definition pending_update.h:41
Define task executor interfaces.
Define symbol visibility macros for core Iceberg APIs.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:33
std::chrono::time_point< std::chrono::system_clock, std::chrono::milliseconds > TimePointMs
A time point in milliseconds.
Definition timepoint.h:33
CleanupLevel
An enum representing possible clean up levels used in snapshot expiration.
Definition expire_snapshots.h:44
@ kAll
Clean up both metadata and data files (default).
@ kNone
Skip all file cleanup, only remove snapshot metadata.
std::expected< T, E > Result
Result alias.
Definition result.h:88
Define Result, Status, and error helpers.
Definition expire_snapshots.h:75
Provide time point conversion helpers.