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
790 changes: 3 additions & 787 deletions diskann-providers/src/index/diskann_async.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion diskann/src/graph/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use crate::{
};

mod knn_search;
mod multihop_search;
pub(crate) mod multihop_search;
mod range_search;

pub mod record;
Expand Down
54 changes: 54 additions & 0 deletions diskann/src/graph/search/multihop_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,57 @@ where

Ok(make_stats(scratch))
}

#[cfg(test)]
mod tests {
use super::*;

/// A simple label evaluator that matches only even IDs.
#[derive(Debug)]
struct EvenOnly;

impl QueryLabelProvider<u32> for EvenOnly {
fn is_match(&self, id: u32) -> bool {
id.is_multiple_of(2)
}
}

#[test]
fn predicate_eval_requires_not_visited_and_matching() {
let mut visited = HashSet::new();
visited.insert(2u32);
let label = EvenOnly;
let pred = NotInMutWithLabelCheck::new(&mut visited, &label);

// Not visited + matches label → true
assert!(pred.eval(&4));

// Already visited + matches label → false
assert!(!pred.eval(&2));

// Not visited + doesn't match label → false
assert!(!pred.eval(&3));

// Already visited + doesn't match → false
visited.insert(3);
let pred = NotInMutWithLabelCheck::new(&mut visited, &label);
assert!(!pred.eval(&3));
}

#[test]
fn predicate_eval_mut_inserts_only_matching() {
let mut visited = HashSet::new();
let label = EvenOnly;
let mut pred = NotInMutWithLabelCheck::new(&mut visited, &label);

// Matching + not visited → inserts and returns true
assert!(pred.eval_mut(&4));
// Second call → already visited, returns false
assert!(!pred.eval_mut(&4));

// Non-matching → not inserted, returns false
assert!(!pred.eval_mut(&3));
// Confirm 3 was NOT added to visited set
assert!(!pred.visited_set.contains(&3));
}
}
1 change: 1 addition & 0 deletions diskann/src/graph/test/cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod grid_search;
mod helpers;
mod index;
mod inplace_delete;
mod multihop;
mod paged_search;
mod range_search;

Expand Down
Loading
Loading