Skip to content

Commit

Permalink
feat: move-stable row ids in compaction (#2544)
Browse files Browse the repository at this point in the history
Part of #2307.

Also addresses #2397
  • Loading branch information
wjones127 authored Aug 7, 2024
1 parent 293758e commit 27fbd4e
Show file tree
Hide file tree
Showing 5 changed files with 636 additions and 368 deletions.
23 changes: 22 additions & 1 deletion rust/lance-table/src/rowids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl RowIdSequence {
self.0.extend(other.0);
}

/// Mark a set of row ids as deleted. Their value will be replaced with tombstones.
/// Remove a set of row ids from the sequence.
pub fn delete(&mut self, row_ids: impl IntoIterator<Item = u64>) {
// Order the row ids by position in which they appear in the sequence.
let (row_ids, offsets) = self.find_ids(row_ids);
Expand All @@ -152,6 +152,27 @@ impl RowIdSequence {
self.0.extend_from_slice(remaining_segments);
}

/// Delete row ids by position.
pub fn mask(&mut self, positions: impl IntoIterator<Item = usize>) -> Result<()> {
let row_ids = positions
.into_iter()
.map(|pos| {
self.get(pos).ok_or_else(|| {
Error::invalid_input(
format!(
"position out of bounds: {} on sequence of length {}",
pos,
self.len()
),
location!(),
)
})
})
.collect::<Result<Vec<_>>>()?;
self.delete(row_ids);
Ok(())
}

/// Find the row ids in the sequence.
///
/// Returns the row ids sorted by their appearance in the sequence.
Expand Down
2 changes: 0 additions & 2 deletions rust/lance-table/src/rowids/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,6 @@ impl U64Segment {
})
};
let stats = Self::compute_stats(make_new_iter());

// Then just use Self::From_stats_and_sequence
Self::from_stats_and_sequence(stats, make_new_iter())
}
}
Expand Down
Loading

0 comments on commit 27fbd4e

Please sign in to comment.