diff --git a/src/iceberg/manifest_entry.h b/src/iceberg/manifest_entry.h index c0393528d..43db00ae9 100644 --- a/src/iceberg/manifest_entry.h +++ b/src/iceberg/manifest_entry.h @@ -56,33 +56,19 @@ ICEBERG_EXPORT constexpr Result ManifestStatusFromInt( } } -enum class DataFileContent { - kData = 0, - kPositionDeletes = 1, - kEqualityDeletes = 2, -}; - -/// \brief Get the relative data file content type from int -ICEBERG_EXPORT constexpr Result DataFileContentFromInt( - int content) noexcept { - switch (content) { - case 0: - return DataFileContent::kData; - case 1: - return DataFileContent::kPositionDeletes; - case 2: - return DataFileContent::kEqualityDeletes; - default: - return InvalidArgument("Invalid data file content: {}", content); - } -} - /// \brief DataFile carries data file path, partition tuple, metrics, ... struct ICEBERG_EXPORT DataFile { + /// \brief Content of a data file + enum class Content { + kData = 0, + kPositionDeletes = 1, + kEqualityDeletes = 2, + }; + /// Field id: 134 /// Type of content stored by the data file: data, equality deletes, or position /// deletes (all v1 files are data files) - DataFileContent content; + Content content; /// Field id: 100 /// Full URI for the file with FS scheme std::string file_path; @@ -322,4 +308,19 @@ struct ICEBERG_EXPORT ManifestEntry { std::shared_ptr datafile_type); }; +/// \brief Get the relative data file content type from int +ICEBERG_EXPORT constexpr Result DataFileContentFromInt( + int content) noexcept { + switch (content) { + case 0: + return DataFile::Content::kData; + case 1: + return DataFile::Content::kPositionDeletes; + case 2: + return DataFile::Content::kEqualityDeletes; + default: + return InvalidArgument("Invalid data file content: {}", content); + } +} + } // namespace iceberg diff --git a/src/iceberg/manifest_list.h b/src/iceberg/manifest_list.h index af2b8dbbc..672b36ccb 100644 --- a/src/iceberg/manifest_list.h +++ b/src/iceberg/manifest_list.h @@ -33,34 +33,6 @@ namespace iceberg { -/// \brief The type of files tracked by the manifest, either data or delete files; 0 for -/// all v1 manifests -enum class ManifestContent { - /// The manifest content is data. - kData = 0, - /// The manifest content is deletes. - kDeletes = 1, -}; - -/// \brief Get the relative manifest content type name -ICEBERG_EXPORT constexpr std::string_view ManifestContentToString( - ManifestContent type) noexcept { - switch (type) { - case ManifestContent::kData: - return "data"; - case ManifestContent::kDeletes: - return "deletes"; - } -} - -/// \brief Get the relative manifest content type from name -ICEBERG_EXPORT constexpr Result ManifestContentFromString( - std::string_view str) noexcept { - if (str == "data") return ManifestContent::kData; - if (str == "deletes") return ManifestContent::kDeletes; - return InvalidArgument("Invalid manifest content type: {}", str); -} - /// \brief Field summary for partition field in the spec. /// /// Each field of this corresponds to a field in the manifest file's partition spec. @@ -98,6 +70,15 @@ struct ICEBERG_EXPORT PartitionFieldSummary { /// \brief Entry in a manifest list. struct ICEBERG_EXPORT ManifestFile { + /// \brief The type of files tracked by the manifest, either data or delete files; 0 for + /// all v1 manifests + enum class Content { + /// The manifest content is data. + kData = 0, + /// The manifest content is deletes. + kDeletes = 1, + }; + /// Field id: 500 /// Location of the manifest file std::string manifest_path; @@ -111,7 +92,7 @@ struct ICEBERG_EXPORT ManifestFile { /// Field id: 517 /// The type of files tracked by the manifest, either data or delete files; 0 for all v1 /// manifests - ManifestContent content; + Content content; /// Field id: 515 /// The sequence number when the manifest was added to the table; use 0 when reading v1 /// manifest lists @@ -232,4 +213,22 @@ struct ICEBERG_EXPORT ManifestList { std::vector entries; }; +/// \brief Get the relative manifest content type name +ICEBERG_EXPORT constexpr std::string_view ToString(ManifestFile::Content type) noexcept { + switch (type) { + case ManifestFile::Content::kData: + return "data"; + case ManifestFile::Content::kDeletes: + return "deletes"; + } +} + +/// \brief Get the relative manifest content type from name +ICEBERG_EXPORT constexpr Result ManifestFileContentFromString( + std::string_view str) noexcept { + if (str == "data") return ManifestFile::Content::kData; + if (str == "deletes") return ManifestFile::Content::kDeletes; + return InvalidArgument("Invalid manifest content type: {}", str); +} + } // namespace iceberg