spotify / voyager

🛰️ An approximate nearest-neighbor search library for Python and Java with a focus on ease of use, simplicity, and deployability.
https://spotify.github.io/voyager/
Apache License 2.0
1.26k stars 51 forks source link

Fix for concurrency bug #70

Closed miclegr closed 1 month ago

miclegr commented 1 month ago

Description

When adding a point to an index without providing an id, we rely on TypedIndex::currentLabel to get one. But we are not doing it in a threadsafe way. This PR fixes that, solves #65

Changes Made

C++

TypedIndex::currentLabel is now std::atomic and it's post-incremented atomically to get a new id when needed

Testing

Checklist

Additional Comments

miclegr commented 1 month ago

C++ linting failing due to this