Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: Add missing property in Snapshot #41

Closed
wants to merge 1 commit into from
Closed
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
44 changes: 44 additions & 0 deletions crates/paimon/src/spec/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ pub struct Snapshot {
#[builder(default = None)]
index_manifest: Option<String>,
commit_user: String,
// Mainly for snapshot deduplication.
//
// If multiple snapshots have the same commitIdentifier, reading from any of these snapshots
Copy link
Contributor Author

@Aitozi Aitozi Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question out of this PR. Currently, the overwrite (expire partition) share the same commit identifier with the current snapshots's commit identifier. So I think this comments may not right ? CC @JingsongLi

// must produce the same table.
//
// If snapshot A has a smaller commitIdentifier than snapshot B, then snapshot A must be
// committed before snapshot B, and thus snapshot A must contain older records than snapshot B.
commit_identifier: i64,
commit_kind: CommitKind,
time_millis: u64,
/// record count of all changes occurred in this snapshot
#[builder(default = None)]
total_record_count: Option<i64>,
Expand Down Expand Up @@ -134,4 +144,38 @@ impl Snapshot {
pub fn statistics(&self) -> Option<&str> {
self.statistics.as_deref()
}

/// Get the commit time of this snapshot.
#[inline]
pub fn time_millis(&self) -> u64 {
self.time_millis
}

/// Get the commit identifier of this snapshot.
#[inline]
pub fn commit_identifier(&self) -> i64 {
self.commit_identifier
}

/// Get the commit kind of this snapshot.
#[inline]
pub fn commit_kind(&self) -> CommitKind {
self.commit_kind
}
}

/// Type of changes in this snapshot.
///
/// Impl Reference: <https://github.com/apache/paimon/blob/release-0.8.2/paimon-core/src/main/java/org/apache/paimon/Snapshot.java#L506>.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum CommitKind {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Aitozi We do not need this enum, you can refer #11.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @QuakeWang I think that just means log_offsets ?

/// Change flushed from the mem table.
Append,
/// Changes by compacting existing data files.
Compact,
/// Changes that clear up the whole partition and then add new records.
Overwrite,
/// Collect statistics.
Analyze,
}
Loading