2424#include < string_view>
2525#include < unordered_map>
2626#include < variant>
27- #include < vector>
2827
2928#include " iceberg/iceberg_export.h"
3029
@@ -42,100 +41,113 @@ enum class SnapshotRefType {
4241
4342// / \brief A reference to a snapshot, either a branch or a tag.
4443struct ICEBERG_EXPORT SnapshotRef {
44+ struct ICEBERG_EXPORT Branch {
45+ // / A positive number for the minimum number of snapshots to keep in a branch while
46+ // / expiring snapshots. Defaults to table property
47+ // / history.expire.min-snapshots-to-keep.
48+ std::optional<int32_t > min_snapshots_to_keep;
49+ // / A positive number for the max age of snapshots to keep when
50+ // / expiring, including the latest snapshot. Defaults to table property
51+ // / history.expire.max-snapshot-age-ms.
52+ std::optional<int64_t > max_snapshot_age_ms;
53+ // / For snapshot references except the main branch, a positive number for the max age
54+ // / of the snapshot reference to keep while expiring snapshots. Defaults to table
55+ // / property history.expire.max-ref-age-ms. The main branch never expires.
56+ std::optional<int64_t > max_ref_age_ms;
57+ };
58+
59+ struct ICEBERG_EXPORT Tag {
60+ // / For snapshot references except the main branch, a positive number for the max age
61+ // / of the snapshot reference to keep while expiring snapshots. Defaults to table
62+ // / property history.expire.max-ref-age-ms. The main branch never expires.
63+ std::optional<int64_t > max_ref_age_ms;
64+ };
65+
4566 // / A reference's snapshot ID. The tagged snapshot or latest snapshot of a branch.
4667 int64_t snapshot_id;
47- // / Type of the reference, tag or branch
48- SnapshotRefType type;
49- // / For branch type only, a positive number for the minimum number of snapshots to keep
50- // / in a branch while expiring snapshots. Defaults to table property
51- // / history.expire.min-snapshots-to-keep.
52- std::optional<int32_t > min_snapshots_to_keep;
53- // / For branch type only, a positive number for the max age of snapshots to keep when
54- // / expiring, including the latest snapshot. Defaults to table property
55- // / history.expire.max-snapshot-age-ms.
56- std::optional<int64_t > max_snapshot_age_ms;
57- // / For snapshot references except the main branch, a positive number for the max age of
58- // / the snapshot reference to keep while expiring snapshots. Defaults to table property
59- // / history.expire.max-ref-age-ms. The main branch never expires.
60- std::optional<int64_t > max_ref_age_ms;
68+ // / Snapshot retention policy
69+ std::variant<Branch, Tag> retention;
70+
71+ SnapshotRefType type () const noexcept ;
6172};
6273
6374// / \brief Optional Snapshot Summary Fields
6475struct SnapshotSummaryFields {
6576 // / \brief The operation field key
66- static const std::string kOperation ;
77+ inline static const std::string kOperation = " operation " ;
6778
6879 // / Metrics, see https://iceberg.apache.org/spec/#metrics
6980
7081 // / \brief Number of data files added in the snapshot
71- static const std::string kAddedDataFiles ;
82+ inline static const std::string kAddedDataFiles = " added-data-files " ;
7283 // / \brief Number of data files deleted in the snapshot
73- static const std::string kDeletedDataFiles ;
84+ inline static const std::string kDeletedDataFiles = " deleted-data-files " ;
7485 // / \brief Total number of live data files in the snapshot
75- static const std::string kTotalDataFiles ;
86+ inline static const std::string kTotalDataFiles = " total-data-files " ;
7687 // / \brief Number of positional/equality delete files and deletion vectors added in the
7788 // / snapshot
78- static const std::string kAddedDeleteFiles ;
89+ inline static const std::string kAddedDeleteFiles = " added-delete-files " ;
7990 // / \brief Number of equality delete files added in the snapshot
80- static const std::string kAddedEqDeleteFiles ;
91+ inline static const std::string kAddedEqDeleteFiles = " added-equality-delete-files " ;
8192 // / \brief Number of equality delete files removed in the snapshot
82- static const std::string kRemovedEqDeleteFiles ;
93+ inline static const std::string kRemovedEqDeleteFiles = " removed-equality-delete-files " ;
8394 // / \brief Number of position delete files added in the snapshot
84- static const std::string kAddedPosDeleteFiles ;
95+ inline static const std::string kAddedPosDeleteFiles = " added-position-delete-files " ;
8596 // / \brief Number of position delete files removed in the snapshot
86- static const std::string kRemovedPosDeleteFiles ;
97+ inline static const std::string kRemovedPosDeleteFiles =
98+ " removed-position-delete-files" ;
8799 // / \brief Number of deletion vectors added in the snapshot
88- static const std::string kAddedDVs ;
100+ inline static const std::string kAddedDVs = " added-dvs " ;
89101 // / \brief Number of deletion vectors removed in the snapshot
90- static const std::string kRemovedDVs ;
102+ inline static const std::string kRemovedDVs = " removed-dvs " ;
91103 // / \brief Number of positional/equality delete files and deletion vectors removed in
92104 // / the snapshot
93- static const std::string kRemovedDeleteFiles ;
105+ inline static const std::string kRemovedDeleteFiles = " removed-delete-files " ;
94106 // / \brief Total number of live positional/equality delete files and deletion vectors in
95107 // / the snapshot
96- static const std::string kTotalDeleteFiles ;
108+ inline static const std::string kTotalDeleteFiles = " total-delete-files " ;
97109 // / \brief Number of records added in the snapshot
98- static const std::string kAddedRecords ;
110+ inline static const std::string kAddedRecords = " added-records " ;
99111 // / \brief Number of records deleted in the snapshot
100- static const std::string kDeletedRecords ;
112+ inline static const std::string kDeletedRecords = " deleted-records " ;
101113 // / \brief Total number of records in the snapshot
102- static const std::string kTotalRecords ;
114+ inline static const std::string kTotalRecords = " total-records " ;
103115 // / \brief The size of files added in the snapshot
104- static const std::string kAddedFileSize ;
116+ inline static const std::string kAddedFileSize = " added-files-size " ;
105117 // / \brief The size of files removed in the snapshot
106- static const std::string kRemovedFileSize ;
118+ inline static const std::string kRemovedFileSize = " removed-files-size " ;
107119 // / \brief Total size of live files in the snapshot
108- static const std::string kTotalFileSize ;
120+ inline static const std::string kTotalFileSize = " total-files-size " ;
109121 // / \brief Number of position delete records added in the snapshot
110- static const std::string kAddedPosDeletes ;
122+ inline static const std::string kAddedPosDeletes = " added-position-deletes " ;
111123 // / \brief Number of position delete records removed in the snapshot
112- static const std::string kRemovedPosDeletes ;
124+ inline static const std::string kRemovedPosDeletes = " removed-position-deletes " ;
113125 // / \brief Total number of position delete records in the snapshot
114- static const std::string kTotalPosDeletes ;
126+ inline static const std::string kTotalPosDeletes = " total-position-deletes " ;
115127 // / \brief Number of equality delete records added in the snapshot
116- static const std::string kAddedEqDeletes ;
128+ inline static const std::string kAddedEqDeletes = " added-equality-deletes " ;
117129 // / \brief Number of equality delete records removed in the snapshot
118- static const std::string kRemovedEqDeletes ;
130+ inline static const std::string kRemovedEqDeletes = " removed-equality-deletes " ;
119131 // / \brief Total number of equality delete records in the snapshot
120- static const std::string kTotalEqDeletes ;
132+ inline static const std::string kTotalEqDeletes = " total-equality-deletes " ;
121133 // / \brief Number of duplicate files deleted (duplicates are files recorded more than
122134 // / once in the manifest)
123- static const std::string kDeletedDuplicatedFiles ;
135+ inline static const std::string kDeletedDuplicatedFiles = " deleted-duplicate-files " ;
124136 // / \brief Number of partitions with files added or removed in the snapshot
125- static const std::string kChangedPartitionCountProp ;
137+ inline static const std::string kChangedPartitionCountProp = " changed-partition-count " ;
126138
127139 // / Other Fields, see https://iceberg.apache.org/spec/#other-fields
128140
129141 // / \brief The Write-Audit-Publish id of a staged snapshot
130- static const std::string kWAPID ;
142+ inline static const std::string kWAPID = " wap.id " ;
131143 // / \brief The Write-Audit-Publish id of a snapshot already been published
132- static const std::string kPublishedWAPID ;
144+ inline static const std::string kPublishedWAPID = " published-wap-id " ;
133145 // / \brief The original id of a cherry-picked snapshot
134- static const std::string kSourceSnapshotID ;
146+ inline static const std::string kSourceSnapshotID = " source-snapshot-id " ;
135147 // / \brief Name of the engine that created the snapshot
136- static const std::string kEngineName ;
148+ inline static const std::string kEngineName = " engine-name " ;
137149 // / \brief Version of the engine that created the snapshot
138- static const std::string kEngineVersion ;
150+ inline static const std::string kEngineVersion = " engine-version " ;
139151};
140152
141153// / \brief Data operation that produce snapshots.
@@ -145,16 +157,16 @@ struct SnapshotSummaryFields {
145157// / does not need to clean up deleted files for appends, which have no deleted files.
146158struct ICEBERG_EXPORT DataOperation {
147159 // / \brief Only data files were added and no files were removed.
148- static constexpr std::string kAppend = " append" ;
160+ inline static const std::string kAppend = " append" ;
149161 // / \brief Data and delete files were added and removed without changing table data;
150162 // / i.e. compaction, change the data file format, or relocating data files.
151- static constexpr std::string kReplace = " replace" ;
163+ inline static const std::string kReplace = " replace" ;
152164 // / \brief Data and delete files were added and removed in a logical overwrite
153165 // / operation.
154- static constexpr std::string kOverwrite = " overwrite" ;
166+ inline static const std::string kOverwrite = " overwrite" ;
155167 // / \brief Data files were removed and their contents logically deleted and/or delete
156168 // / files were added to delete rows.
157- static constexpr std::string kDelete = " delete" ;
169+ inline static const std::string kDelete = " delete" ;
158170};
159171
160172// / \brief A snapshot of the data in a table at a point in time.
0 commit comments