Skip to content

Commit 8e44700

Browse files
authored
[core] Add primary-key vector bucket search kernel (#516)
1 parent 3484fb0 commit 8e44700

10 files changed

Lines changed: 1686 additions & 2 deletions

File tree

crates/paimon/src/deletion_vector/core.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ impl DeletionVector {
5959
self.bitmap.len()
6060
}
6161

62+
/// Returns true if `position` is deleted. Positions above `u32::MAX` cannot be
63+
/// present in a roaring32 bitmap and are therefore reported as not deleted.
64+
/// Mirrors Java `BitmapDeletionVector#isDeleted` / the searchers' `LongPredicate`.
65+
pub fn is_deleted(&self, position: u64) -> bool {
66+
u32::try_from(position)
67+
.ok()
68+
.is_some_and(|p| self.bitmap.contains(p))
69+
}
70+
6271
/// Returns an iterator over deleted positions that supports [DeletionVectorIterator::advance_to].
6372
/// Required for efficient row selection building when skipping row groups (avoid re-scanning
6473
/// deletes in skipped ranges).
@@ -249,4 +258,15 @@ mod tests {
249258
let expected_bitmap = RoaringBitmap::from_iter([1u32, 2u32]);
250259
assert_eq!(dv.bitmap(), &expected_bitmap, "bitmap should be [1, 2]");
251260
}
261+
262+
#[test]
263+
fn test_is_deleted_reports_membership_and_guards_u32_overflow() {
264+
let mut bitmap = RoaringBitmap::new();
265+
bitmap.insert(2);
266+
let dv = DeletionVector::from_bitmap(bitmap);
267+
assert!(dv.is_deleted(2), "position 2 was deleted");
268+
assert!(!dv.is_deleted(0), "position 0 was not deleted");
269+
// Positions above u32::MAX cannot exist in a roaring32 bitmap -> not deleted.
270+
assert!(!dv.is_deleted(u64::from(u32::MAX) + 1));
271+
}
252272
}

crates/paimon/src/spec/pk_vector_source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ impl PkVectorSourceMeta {
157157
}
158158

159159
/// Minimal big-endian reader mirroring the Java `DataInput` primitives the
160-
/// `_SOURCE_META` frame uses. Module-private by design (see the PR1 spec: no
161-
/// shared `common/` abstraction until a second consumer exists).
160+
/// `_SOURCE_META` frame uses. Module-private by design: no shared `common/`
161+
/// abstraction until a second consumer exists.
162162
struct DataInputCursor<'a> {
163163
bytes: &'a [u8],
164164
position: usize,

crates/paimon/src/vindex/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
pub mod reader;
1919

20+
pub mod pkvector;
21+
2022
use crate::spec::{DataField, DataType};
2123
use paimon_vindex_core::index::VectorIndexConfig;
2224
use std::collections::HashMap;

0 commit comments

Comments
 (0)