@@ -57,15 +57,6 @@ ICEBERG_EXPORT constexpr Result<ManifestStatus> ManifestStatusFromInt(
5757 }
5858}
5959
60- enum class ManifestContent {
61- kData = 0 ,
62- kDeletes = 1 ,
63- };
64-
65- ICEBERG_EXPORT constexpr std::string_view ToString (ManifestContent content) noexcept ;
66- ICEBERG_EXPORT constexpr Result<ManifestContent> ManifestContentFromString (
67- std::string_view str) noexcept ;
68-
6960// / \brief DataFile carries data file path, partition tuple, metrics, ...
7061struct ICEBERG_EXPORT DataFile {
7162 // / \brief Content of a data file
@@ -277,6 +268,7 @@ struct ICEBERG_EXPORT DataFile {
277268
278269 bool operator ==(const DataFile& other) const = default ;
279270
271+ // / \brief Get the schema of the data file with the given partition type.
280272 static std::shared_ptr<StructType> Type (std::shared_ptr<StructType> partition_type);
281273};
282274
@@ -315,6 +307,33 @@ struct ICEBERG_EXPORT ManifestEntry {
315307 inline static const SchemaField kFileSequenceNumber =
316308 SchemaField::MakeOptional (4 , " file_sequence_number" , iceberg::int64());
317309
310+ // / \brief Check if this manifest entry is deleted.
311+ constexpr bool IsAlive () const {
312+ return status == ManifestStatus::kAdded || status == ManifestStatus::kExisting ;
313+ }
314+
315+ ManifestEntry AsAdded () const {
316+ ManifestEntry copy = *this ;
317+ copy.status = ManifestStatus::kAdded ;
318+ if (copy.data_file ->first_row_id .has_value ()) {
319+ copy.data_file = std::make_unique<DataFile>(*copy.data_file );
320+ copy.data_file ->first_row_id = std::nullopt ;
321+ }
322+ return copy;
323+ }
324+
325+ ManifestEntry AsExisting () const {
326+ ManifestEntry copy = *this ;
327+ copy.status = ManifestStatus::kExisting ;
328+ return copy;
329+ }
330+
331+ ManifestEntry AsDeleted () const {
332+ ManifestEntry copy = *this ;
333+ copy.status = ManifestStatus::kDeleted ;
334+ return copy;
335+ }
336+
318337 bool operator ==(const ManifestEntry& other) const ;
319338
320339 static std::shared_ptr<StructType> TypeFromPartitionType (
@@ -323,6 +342,19 @@ struct ICEBERG_EXPORT ManifestEntry {
323342 std::shared_ptr<StructType> datafile_type);
324343};
325344
345+ // / \brief Get the relative datafile content type name
346+ ICEBERG_EXPORT constexpr std::string_view ToString (DataFile::Content type) noexcept {
347+ switch (type) {
348+ case DataFile::Content::kData :
349+ return " data" ;
350+ case DataFile::Content::kPositionDeletes :
351+ return " position_deletes" ;
352+ case DataFile::Content::kEqualityDeletes :
353+ return " equality_deletes" ;
354+ }
355+ std::unreachable ();
356+ }
357+
326358// / \brief Get the relative data file content type from int
327359ICEBERG_EXPORT constexpr Result<DataFile::Content> DataFileContentFromInt (
328360 int content) noexcept {
0 commit comments