Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions src/iceberg/manifest_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,19 @@ ICEBERG_EXPORT constexpr Result<ManifestStatus> ManifestStatusFromInt(
}
}

enum class DataFileContent {
kData = 0,
kPositionDeletes = 1,
kEqualityDeletes = 2,
};

/// \brief Get the relative data file content type from int
ICEBERG_EXPORT constexpr Result<DataFileContent> 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;
Expand Down Expand Up @@ -322,4 +308,19 @@ struct ICEBERG_EXPORT ManifestEntry {
std::shared_ptr<StructType> datafile_type);
};

/// \brief Get the relative data file content type from int
ICEBERG_EXPORT constexpr Result<DataFile::Content> 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
57 changes: 28 additions & 29 deletions src/iceberg/manifest_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ManifestContent> 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.
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -232,4 +213,22 @@ struct ICEBERG_EXPORT ManifestList {
std::vector<ManifestFile> 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<ManifestFile::Content> 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
Loading