Skip to content

Conversation

@shangxinli
Copy link
Contributor

Add ExpireSnapshots as a concrete implementation extending PendingUpdateTyped, following Gang's suggestion to avoid pure interfaces when there's only one implementation.

Changes:

  • ExpireSnapshots is now a concrete class (not pure interface)
  • Builder methods (ExpireSnapshotId, ExpireOlderThan, etc.) are non-virtual for performance
  • Apply() and Commit() remain virtual (from PendingUpdateTyped)
  • Added placeholder implementations in expire_snapshots.cc
  • Updated tests to use concrete class directly
  • Added source file to CMakeLists.txt and meson.build

This design provides:

  • Simpler one-class implementation (vs interface + impl)
  • No virtual function overhead for builder methods
  • Still polymorphic through PendingUpdate base (for Transaction)
  • Maintains fluent API and type safety

Full implementation of Apply() and Commit() will be added in follow-up PRs.

@shangxinli shangxinli force-pushed the ExpireSnapshots branch 7 times, most recently from bfd5280 to e1f179b Compare November 29, 2025 04:30
literal_test.cc
predicate_test.cc)

add_iceberg_test(update_test SOURCES ../update/test/expire_snapshots_test.cc)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think this test file should be placed under src/iceberg/test/update/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Add ExpireSnapshots as a concrete implementation in iceberg/update/
following the PendingUpdate pattern.

Features:
- Fluent API builder methods: ExpireSnapshotId, ExpireOlderThan,
  RetainLast, DeleteWith, SetCleanupLevel
- Extends PendingUpdateTyped<vector<shared_ptr<Snapshot>>>
- Takes Table* in constructor for access to table metadata
- Placeholder implementations for Apply() and Commit()

Directory structure:
- src/iceberg/update/expire_snapshots.{h,cc}
- src/iceberg/update/CMakeLists.txt
- src/iceberg/update/meson.build
- Updated build files (CMakeLists.txt, meson.build)
Add comprehensive test suite for ExpireSnapshots API.

Tests cover:
- Fluent API chaining
- ExpireSnapshotId single and multiple
- ExpireOlderThan timestamp-based expiration
- RetainLast to keep recent snapshots
- DeleteWith custom deletion callback
- SetCleanupLevel with different levels (None, MetadataOnly, All)
- Combined configuration scenarios

Test file location: src/iceberg/test/update/expire_snapshots_test.cc
/// \brief Create a new expire snapshots operation for this table
///
/// \return a shared pointer to the new ExpireSnapshots operation
virtual std::shared_ptr<ExpireSnapshots> NewExpireSnapshots();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: return unique_ptr?

Change Table::NewExpireSnapshots() and Transaction::NewExpireSnapshots()
to return std::unique_ptr instead of std::shared_ptr for consistency
with other factory methods (NewScan, NewTransaction) that create new
objects with exclusive ownership transfer to the caller.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants