Skip to content

Commit

Permalink
fix panic when running KNN on empty index
Browse files Browse the repository at this point in the history
  • Loading branch information
zh217 committed Jun 21, 2023
1 parent d779e0c commit 6c07666
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cozo-core/src/runtime/hnsw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,10 +900,14 @@ impl<'a> SessionTx<'a> {
if let Some(ep) = ep_res {
let ep = ep?;
let bottom_level = ep[0].get_int().unwrap();
let ep_idx = match ep[config.base_handle.metadata.keys.len() + 1].get_int() {
Some(x) => x as usize,
None => {
// this occurs if the index is empty
return Ok(vec![])
},
};
let ep_t_key = ep[1..config.base_handle.metadata.keys.len() + 1].to_vec();
let ep_idx = ep[config.base_handle.metadata.keys.len() + 1]
.get_int()
.unwrap() as usize;
let ep_subidx = ep[config.base_handle.metadata.keys.len() + 2]
.get_int()
.unwrap() as i32;
Expand Down

0 comments on commit 6c07666

Please sign in to comment.