Skip to content

Commit

Permalink
one more test just in cade
Browse files Browse the repository at this point in the history
  • Loading branch information
hermeGarcia committed Nov 28, 2023
1 parent c748e6e commit d45e5e8
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions nucliadb_vectors/src/data_types/key_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,43 @@ mod tests {
retrieval_checks(&expected, &buf);
}

#[test]
fn merge_some_deleted_different_length() {
let v0: Vec<_> = [0u32, 1, 2].iter().map(|x| x.to_be_bytes()).collect();
let v1: Vec<_> = [3u32, 4, 5, 11].iter().map(|x| x.to_be_bytes()).collect();
let v2: Vec<_> = [6u32, 7, 8, 9, 10]
.iter()
.map(|x| x.to_be_bytes())
.collect();
let mut v0_store = vec![];
let mut v1_store = vec![];
let mut v2_store = vec![];
create_key_value(&mut v0_store, v0).unwrap();
create_key_value(&mut v1_store, v1).unwrap();
create_key_value(&mut v2_store, v2).unwrap();

let interface = (GreaterThan(ONE), TElem);
let mut file = tempfile::tempfile().unwrap();

let elems = vec![
// zero and 1 will be removed
(interface, v0_store.as_slice()),
// no element is removed
(interface, v1_store.as_slice()),
// no element is removed
(interface, v2_store.as_slice()),
];
merge::<(GreaterThan, TElem), std::fs::File>(&mut file, elems.as_slice()).unwrap();
let expected: Vec<u32> = vec![2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
let merge_store = unsafe { memmap2::Mmap::map(&file).unwrap() };
let number_of_elements = elements_in_total(&merge_store);
let values: Vec<u32> = (0..number_of_elements)
.map(|i| get_value(TElem, &merge_store, i))
.map(|s| u32::from_be_bytes(s.try_into().unwrap()))
.collect();
assert_eq!(values, expected);
}

#[test]
fn merge_some_elements_deleted() {
let v0: Vec<_> = [0u32, 1, 2].iter().map(|x| x.to_be_bytes()).collect();
Expand Down

1 comment on commit d45e5e8

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: d45e5e8 Previous: 6a3e3cd Ratio
nucliadb/search/tests/unit/search/test_fetch.py::test_highligh_error 13004.336598499169 iter/sec (stddev: 2.1271999698086235e-7) 6621.622688322887 iter/sec (stddev: 0.000003234538187648496) 0.51

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.