This is an automated email from the ASF dual-hosted git repository.
liurenjie1024 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-rust.git
The following commit(s) were added to refs/heads/main by this push:
new b07fbb32 refine: refine ManifestFile (#1117)
b07fbb32 is described below
commit b07fbb32f23ad64449a81e93e7eeff36c9d9cce4
Author: ZENOTME <[email protected]>
AuthorDate: Fri Mar 21 16:31:15 2025 +0800
refine: refine ManifestFile (#1117)
## Which issue does this PR close?
This PR adds `Hash` to ManifestFile and fulfills the miss function of
ManifestFile. It's required for RewriteManifest action(WIP now and I
will send the PR for this later) in the future.
---------
Co-authored-by: ZENOTME <[email protected]>
---
crates/iceberg/src/spec/manifest_list.rs | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/crates/iceberg/src/spec/manifest_list.rs
b/crates/iceberg/src/spec/manifest_list.rs
index 4618c8a4..8cf5df8d 100644
--- a/crates/iceberg/src/spec/manifest_list.rs
+++ b/crates/iceberg/src/spec/manifest_list.rs
@@ -507,7 +507,7 @@ mod _const_schema {
}
/// Entry in a manifest list.
-#[derive(Debug, PartialEq, Clone)]
+#[derive(Debug, PartialEq, Clone, Eq, Hash)]
pub struct ManifestFile {
/// field: 500
///
@@ -587,17 +587,22 @@ pub struct ManifestFile {
impl ManifestFile {
/// Checks if the manifest file has any added files.
pub fn has_added_files(&self) -> bool {
- self.added_files_count.is_none() || self.added_files_count.unwrap() > 0
+ self.added_files_count.map(|c| c > 0).unwrap_or(true)
+ }
+
+ /// Checks whether this manifest contains entries with DELETED status.
+ pub fn has_deleted_files(&self) -> bool {
+ self.deleted_files_count.map(|c| c > 0).unwrap_or(true)
}
/// Checks if the manifest file has any existed files.
pub fn has_existing_files(&self) -> bool {
- self.existing_files_count.is_none() ||
self.existing_files_count.unwrap() > 0
+ self.existing_files_count.map(|c| c > 0).unwrap_or(true)
}
}
/// The type of files tracked by the manifest, either data or delete files;
Data(0) for all v1 manifests
-#[derive(Debug, PartialEq, Clone, Copy, Eq)]
+#[derive(Debug, PartialEq, Clone, Copy, Eq, Hash)]
pub enum ManifestContentType {
/// The manifest content is data.
Data = 0,
@@ -668,7 +673,7 @@ impl ManifestFile {
/// Field summary for partition field in the spec.
///
/// Each field in the list corresponds to a field in the manifest file’s
partition spec.
-#[derive(Debug, PartialEq, Eq, Clone, Default)]
+#[derive(Debug, PartialEq, Eq, Clone, Default, Hash)]
pub struct FieldSummary {
/// field: 509
///