Skip to content

Commit

Permalink
Introduce LogStore trait
Browse files Browse the repository at this point in the history
This trait is supposed to serve as the entry point to read and write
commits in the Delta log.
  • Loading branch information
dispanser committed Oct 6, 2023
1 parent 4da7d66 commit fcd4dd6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ compile_error!(

pub mod data_catalog;
pub mod errors;
pub mod logstore;
pub mod operations;
pub mod protocol;
pub mod schema;
Expand Down
36 changes: 36 additions & 0 deletions rust/src/logstore/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//! Delta log store.
use crate::errors::DeltaResult;
use bytes::Bytes;

use crate::protocol::Action;

/// Trait for critical operations required to read and write commit entries in Delta logs.
///
/// The correctness is predicated on the atomicity and durability guarantees of
/// the implementation of this interface. Specifically,
///
/// - Atomic visibility: Any commit created via `write_commit_entry` must become visible atomically.
/// - Mutual exclusion: Only one writer must be able to create a commit for a specific version.
/// - Consistent listing: Once a commit entry for version `v` has been written, any future call to
/// `get_latest_version` must return a version >= `v`, i.e. the underlying file system entry must
/// become visible immediately.
#[async_trait::async_trait]
pub trait LogStore {
/// Read data for commit entry with the given version.
/// TODO: return the actual commit data, i.e. Vec<Action>, instead?
async fn read_commit_entry(&self, version: i64) -> DeltaResult<Bytes>;

/// Write list of actions as delta commit entry for given version.
///
/// This operation can be retried with a higher version in case the write
/// fails with `TransactionError::VersionAlreadyExists`.
async fn write_commit_entry(
&self,
version: i64,
actions: Vec<Action>,
overwrite: bool,
) -> DeltaResult<()>;

/// Find latest version currently stored in the delta log.
async fn get_latest_version(&self) -> DeltaResult<i64>;
}

0 comments on commit fcd4dd6

Please sign in to comment.