wgtmac commented on code in PR #648:
URL: https://github.com/apache/iceberg-cpp/pull/648#discussion_r3264416547
##########
src/iceberg/update/expire_snapshots.cc:
##########
@@ -613,11 +917,23 @@ Status ExpireSnapshots::Finalize(Result<const
TableMetadata*> commit_result) {
apply_result_.reset();
// File cleanup is best-effort: log and continue on individual file deletion
failures
- ReachableFileCleanup strategy(ctx_->table->io(), delete_func_);
- return strategy.CleanFiles(metadata_before_expiration,
metadata_after_expiration,
- expired_ids, cleanup_level_);
+ // Pick incremental cleanup when the expiration is a simple linear-ancestry
walk:
+ // no explicit snapshot IDs, no removed snapshots outside main ancestry, and
no
+ // retained snapshots outside main ancestry. Mirrors Java RemoveSnapshots's
+ // dispatch in cleanExpiredSnapshots().
+ bool can_use_incremental = !specified_snapshot_id_ &&
+
!HasRemovedNonMainAncestors(metadata_before_expiration,
+
metadata_after_expiration) &&
+ !HasNonMainSnapshots(metadata_after_expiration);
+
+ std::unique_ptr<FileCleanupStrategy> strategy;
+ if (can_use_incremental) {
+ strategy = std::make_unique<IncrementalFileCleanup>(ctx_->table->io(),
delete_func_);
+ } else {
+ strategy = std::make_unique<ReachableFileCleanup>(ctx_->table->io(),
delete_func_);
+ }
+ return strategy->CleanFiles(metadata_before_expiration,
metadata_after_expiration,
Review Comment:
This status is ignored by the normal `Commit()` paths today. Please add a
commit-path test and propagate parsing/planning errors, otherwise malformed
`source-snapshot-id` still reports success.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]