Skip to content
Draft
Show file tree
Hide file tree
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
27 changes: 20 additions & 7 deletions rust/lance-table/src/transaction/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
//!
//! The wire format and the reasoning behind it live in
//! `protos/transaction/actions.proto`; the two definitions must stay in step.
//! Only the subset of the specified vocabulary that is implemented appears here --
//! an action this build does not know is rejected on load rather than skipped.
//! Every action the specification defines is implemented here, so the two
//! vocabularies now coincide -- an action a newer Lance writes is rejected on
//! load rather than skipped.
//!
//! Each action lives in its own module and owns everything about itself: its
//! definition, how it is applied, which coordinates it writes, and its wire
Expand Down Expand Up @@ -66,6 +67,9 @@ macro_rules! for_each_action {
TombstoneFieldData,
RemoveFragment,
SetDeletionFile,
AddOverlays,
RefreshRowVersionMetadata,
UpdateCompactedSsTables,
AlterField,
DropField,
AddIndexSegment,
Expand All @@ -75,6 +79,7 @@ macro_rules! for_each_action {
ReserveRowIds,
ResetTable,
ConfigUpdate,
AssertUniqueKeys,
}
};
}
Expand All @@ -84,20 +89,24 @@ mod add_data_file;
mod add_field;
mod add_fragment;
mod add_index_segment;
mod add_overlays;
mod adjust_index_coverage;
mod alter_field;
mod apply;
mod assert_unique_keys;
mod config_update;
mod drop_field;
mod footprint;
mod proto;
mod refresh_row_version_metadata;
mod remove_fragment;
mod remove_index_segment;
mod reserve_fragment_ids;
mod reserve_row_ids;
mod reset_table;
mod set_deletion_file;
mod tombstone_field_data;
mod update_compacted_sstables;

#[cfg(test)]
mod test_support;
Expand All @@ -107,18 +116,22 @@ pub use add_data_file::AddDataFile;
pub use add_field::AddField;
pub use add_fragment::AddFragment;
pub use add_index_segment::AddIndexSegment;
pub use add_overlays::AddOverlays;
pub use adjust_index_coverage::AdjustIndexCoverage;
pub use alter_field::AlterField;
pub use assert_unique_keys::AssertUniqueKeys;
pub use config_update::{ConfigUpdate, FieldMetadataUpdate};
pub use drop_field::DropField;
pub use footprint::{ConfigMap, Coordinate, Footprint};
pub use refresh_row_version_metadata::RefreshRowVersionMetadata;
pub use remove_fragment::RemoveFragment;
pub use remove_index_segment::RemoveIndexSegment;
pub use reserve_fragment_ids::ReserveFragmentIds;
pub use reserve_row_ids::ReserveRowIds;
pub use reset_table::ResetTable;
pub use set_deletion_file::SetDeletionFile;
pub use tombstone_field_data::TombstoneFieldData;
pub use update_compacted_sstables::UpdateCompactedSsTables;

use apply::ApplyState;
use lance_core::Result;
Expand Down Expand Up @@ -266,12 +279,12 @@ impl UserAction {

macro_rules! define_action {
($($variant:ident,)*) => {
/// A single granular change to the manifest.
/// A single granular change to the manifest, or an assertion about the
/// version it lands on.
///
/// The specified vocabulary is larger than this; the variants here are the
/// ones this build implements end to end. Each one is defined, applied,
/// and encoded in the module named after it, and appears here only
/// because it is listed in `for_each_action!`.
/// Each variant is defined, applied, and encoded in the module named
/// after it, and appears here only because it is listed in
/// `for_each_action!`.
#[derive(Debug, Clone, PartialEq, DeepSizeOf)]
pub enum Action {
$($variant($variant),)*
Expand Down
19 changes: 14 additions & 5 deletions rust/lance-table/src/transaction/action/add_fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,26 @@ impl AddFragment {
self.data_change
}

/// Nothing for a local token: the fragment does not exist in the read
/// No coordinate for a local token: the fragment does not exist in the read
/// version, so no concurrent writer can be naming it.
///
/// A committed id does write one coordinate. A reservation is meant to be
/// one writer's alone, but nothing in the format enforces that, so two
/// operations handed the same range would otherwise each add a fragment at
/// the same id and the second commit would silently win.
/// A committed id does write one. A reservation is meant to be one writer's
/// alone, but nothing in the format enforces that, so two operations handed
/// the same range would otherwise each add a fragment at the same id and
/// the second commit would silently win.
///
/// Either form records that rows arrive, which is the one thing about an
/// added fragment a concurrent
/// [`AssertUniqueKeys`](super::AssertUniqueKeys) has to know. A fragment
/// that is not a data change holds rows that were already in the dataset --
/// a compaction rewrite -- and brings in no new key.
pub(super) fn footprint(&self, footprint: &mut Footprint) {
if let Some(id) = self.id.committed() {
footprint.write(Coordinate::FragmentExistence(id));
}
if self.data_change {
footprint.insert_rows();
}
}
}

Expand Down
Loading
Loading