Skip to content

Commit

Permalink
rename to set_transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
zachschuermann committed Oct 9, 2024
1 parent 8ba7f4d commit 2935d43
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
6 changes: 3 additions & 3 deletions kernel/src/actions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::features::{ReaderFeatures, WriterFeatures};
use crate::{schema::StructType, DeltaResult, EngineData};

pub mod deletion_vector;
pub mod transaction;
pub mod set_transaction;

pub(crate) mod schemas;
pub(crate) mod visitors;
Expand All @@ -31,7 +31,7 @@ static LOG_SCHEMA: LazyLock<StructType> = LazyLock::new(|| {
Option::<Remove>::get_struct_field(REMOVE_NAME),
Option::<Metadata>::get_struct_field(METADATA_NAME),
Option::<Protocol>::get_struct_field(PROTOCOL_NAME),
Option::<Transaction>::get_struct_field(TRANSACTION_NAME),
Option::<SetTransaction>::get_struct_field(TRANSACTION_NAME),
Option::<CommitInfo>::get_struct_field(COMMIT_INFO_NAME),
// We don't support the following actions yet
//Option::<Cdc>::get_struct_field(CDC_NAME),
Expand Down Expand Up @@ -245,7 +245,7 @@ impl Remove {
}

#[derive(Debug, Clone, PartialEq, Eq, Schema)]
pub struct Transaction {
pub struct SetTransaction {
/// A unique identifier for the application performing the transaction.
pub app_id: String,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use crate::actions::visitors::TransactionVisitor;
use crate::actions::{get_log_schema, Transaction, TRANSACTION_NAME};
use crate::actions::{get_log_schema, SetTransaction, TRANSACTION_NAME};
use crate::snapshot::Snapshot;
use crate::{DeltaResult, Engine, EngineData, SchemaRef};

Expand Down Expand Up @@ -58,7 +58,7 @@ impl TransactionScanner {
&self,
engine: &dyn Engine,
application_id: &str,
) -> DeltaResult<Option<Transaction>> {
) -> DeltaResult<Option<SetTransaction>> {
let mut transactions = self.scan_application_transactions(engine, Some(application_id))?;
Ok(transactions.remove(application_id))
}
Expand All @@ -78,7 +78,10 @@ mod tests {
use crate::Table;
use itertools::Itertools;

fn get_latest_transactions(path: &str, app_id: &str) -> (TransactionMap, Option<Transaction>) {
fn get_latest_transactions(
path: &str,
app_id: &str,
) -> (TransactionMap, Option<SetTransaction>) {
let path = std::fs::canonicalize(PathBuf::from(path)).unwrap();
let url = url::Url::from_directory_path(path).unwrap();
let engine = SyncEngine::new();
Expand All @@ -105,7 +108,7 @@ mod tests {
assert_eq!(txns.get("my-app"), txn.as_ref());
assert_eq!(
txns.get("my-app2"),
Some(Transaction {
Some(SetTransaction {
app_id: "my-app2".to_owned(),
version: 2,
last_updated: None
Expand All @@ -119,7 +122,7 @@ mod tests {
assert_eq!(txns.get("my-app"), txn.as_ref());
assert_eq!(
txns.get("my-app2"),
Some(Transaction {
Some(SetTransaction {
app_id: "my-app2".to_owned(),
version: 2,
last_updated: None
Expand Down
13 changes: 7 additions & 6 deletions kernel/src/actions/visitors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use crate::{
};

use super::{
deletion_vector::DeletionVectorDescriptor, Add, Format, Metadata, Protocol, Remove, Transaction,
deletion_vector::DeletionVectorDescriptor, Add, Format, Metadata, Protocol, Remove,
SetTransaction,
};

#[derive(Default)]
Expand Down Expand Up @@ -230,7 +231,7 @@ impl DataVisitor for RemoveVisitor {
}
}

pub type TransactionMap = HashMap<String, Transaction>;
pub type TransactionMap = HashMap<String, SetTransaction>;

/// Extact application transaction actions from the log into a map
///
Expand Down Expand Up @@ -259,10 +260,10 @@ impl TransactionVisitor {
row_index: usize,
app_id: String,
getters: &[&'a dyn GetData<'a>],
) -> DeltaResult<Transaction> {
) -> DeltaResult<SetTransaction> {
let version: i64 = getters[1].get(row_index, "txn.version")?;
let last_updated: Option<i64> = getters[2].get_long(row_index, "txn.lastUpdated")?;
Ok(Transaction {
Ok(SetTransaction {
app_id,
version,
last_updated,
Expand Down Expand Up @@ -490,15 +491,15 @@ mod tests {
let mut actual = txn_visitor.transactions;
assert_eq!(
actual.remove("myApp2"),
Some(Transaction {
Some(SetTransaction {
app_id: "myApp2".to_string(),
version: 4,
last_updated: Some(1670892998177),
},)
);
assert_eq!(
actual.remove("myApp"),
Some(Transaction {
Some(SetTransaction {
app_id: "myApp".to_string(),
version: 3,
last_updated: None,
Expand Down

0 comments on commit 2935d43

Please sign in to comment.