Changelog
Source:NEWS.md
RcppHNSW 0.7.0.9001
Bug fixes and minor improvements
- Numeric controls, logical options, matrix shapes, item identifiers, paths, and coordinates are now validated before conversion to native types. Search
kmust be positive and cannot exceed the active (not deleted) item count. Coordinates must be finite and representable as single-precision floats, and cosine inputs must have a positive finite norm after conversion. - Parallel construction and search no longer write unsynchronized shared state. Two construction races in the bundled hnswlib code are repaired, and an index now fails closed if an exception escapes after insertion has begun.
- Raw index loading now rejects incompatible dimensions and malformed offset layouts. Raw save open, write, flush, and close failures are reported to R. The raw format remains an operational hnswlib checkpoint rather than a stable cross-version or cross-platform archive.
- The existing
grain_sizesetting is now passed to all threaded index add and search operations, matching the documented behavior. - Updated hnswlib to version 0.9.0. This was a minor upstream bug-fix release; RcppHNSW also carries a documented patch series for package integration and the safety fixes above.
RcppHNSW 0.7.0
CRAN release: 2026-05-26
New features
- New class:
HnswEuclidean. This uses Euclidean distances internally and will be returned fromhnsw_buildwhendistance = "euclidean"is specified. This fixes an issue where if you created an index withhnsw_buildanddistance = "euclidean"(the default), then after saving, you would be unable to reload the index and have it find Euclidean distances. You would have to create it as anHsnwL2object and take the square root of the distances yourself (https://github.com/jlmelville/rcpphnsw/issues/21). - The
Hnswconstructors and thehnsw_buildandhnsw_knnfunctions now expose arandom_seedparameter that you can use to set the random seed used in constructing the HNSW index. If not provided, the the hnswlib default of100is used (and should preserve previous behavior). Based on a request by Maciej Beręsewicz (https://github.com/jlmelville/rcpphnsw/issues/23).
RcppHNSW 0.5.0
CRAN release: 2023-09-19
New features
- Updated hnswlib to version 0.7.0. Note that I made some very minor changes to the code to silence some compiler warnings. These changes have been submitted up-stream to the hnswlib project.
- For high-dimensional data, there can be a noticeable CPU overhead in copying data out of the non-contiguous memory regions when row-wise data is used. If you wish to provide data where each column of the input matrix contains an item to be indexed/search then see the following additions to the API:
- For the class-based API:
addItemsCol,getAllNNsColandgetAllNNsListColare the column-based equivalents ofaddItems,getAllNNsandgetAllNNsList, respectively. Note that the returned nearest neighbor data fromgetAllNNsColandgetAllNNsListColare also stored by column, i.e. the matrices have dimensionsk x nwherekis the number of neighbors, andnthe number of items in the data being searched. - For the function-based API, a new parameter
byrowhas been added tohnsw_knn,hnsw_buildandhnsw_search. By default this is set toTRUEand indicates that the items in the input matrix are found in each row. To pass column-stored items, setbyrow = FALSE. Any matrices returned byhnsw_searchandhnsw_knnwill now follow the convention provided by the value ofbyrow: i.e. ifbyrow = FALSE, the matrices contain nearest neighbor information in each column.
- For the class-based API:
- new method:
getItems, which returns a matrix of the data vectors in the index with the specified integer identifiers. From a feature request made by d4tum (https://github.com/jlmelville/rcpphnsw/issues/18).
RcppHNSW 0.4.1
CRAN release: 2022-07-18
Bug fixes and minor improvements
- Rolled back to hnswlib v0.4.0 due to valgrind problems in v0.6.2
RcppHNSW 0.3.0
CRAN release: 2020-09-06
New features
- Multi-threading support is now available. Use the
setNumThreadsmethod if using the object-based API, and then_threadsparameter in thehnsw_*function API. For finer control, asetGrainSizeandgrain_sizeoption is also available in the object and function interface respectively. Thank you to Dmitriy Selivanov for a lot of the work on this. - Updated hnswlib to version 0.4.0.
Bug fixes and minor improvements
- Setting
verbose = TRUEnow has incurs substantially less computational overhead associated with calculating the progress bar. Thank you to Samuel Granjeaud for spotting the problem and coming up with various solutions. - New parameter:
progress. By default this is set to"bar"and will show the progress bar whenverbose = TRUE. If you want a more terse output, setprogress = NULL.progress = NULLwill eventually be the default setting: for now,verbose = TRUEwill get you the progress bar by default for backwards compatibility. - No progress bar will be shown if you have less than 50 items to process.
RcppHNSW 0.2.0
CRAN release: 2019-09-20
New features
- Updated hnswlib to https://github.com/nmslib/hnswlib/commit/c5c38f0 (20 September 2019).
- A new method,
markDeleted, that will remove an object from being retrieved from the index. - A new method,
resizeIndex, that allows the index to be increased without having to save and reload the index. - A new method,
sizeis available for the index objects and reports the number of items added to the index.
Bug fixes and minor improvements
-
hnsw_searchwouldstopif the number of rows in the input matrix was smaller thank. This check has been removed. Note that the correct behavior is to ensure thatkis smaller than or equal toindex$size()whereindexis the index you are searching. Because thesize()method is new to this version, to preserve compatibility with old indexes, this check hasn’t been added tohnsw_search. If this matters to you, manually compareindex$size()withkbefore runninghnsw_search. An error will be thrown ifkneighbors can’t be found in the index. Thank you to Yuxing Liao for spotting this and the pull request to remove the check.