Skip to content

Commit 71df87c

Browse files
committed
feat: add SnapshotManager
The test cases are derived from Java's TestSnapshotManager.java. Since MergeAppend is not supported yet, some tests are omitted for now and can be added later.
1 parent c46b38e commit 71df87c

15 files changed

Lines changed: 990 additions & 0 deletions

src/iceberg/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ set(ICEBERG_SOURCES
8989
update/fast_append.cc
9090
update/pending_update.cc
9191
update/set_snapshot.cc
92+
update/snapshot_manager.cc
9293
update/snapshot_update.cc
9394
update/update_location.cc
9495
update/update_partition_spec.cc

src/iceberg/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ iceberg_sources = files(
107107
'update/fast_append.cc',
108108
'update/pending_update.cc',
109109
'update/set_snapshot.cc',
110+
'update/snapshot_manager.cc',
110111
'update/snapshot_update.cc',
111112
'update/update_location.cc',
112113
'update/update_partition_spec.cc',

src/iceberg/table.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "iceberg/table_scan.h"
3333
#include "iceberg/transaction.h"
3434
#include "iceberg/update/expire_snapshots.h"
35+
#include "iceberg/update/snapshot_manager.h"
3536
#include "iceberg/update/update_partition_spec.h"
3637
#include "iceberg/update/update_partition_statistics.h"
3738
#include "iceberg/update/update_properties.h"
@@ -222,6 +223,10 @@ Result<std::shared_ptr<UpdatePartitionStatistics>> Table::NewUpdatePartitionStat
222223
return transaction->NewUpdatePartitionStatistics();
223224
}
224225

226+
Result<std::shared_ptr<SnapshotManager>> Table::NewSnapshotManager() {
227+
return SnapshotManager::Make(name().ToString(), shared_from_this());
228+
}
229+
225230
Result<std::shared_ptr<StagedTable>> StagedTable::Make(
226231
TableIdentifier identifier, std::shared_ptr<TableMetadata> metadata,
227232
std::string metadata_location, std::shared_ptr<FileIO> io,

src/iceberg/table.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ class ICEBERG_EXPORT Table : public std::enable_shared_from_this<Table> {
168168
/// \brief Create a new FastAppend to append data files and commit the changes.
169169
virtual Result<std::shared_ptr<FastAppend>> NewFastAppend();
170170

171+
/// \brief Create a new SnapshotManager to manage snapshots and snapshot references.
172+
virtual Result<std::shared_ptr<SnapshotManager>> NewSnapshotManager();
173+
171174
protected:
172175
Table(TableIdentifier identifier, std::shared_ptr<TableMetadata> metadata,
173176
std::string metadata_location, std::shared_ptr<FileIO> io,

src/iceberg/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ if(ICEBERG_BUILD_BUNDLE)
179179
expire_snapshots_test.cc
180180
fast_append_test.cc
181181
set_snapshot_test.cc
182+
snapshot_manager_test.cc
182183
transaction_test.cc
183184
update_location_test.cc
184185
update_partition_spec_test.cc

0 commit comments

Comments
 (0)