MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / search_with_bitmap_bytes

Method search_with_bitmap_bytes

nodedb-vector/src/collection/search.rs:357–401  ·  view source on GitHub ↗

Search with a pre-filter bitmap (byte-array format).

(
        &self,
        query: &[f32],
        top_k: usize,
        ef: usize,
        bitmap: &[u8],
    )

Source from the content-addressed store, hash-verified

355
356 /// Search with a pre-filter bitmap (byte-array format).
357 pub fn search_with_bitmap_bytes(
358 &self,
359 query: &[f32],
360 top_k: usize,
361 ef: usize,
362 bitmap: &[u8],
363 ) -> Vec<SearchResult> {
364 let mut all: Vec<SearchResult> = Vec::new();
365
366 let growing_results =
367 self.growing
368 .search_filtered_offset(query, top_k, bitmap, self.growing_base_id);
369 for mut r in growing_results {
370 r.id += self.growing_base_id;
371 all.push(r);
372 }
373
374 for seg in &self.sealed {
375 let results =
376 seg.index
377 .search_with_bitmap_bytes_offset(query, top_k, ef, bitmap, seg.base_id);
378 for mut r in results {
379 r.id += seg.base_id;
380 all.push(r);
381 }
382 }
383
384 for seg in &self.building {
385 let results = seg
386 .flat
387 .search_filtered_offset(query, top_k, bitmap, seg.base_id);
388 for mut r in results {
389 r.id += seg.base_id;
390 all.push(r);
391 }
392 }
393
394 all.sort_by(|a, b| {
395 a.distance
396 .partial_cmp(&b.distance)
397 .unwrap_or(std::cmp::Ordering::Equal)
398 });
399 all.truncate(top_k);
400 all
401 }
402
403 /// Search with a structured payload predicate.
404 ///

Callers 1

Calls 5

pushMethod · 0.45
partial_cmpMethod · 0.45
truncateMethod · 0.45

Tested by

no test coverage detected