unum-cloud / usearch

Fast Open-Source Search & Clustering engine × for Vectors & 🔜 Strings × in C++, C, Python, JavaScript, Rust, Java, Objective-C, Swift, C#, GoLang, and Wolfram 🔍
https://unum-cloud.github.io/usearch/
Apache License 2.0
1.92k stars 109 forks source link

Bug: Rust test_add_remove_vector fails on main-dev #432

Open MarkReedZ opened 1 month ago

MarkReedZ commented 1 month ago

Describe the bug

running 8 tests
test tests::integration ... --------------------------------------------------
before add, memory_usage: 2048 cap: 64 
after add, memory_usage: 20973504 cap: 64 
Matches { keys: [43, 42], distances: [1.0, 1.0] }
Matches { keys: [43, 42], distances: [1.0, 1.0] }
--------------------------------------------------
ok
test tests::print_specs ... --------------------------------------------------
OS: linux
Rust version: unknown
f64 hardware acceleration: serial
f32 hardware acceleration: serial
f16 hardware acceleration: serial
i8 hardware acceleration: serial
b1 hardware acceleration: serial
--------------------------------------------------
ok
test tests::test_add_get_vector ... ok
test tests::test_add_remove_vector ... thread 'tests::test_add_remove_vector' panicked at rust/lib.rs:1408:9:
assertion `left == right` failed
  left: 64
 right: 10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
FAILED
test tests::test_binary_vectors_and_hamming_distance ... ok
test tests::test_change_distance_function ... ok
test tests::test_search_with_stateful_filter ... ok
test tests::test_search_with_stateless_filter ... ok

The code is:

        let index = Index::new(&options).unwrap();
        assert!(index.reserve(10).is_ok());
        assert_eq!(index.capacity(), 10); 

Steps to reproduce

cargo test -p usearch -- --nocapture --test-threads=1

Expected behavior

Tests should pass

USearch version

main-dev

Operating System

Ubuntu 22 and 24

Hardware architecture

x86

Which interface are you using?

Other bindings

Contact Details

No response

Are you open to being tagged as a contributor?

Is there an existing issue for this?

Code of Conduct

MarkReedZ commented 1 month ago

The C test allow capacity to be greater than that reserved.

   expect(usearch_capacity(index, &error) >= collection_size, error);

This was changed in https://github.com/unum-cloud/usearch/commit/aa59418e

I'll make a PR to change the rust test as well. Or should we change the tests to expect the correct value and try various reserve values?

ashvardanian commented 1 month ago

The new C behavior is correct and should propagate to Rust 🤗