Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Soft deprecation of load methods requiring metadata parameters + Fix TypedIndex constructor #112

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

stephen29xie
Copy link
Contributor

@stephen29xie stephen29xie commented Feb 21, 2025

Related Issues

Changes Made

C++

  • TypedIndex.h
    • Add deprecated annotations to TypedIndex constructors that require metadata parameters.
    • Fix one of the TypedIndex constructors. It was incorrectly calling the HierarchicalNSW constructor
      • There were no build issues prior, I don't think we had any tests or code using this constructor that loaded the old version of indexes without a metadata header
    • Add override keyword for overridden methods for readability and error checking
    • Add loadTypedIndexFromFile method, in addition to the existing loadTypedIndexFromStream method

Java

  • Index.java
    • Add deprecated annotations to load() methods that require metadata parameters.
  • StringIndex.java
    • Add deprecated annotations to load() methods that require metadata parameters.
  • regenerated the docs

Python

Testing

Checklist

  • My code follows the code style of this project.
  • I have added and/or updated appropriate documentation (if applicable).
  • All new and existing tests pass locally with these changes.
  • I have run static code analysis (if available) and resolved any issues.
  • I have considered backward compatibility (if applicable).
  • I have confirmed that this PR does not introduce any security vulnerabilities.

Additional Comments

Comment on lines +152 to +154
auto inputStream = std::make_shared<FileInputStream>(indexFilename);
algorithmImpl = std::make_unique<hnswlib::HierarchicalNSW<dist_t, data_t>>(
spaceImpl.get(), indexFilename, 0, searchOnly);
spaceImpl.get(), inputStream, 0, searchOnly);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The constructor for HierarchicalNSW is

HierarchicalNSW(Space<dist_t, data_t> *s,
                  std::shared_ptr<InputStream> inputStream,
                  size_t max_elements = 0, bool search_only = false)

@stephen29xie stephen29xie marked this pull request as ready for review February 21, 2025 22:57
@stephen29xie stephen29xie marked this pull request as draft February 21, 2025 23:03
@stephen29xie stephen29xie changed the title Fix TypedIndex constructor Fix TypedIndex constructor + Soft deprecation of load methods requiring metadata parameters Feb 25, 2025
@stephen29xie stephen29xie changed the title Fix TypedIndex constructor + Soft deprecation of load methods requiring metadata parameters Fix TypedIndex constructors + Soft deprecation of load methods requiring metadata parameters Feb 25, 2025
@stephen29xie stephen29xie changed the title Fix TypedIndex constructors + Soft deprecation of load methods requiring metadata parameters Soft deprecation of load methods requiring metadata parameters + Fix TypedIndex constructor Feb 26, 2025
@stephen29xie stephen29xie marked this pull request as ready for review February 26, 2025 18:32
@stephen29xie stephen29xie requested a review from psobot February 26, 2025 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant