Skip to content

Commit b07fbb3

Browse files
ZENOTMEZENOTME
and
ZENOTME
authored
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]>
1 parent f5242cd commit b07fbb3

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

crates/iceberg/src/spec/manifest_list.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ mod _const_schema {
507507
}
508508

509509
/// Entry in a manifest list.
510-
#[derive(Debug, PartialEq, Clone)]
510+
#[derive(Debug, PartialEq, Clone, Eq, Hash)]
511511
pub struct ManifestFile {
512512
/// field: 500
513513
///
@@ -587,17 +587,22 @@ pub struct ManifestFile {
587587
impl ManifestFile {
588588
/// Checks if the manifest file has any added files.
589589
pub fn has_added_files(&self) -> bool {
590-
self.added_files_count.is_none() || self.added_files_count.unwrap() > 0
590+
self.added_files_count.map(|c| c > 0).unwrap_or(true)
591+
}
592+
593+
/// Checks whether this manifest contains entries with DELETED status.
594+
pub fn has_deleted_files(&self) -> bool {
595+
self.deleted_files_count.map(|c| c > 0).unwrap_or(true)
591596
}
592597

593598
/// Checks if the manifest file has any existed files.
594599
pub fn has_existing_files(&self) -> bool {
595-
self.existing_files_count.is_none() || self.existing_files_count.unwrap() > 0
600+
self.existing_files_count.map(|c| c > 0).unwrap_or(true)
596601
}
597602
}
598603

599604
/// The type of files tracked by the manifest, either data or delete files; Data(0) for all v1 manifests
600-
#[derive(Debug, PartialEq, Clone, Copy, Eq)]
605+
#[derive(Debug, PartialEq, Clone, Copy, Eq, Hash)]
601606
pub enum ManifestContentType {
602607
/// The manifest content is data.
603608
Data = 0,
@@ -668,7 +673,7 @@ impl ManifestFile {
668673
/// Field summary for partition field in the spec.
669674
///
670675
/// Each field in the list corresponds to a field in the manifest file’s partition spec.
671-
#[derive(Debug, PartialEq, Eq, Clone, Default)]
676+
#[derive(Debug, PartialEq, Eq, Clone, Default, Hash)]
672677
pub struct FieldSummary {
673678
/// field: 509
674679
///

0 commit comments

Comments
 (0)