Skip to content

Commit 255657b

Browse files
authored
feat: add merge append (#699)
1 parent 950fbff commit 255657b

13 files changed

Lines changed: 1675 additions & 0 deletions

src/iceberg/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ set(ICEBERG_SOURCES
101101
type.cc
102102
update/expire_snapshots.cc
103103
update/fast_append.cc
104+
update/merge_append.cc
104105
update/merging_snapshot_update.cc
105106
update/pending_update.cc
106107
update/set_snapshot.cc

src/iceberg/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ iceberg_sources = files(
126126
'type.cc',
127127
'update/expire_snapshots.cc',
128128
'update/fast_append.cc',
129+
'update/merge_append.cc',
129130
'update/merging_snapshot_update.cc',
130131
'update/pending_update.cc',
131132
'update/set_snapshot.cc',

src/iceberg/table.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "iceberg/transaction.h"
3434
#include "iceberg/update/expire_snapshots.h"
3535
#include "iceberg/update/fast_append.h"
36+
#include "iceberg/update/merge_append.h"
3637
#include "iceberg/update/set_snapshot.h"
3738
#include "iceberg/update/snapshot_manager.h"
3839
#include "iceberg/update/update_location.h"
@@ -217,6 +218,12 @@ Result<std::shared_ptr<FastAppend>> Table::NewFastAppend() {
217218
return FastAppend::Make(name().name, std::move(ctx));
218219
}
219220

221+
Result<std::shared_ptr<MergeAppend>> Table::NewMergeAppend() {
222+
ICEBERG_ASSIGN_OR_RAISE(
223+
auto ctx, TransactionContext::Make(shared_from_this(), TransactionKind::kUpdate));
224+
return MergeAppend::Make(name().name, std::move(ctx));
225+
}
226+
220227
Result<std::shared_ptr<UpdateStatistics>> Table::NewUpdateStatistics() {
221228
ICEBERG_ASSIGN_OR_RAISE(
222229
auto ctx, TransactionContext::Make(shared_from_this(), TransactionKind::kUpdate));
@@ -316,6 +323,10 @@ Result<std::shared_ptr<FastAppend>> StaticTable::NewFastAppend() {
316323
return NotSupported("Cannot create a fast append for a static table");
317324
}
318325

326+
Result<std::shared_ptr<MergeAppend>> StaticTable::NewMergeAppend() {
327+
return NotSupported("Cannot create a merge append for a static table");
328+
}
329+
319330
Result<std::shared_ptr<SnapshotManager>> StaticTable::NewSnapshotManager() {
320331
return NotSupported("Cannot create a snapshot manager for a static table");
321332
}

src/iceberg/table.h

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

179+
/// \brief Create a new MergeAppend to append data files and merge manifests.
180+
virtual Result<std::shared_ptr<MergeAppend>> NewMergeAppend();
181+
179182
/// \brief Create a new SnapshotManager to manage snapshots and snapshot references.
180183
virtual Result<std::shared_ptr<SnapshotManager>> NewSnapshotManager();
181184

@@ -243,6 +246,8 @@ class ICEBERG_EXPORT StaticTable : public Table {
243246

244247
Result<std::shared_ptr<FastAppend>> NewFastAppend() override;
245248

249+
Result<std::shared_ptr<MergeAppend>> NewMergeAppend() override;
250+
246251
Result<std::shared_ptr<SnapshotManager>> NewSnapshotManager() override;
247252

248253
private:

src/iceberg/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ if(ICEBERG_BUILD_BUNDLE)
225225
expire_snapshots_test.cc
226226
fast_append_test.cc
227227
manifest_filter_manager_test.cc
228+
merge_append_test.cc
228229
merging_snapshot_update_test.cc
229230
name_mapping_update_test.cc
230231
snapshot_manager_test.cc

0 commit comments

Comments
 (0)