pub struct SnapshotManager { /* private fields */ }Expand description
Manager for snapshot files using unified FileIO.
Reference: org.apache.paimon.utils.SnapshotManager.
Implementations§
Source§impl SnapshotManager
impl SnapshotManager
Sourcepub fn new(file_io: FileIO, table_path: String) -> Self
pub fn new(file_io: FileIO, table_path: String) -> Self
Create a snapshot manager for the given table path and FileIO.
pub fn file_io(&self) -> &FileIO
Sourcepub fn snapshot_dir(&self) -> String
pub fn snapshot_dir(&self) -> String
Path to the snapshot directory (e.g. table_path/snapshot).
Sourcepub fn snapshot_path(&self, snapshot_id: i64) -> String
pub fn snapshot_path(&self, snapshot_id: i64) -> String
Path to the snapshot file for the given id (e.g. snapshot/snapshot-1).
Sourcepub fn manifest_dir(&self) -> String
pub fn manifest_dir(&self) -> String
Path to the manifest directory.
Sourcepub fn manifest_path(&self, manifest_name: &str) -> String
pub fn manifest_path(&self, manifest_name: &str) -> String
Path to a manifest file.
Sourcepub async fn get_latest_snapshot_id(&self) -> Result<Option<i64>>
pub async fn get_latest_snapshot_id(&self) -> Result<Option<i64>>
Get the latest snapshot id.
First tries the LATEST hint file. If the hint is valid and no next snapshot exists, returns it. Otherwise falls back to listing snapshot files.
Reference: HintFileUtils.findLatest
Sourcepub async fn earliest_snapshot_id(&self) -> Result<Option<i64>>
pub async fn earliest_snapshot_id(&self) -> Result<Option<i64>>
Get the earliest snapshot id.
First tries the EARLIEST hint file. If the hint is valid and the snapshot file exists, returns it. Otherwise falls back to listing snapshot files.
Reference: HintFileUtils.findEarliest
Sourcepub async fn get_snapshot(&self, snapshot_id: i64) -> Result<Snapshot>
pub async fn get_snapshot(&self, snapshot_id: i64) -> Result<Snapshot>
Get a snapshot by id.
Sourcepub async fn get_latest_snapshot(&self) -> Result<Option<Snapshot>>
pub async fn get_latest_snapshot(&self) -> Result<Option<Snapshot>>
Get the latest snapshot, or None if no snapshots exist.
Sourcepub async fn commit_snapshot(&self, snapshot: &Snapshot) -> Result<bool>
pub async fn commit_snapshot(&self, snapshot: &Snapshot) -> Result<bool>
Atomically commit a snapshot.
Writes the snapshot JSON to the target path. Returns false if the
target already exists (another writer won the race).
On file systems that support atomic rename, we write to a temp file first then rename. On backends where rename is not supported (e.g. memory, object stores), we fall back to a direct write after an existence check.
Sourcepub async fn write_latest_hint(&self, snapshot_id: i64) -> Result<()>
pub async fn write_latest_hint(&self, snapshot_id: i64) -> Result<()>
Update the LATEST hint file.
Sourcepub async fn earlier_or_equal_time_mills(
&self,
timestamp_millis: i64,
) -> Result<Option<Snapshot>>
pub async fn earlier_or_equal_time_mills( &self, timestamp_millis: i64, ) -> Result<Option<Snapshot>>
Returns the snapshot whose commit time is earlier than or equal to the given
timestamp_millis. If no such snapshot exists, returns None.
Uses binary search over snapshot IDs (assumes monotonically increasing commit times).
Reference: SnapshotManager.earlierOrEqualTimeMills
Trait Implementations§
Source§impl Clone for SnapshotManager
impl Clone for SnapshotManager
Source§fn clone(&self) -> SnapshotManager
fn clone(&self) -> SnapshotManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more