2121
2222#include < optional>
2323#include < string>
24+ #include < string_view>
2425#include < unordered_map>
2526#include < variant>
2627#include < vector>
2728
2829#include " iceberg/iceberg_export.h"
29- #include " iceberg/util/formattable.h"
3030
3131namespace iceberg {
3232
@@ -63,82 +63,79 @@ struct ICEBERG_EXPORT SnapshotRef {
6363// / \brief Optional Snapshot Summary Fields
6464struct SnapshotSummaryFields {
6565 // / \brief The operation field key
66- constexpr static std::string_view kOperation = " operation " ;
66+ static const std::string kOperation ;
6767
6868 // / Metrics, see https://iceberg.apache.org/spec/#metrics
6969
7070 // / \brief Number of data files added in the snapshot
71- constexpr static std::string_view kAddedDataFiles = " added-data-files " ;
71+ static const std::string kAddedDataFiles ;
7272 // / \brief Number of data files deleted in the snapshot
73- constexpr static std::string_view kDeletedDataFiles = " deleted-data-files " ;
73+ static const std::string kDeletedDataFiles ;
7474 // / \brief Total number of live data files in the snapshot
75- constexpr static std::string_view kTotalDataFiles = " total-data-files " ;
75+ static const std::string kTotalDataFiles ;
7676 // / \brief Number of positional/equality delete files and deletion vectors added in the
7777 // / snapshot
78- constexpr static std::string_view kAddedDeleteFiles = " added-delete-files " ;
78+ static const std::string kAddedDeleteFiles ;
7979 // / \brief Number of equality delete files added in the snapshot
80- constexpr static std::string_view kAddedEqDeleteFiles = " added-equality-delete-files " ;
80+ static const std::string kAddedEqDeleteFiles ;
8181 // / \brief Number of equality delete files removed in the snapshot
82- constexpr static std::string_view kRemovedEqDeleteFiles =
83- " removed-equality-delete-files" ;
82+ static const std::string kRemovedEqDeleteFiles ;
8483 // / \brief Number of position delete files added in the snapshot
85- constexpr static std::string_view kAddedPosDeleteFiles = " added-position-delete-files " ;
84+ static const std::string kAddedPosDeleteFiles ;
8685 // / \brief Number of position delete files removed in the snapshot
87- constexpr static std::string_view kRemovedPosDeleteFiles =
88- " removed-position-delete-files" ;
86+ static const std::string kRemovedPosDeleteFiles ;
8987 // / \brief Number of deletion vectors added in the snapshot
90- constexpr static std::string_view kAddedDVS = " added-dvs " ;
88+ static const std::string kAddedDVS ;
9189 // / \brief Number of deletion vectors removed in the snapshot
92- constexpr static std::string_view kRemovedDVS = " removed-dvs " ;
90+ static const std::string kRemovedDVS ;
9391 // / \brief Number of positional/equality delete files and deletion vectors removed in
9492 // / the snapshot
95- constexpr static std::string_view kRemovedDeleteFiles = " removed-delete-files " ;
93+ static const std::string kRemovedDeleteFiles ;
9694 // / \brief Total number of live positional/equality delete files and deletion vectors in
9795 // / the snapshot
98- constexpr static std::string_view kTotalDeleteFiles = " total-delete-files " ;
96+ static const std::string kTotalDeleteFiles ;
9997 // / \brief Number of records added in the snapshot
100- constexpr static std::string_view kAddedRecords = " added-records " ;
98+ static const std::string kAddedRecords ;
10199 // / \brief Number of records deleted in the snapshot
102- constexpr static std::string_view kDeletedRecords = " deleted-records " ;
100+ static const std::string kDeletedRecords ;
103101 // / \brief Total number of records in the snapshot
104- constexpr static std::string_view kTotalRecords = " total-records " ;
102+ static const std::string kTotalRecords ;
105103 // / \brief The size of files added in the snapshot
106- constexpr static std::string_view kAddedFileSize = " added-files-size " ;
104+ static const std::string kAddedFileSize ;
107105 // / \brief The size of files removed in the snapshot
108- constexpr static std::string_view kRemovedFileSize = " removed-files-size " ;
106+ static const std::string kRemovedFileSize ;
109107 // / \brief Total size of live files in the snapshot
110- constexpr static std::string_view kTotalFileSize = " total-files-size " ;
108+ static const std::string kTotalFileSize ;
111109 // / \brief Number of position delete records added in the snapshot
112- constexpr static std::string_view kAddedPosDeletes = " added-position-deletes " ;
110+ static const std::string kAddedPosDeletes ;
113111 // / \brief Number of position delete records removed in the snapshot
114- constexpr static std::string_view kRemovedPosDeletes = " removed-position-deletes " ;
112+ static const std::string kRemovedPosDeletes ;
115113 // / \brief Total number of position delete records in the snapshot
116- constexpr static std::string_view kTotalPosDeletes = " total-position-deletes " ;
114+ static const std::string kTotalPosDeletes ;
117115 // / \brief Number of equality delete records added in the snapshot
118- constexpr static std::string_view kAddedEqDeletes = " added-equality-deletes " ;
116+ static const std::string kAddedEqDeletes ;
119117 // / \brief Number of equality delete records removed in the snapshot
120- constexpr static std::string_view kRemovedEqDeletes = " removed-equality-deletes " ;
118+ static const std::string kRemovedEqDeletes ;
121119 // / \brief Total number of equality delete records in the snapshot
122- constexpr static std::string_view kTotalEqDeletes = " total-equality-deletes " ;
120+ static const std::string kTotalEqDeletes ;
123121 // / \brief Number of duplicate files deleted (duplicates are files recorded more than
124122 // / once in the manifest)
125- constexpr static std::string_view kDeletedDuplicatedFiles = " deleted-duplicate-files " ;
123+ static const std::string kDeletedDuplicatedFiles ;
126124 // / \brief Number of partitions with files added or removed in the snapshot
127- constexpr static std::string_view kChangedPartitionCountProp =
128- " changed-partition-count" ;
125+ static const std::string kChangedPartitionCountProp ;
129126
130127 // / Other Fields, see https://iceberg.apache.org/spec/#other-fields
131128
132129 // / \brief The Write-Audit-Publish id of a staged snapshot
133- constexpr static std::string_view kWAPID = " wap.id " ;
130+ static const std::string kWAPID ;
134131 // / \brief The Write-Audit-Publish id of a snapshot already been published
135- constexpr static std::string_view kPublishedWAPID = " published-wap-id " ;
132+ static const std::string kPublishedWAPID ;
136133 // / \brief The original id of a cherry-picked snapshot
137- constexpr static std::string_view kSourceSnapshotID = " source-snapshot-id " ;
134+ static const std::string kSourceSnapshotID ;
138135 // / \brief Name of the engine that created the snapshot
139- constexpr static std::string_view kEngineName = " engine-name " ;
136+ static const std::string kEngineName ;
140137 // / \brief Version of the engine that created the snapshot
141- constexpr static std::string_view kEngineVersion = " engine-version " ;
138+ static const std::string kEngineVersion ;
142139};
143140
144141// / \brief Data operation that produce snapshots.
@@ -148,16 +145,27 @@ struct SnapshotSummaryFields {
148145// / does not need to clean up deleted files for appends, which have no deleted files.
149146struct ICEBERG_EXPORT DataOperation {
150147 // / \brief Only data files were added and no files were removed.
151- static constexpr std::string_view kAppend = " append" ;
148+ static constexpr std::string kAppend = " append" ;
152149 // / \brief Data and delete files were added and removed without changing table data;
153150 // / i.e. compaction, change the data file format, or relocating data files.
154- static constexpr std::string_view kReplace = " replace" ;
151+ static constexpr std::string kReplace = " replace" ;
155152 // / \brief Data and delete files were added and removed in a logical overwrite
156153 // / operation.
157- static constexpr std::string_view kOverwrite = " overwrite" ;
154+ static constexpr std::string kOverwrite = " overwrite" ;
158155 // / \brief Data files were removed and their contents logically deleted and/or delete
159156 // / files were added to delete rows.
160- static constexpr std::string_view kDelete = " delete" ;
157+ static constexpr std::string kDelete = " delete" ;
158+ };
159+
160+ // / \brief The location of a manifest list for this snapshot that tracks manifest files
161+ // / with additional metadata
162+ struct ICEBERG_EXPORT ManifestList {
163+ std::string manifest_list_path;
164+ };
165+
166+ // / \brief A list of manifest file locations.
167+ struct ICEBERG_EXPORT Manifests {
168+ std::vector<std::string> manifest_paths;
161169};
162170
163171// / \brief A snapshot of the data in a table at a point in time.
@@ -167,9 +175,6 @@ struct ICEBERG_EXPORT DataOperation {
167175// /
168176// / Snapshots are created by table operations.
169177struct ICEBERG_EXPORT Snapshot {
170- using manifest_list_t = std::string;
171- using manifests_t = std::vector<std::string>;
172-
173178 // / A unqiue long ID.
174179 int64_t snapshot_id;
175180 // / The snapshot ID of the snapshot's parent. Omitted for any snapshot with no parent.
@@ -180,8 +185,8 @@ struct ICEBERG_EXPORT Snapshot {
180185 // / inspection.
181186 int64_t timestamp_ms;
182187 // / The location of a manifest list for this snapshot that tracks manifest files with
183- // / additional metadata.
184- std::variant<manifest_list_t , manifests_t > manifest_list;
188+ // / additional metadata(v2) or a list of manifest file locations(v1) .
189+ std::variant<std::monostate, ManifestList, Manifests > manifest_list;
185190 // / A string map that summaries the snapshot changes, including operation.
186191 std::unordered_map<std::string, std::string> summary;
187192 // / ID of the table's current schema when the snapshot was created.
@@ -192,19 +197,19 @@ struct ICEBERG_EXPORT Snapshot {
192197 // /
193198 // / \return the operation that produced this snapshot, or nullopt if the operation is
194199 // / unknown.
195- std::optional<std::string > operation () const ;
200+ std::optional<std::string_view > operation () const ;
196201
197202 // / \brief Get the manifest list for this snapshot.
198203 // /
199204 // / \return the manifest list for this snapshot, or nullopt if the snapshot has no
200205 // / manifest list.
201- std::optional<std::reference_wrapper<const manifest_list_t >> ManifestList () const ;
206+ std::optional<std::reference_wrapper<const ManifestList >> ManifestList () const ;
202207
203208 // / \brief Get the manifests for this snapshot.
204209 // /
205210 // / \return the manifests for this snapshot, or nullopt if the snapshot has no
206211 // / manifests.
207- std::optional<std::reference_wrapper<const manifests_t >> Manifests () const ;
212+ std::optional<std::reference_wrapper<const Manifests >> Manifests () const ;
208213
209214 // / \brief Compare two snapshots for equality.
210215 friend bool operator ==(const Snapshot& lhs, const Snapshot& rhs) {
0 commit comments