Skip to content

Commit

Permalink
turn table state version into a private field (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
houqp authored Aug 29, 2022
1 parent dbc2994 commit 1477198
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions rust/src/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ impl DeltaTable {

/// Currently loaded evrsion of the table
pub fn version(&self) -> DeltaDataTypeVersion {
self.state.version
self.state.version()
}

/// Load DeltaTable with data from latest checkpoint
Expand Down Expand Up @@ -864,7 +864,6 @@ impl DeltaTable {
} else {
self.last_check_point = Some(last_check_point);
self.restore_checkpoint(last_check_point).await?;
self.state.version = last_check_point.version;
self.update_incremental().await
}
}
Expand Down
4 changes: 2 additions & 2 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extern crate thiserror;
pub mod action;
pub mod checkpoints;
pub mod data_catalog;
mod delta;
pub mod delta;
pub mod delta_arrow;
pub mod delta_config;
pub mod object_store;
Expand All @@ -102,7 +102,7 @@ pub mod optimize;
pub mod partitions;
pub mod schema;
pub mod storage;
mod table_state;
pub mod table_state;
pub mod time_utils;
pub mod vacuum;
pub mod writer;
Expand Down
9 changes: 8 additions & 1 deletion rust/src/table_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::io::{BufRead, BufReader, Cursor};
/// State snapshot currently held by the Delta Table instance.
#[derive(Default, Debug, Clone)]
pub struct DeltaTableState {
pub version: DeltaDataTypeVersion,
version: DeltaDataTypeVersion,
// A remove action should remain in the state of the table as a tombstone until it has expired.
// A tombstone expires when the creation timestamp of the delta file exceeds the expiration
tombstones: HashSet<action::Remove>,
Expand All @@ -34,12 +34,19 @@ pub struct DeltaTableState {
}

impl DeltaTableState {
/// Create Table state with specified version
pub fn with_version(version: DeltaDataTypeVersion) -> Self {
Self {
version,
..Self::default()
}
}

/// Return table version
pub fn version(&self) -> DeltaDataTypeVersion {
self.version
}

/// Construct a delta table state object from commit version.
pub async fn from_commit(
table: &DeltaTable,
Expand Down

0 comments on commit 1477198

Please sign in to comment.