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
2.27k stars 143 forks source link

Bug: `nodes_capacity_` is not set in header when saving to stream #452

Closed GoodKnight closed 3 months ago

GoodKnight commented 3 months ago

Describe the bug

Ran into an issue when attempting to load from disk that the capacity (nodes_capacity_) is incorrect and is instead set to the number of slots already storing non-null nodes (nodes_count_). Digging into it further it seems that in save_to_stream(...) the header (index_serialized_header_t) created does not contain nodes_capacity_.

Wasn't too sure if this was intentional and thus wanted to raise an issue.

Steps to reproduce

  1. Instantiate with a set number for capacity via reserve()
  2. Save via save_to_stream
  3. Load via load_from_stream
  4. Check capacity and notice that it is different than the normal reserve() value

Expected behavior

Expecting the capacity after load to be the same value as when saved.

USearch version

v2.12.0

Operating System

macOS 14.5

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

ashvardanian commented 3 months ago

Good catch, looking into it!