Skip to content
Merged
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
20 changes: 20 additions & 0 deletions crates/paimon/src/deletion_vector/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ impl DeletionVector {
self.bitmap.len()
}

/// Returns true if `position` is deleted. Positions above `u32::MAX` cannot be
/// present in a roaring32 bitmap and are therefore reported as not deleted.
/// Mirrors Java `BitmapDeletionVector#isDeleted` / the searchers' `LongPredicate`.
pub fn is_deleted(&self, position: u64) -> bool {
u32::try_from(position)
.ok()
.is_some_and(|p| self.bitmap.contains(p))
}

/// Returns an iterator over deleted positions that supports [DeletionVectorIterator::advance_to].
/// Required for efficient row selection building when skipping row groups (avoid re-scanning
/// deletes in skipped ranges).
Expand Down Expand Up @@ -249,4 +258,15 @@ mod tests {
let expected_bitmap = RoaringBitmap::from_iter([1u32, 2u32]);
assert_eq!(dv.bitmap(), &expected_bitmap, "bitmap should be [1, 2]");
}

#[test]
fn test_is_deleted_reports_membership_and_guards_u32_overflow() {
let mut bitmap = RoaringBitmap::new();
bitmap.insert(2);
let dv = DeletionVector::from_bitmap(bitmap);
assert!(dv.is_deleted(2), "position 2 was deleted");
assert!(!dv.is_deleted(0), "position 0 was not deleted");
// Positions above u32::MAX cannot exist in a roaring32 bitmap -> not deleted.
assert!(!dv.is_deleted(u64::from(u32::MAX) + 1));
}
}
4 changes: 2 additions & 2 deletions crates/paimon/src/spec/pk_vector_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ impl PkVectorSourceMeta {
}

/// Minimal big-endian reader mirroring the Java `DataInput` primitives the
/// `_SOURCE_META` frame uses. Module-private by design (see the PR1 spec: no
/// shared `common/` abstraction until a second consumer exists).
/// `_SOURCE_META` frame uses. Module-private by design: no shared `common/`
/// abstraction until a second consumer exists.
struct DataInputCursor<'a> {
bytes: &'a [u8],
position: usize,
Expand Down
2 changes: 2 additions & 0 deletions crates/paimon/src/vindex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

pub mod reader;

pub mod pkvector;

use crate::spec::{DataField, DataType};
use paimon_vindex_core::index::VectorIndexConfig;
use std::collections::HashMap;
Expand Down
Loading
Loading