70 static Result<std::shared_ptr<ExpireSnapshots>> Make(
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;
123 ExpireSnapshots& DeleteWith(std::function<
void(
const std::string&)> delete_func);
158 Kind
kind() const final {
return Kind::kExpireSnapshots; }
163 Result<ApplyResult> Apply();
174 Status Finalize(Result<const TableMetadata*> commit_result)
override;
179 using SnapshotToRef = std::unordered_map<std::string, std::shared_ptr<SnapshotRef>>;
181 Result<SnapshotToRef> ComputeRetainedRefs(
const SnapshotToRef& refs)
const;
183 Result<std::unordered_set<int64_t>> ComputeBranchSnapshotsToRetain(
184 int64_t snapshot_id, TimePointMs expire_snapshot_older_than,
185 int32_t min_snapshots_to_keep)
const;
187 Result<std::unordered_set<int64_t>> ComputeAllBranchSnapshotIdsToRetain(
188 const SnapshotToRef& refs)
const;
190 Result<std::unordered_set<int64_t>> UnreferencedSnapshotIdsToRetain(
191 const SnapshotToRef& refs)
const;
193 const TimePointMs current_time_ms_;
194 const int64_t default_max_ref_age_ms_;
195 int32_t default_min_num_snapshots_;
196 TimePointMs default_expire_older_than_;
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_;