You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[test]
pub fn test_duplidate_ids() {
let (b, r) = calculate_minhash_params(0.5, 200);
let min_hash = MinHasher64V1::new(b * r);
let mut lsh_index = MinHashIndex::new(b, r, 0.5);
lsh_index.insert(1, min_hash.create_signature(S1.split_whitespace()));
lsh_index.insert(1, min_hash.create_signature(S4.split_whitespace()));
lsh_index.insert(6, min_hash.create_signature(S6.split_whitespace()));
println!("{}", lsh_index);
assert_eq!(lsh_index.size(), 2);
lsh_index.remove(&1);
let ret = lsh_index.query(&min_hash.create_signature(S1.split_whitespace()));
println!("{:?}", ret);
}
no entry found for key
thread 'minhash::minhash_index::tests::test_duplidate_ids' panicked at 'no entry found for key', gaoya/src/minhash/minhash_index.rs:552:30
stack backtrace:
0: rust_begin_unwind
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/panicking.rs:64:14
2: core::panicking::panic_display
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/panicking.rs:147:5
3: core::panicking::panic_str
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/panicking.rs:131:5
4: core::option::expect_failed
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/option.rs:1924:5
5: core::option::Option<T>::expect
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/option.rs:786:21
6: <std::collections::hash::map::HashMap<K,V,S> as core::ops::index::Index<&Q>>::index
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/collections/hash/map.rs:1340:23
7: gaoya::minhash::minhash_index::MinHashIndex<T,Id,C>::query::{{closure}}
at ./src/minhash/minhash_index.rs:552:30
8: hashbrown::set::HashSet<T,S,A>::retain::{{closure}}
at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.3/src/set.rs:325:32
9: hashbrown::map::HashMap<K,V,S,A>::retain
at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.3/src/map.rs:834:21
10: hashbrown::set::HashSet<T,S,A>::retain
at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.3/src/set.rs:325:9
11: std::collections::hash::set::HashSet<T,S>::retain
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/collections/hash/set.rs:333:9
12: gaoya::minhash::minhash_index::MinHashIndex<T,Id,C>::query
at ./src/minhash/minhash_index.rs:551:9
13: gaoya::minhash::minhash_index::tests::test_duplidate_ids
at ./src/minhash/minhash_index.rs:1208:19
14: gaoya::minhash::minhash_index::tests::test_duplidate_ids::{{closure}}
at ./src/minhash/minhash_index.rs:1197:33
15: core::ops::function::FnOnce::call_once
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/ops/function.rs:250:5
16: core::ops::function::FnOnce::call_once
at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.```
The current logic does not check in the `insert` method whether ID is already present in the index. The assumption is that IDs are unique and it is up to the caller to handle duplicates.
The text was updated successfully, but these errors were encountered:
serega
changed the title
Duplicate ids cause panic
Duplicate ids causes panic
May 14, 2023
The code results in panic.
The text was updated successfully, but these errors were encountered: