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

Use DataSetPtr in all knowhere interfaces #666

Closed
cydrain opened this issue Jun 26, 2024 · 2 comments
Closed

Use DataSetPtr in all knowhere interfaces #666

cydrain opened this issue Jun 26, 2024 · 2 comments
Assignees
Labels

Comments

@cydrain
Copy link
Collaborator

cydrain commented Jun 26, 2024

To support multi data type, PR #210 introduced IndexNodeDataMockWrapper::xxx, in which DataSet reference is converted into shared_ptr.
This operation has panic risk, because if the DataSet is not created by make_shared, but created in stack,
calling shared_from_this will cause bad_weakptr.
To avoid this kind of risk, need change all DataSet& to DataSetPtr in all knowhere APIs.

For details please check #210 and #659

@alexanderguzhva
Copy link
Collaborator

I would personally stick with std::shared_ptr<DataSet> instead of creating an alias 'DataSetPtr'. Just because it is confusing (DataSetPtr kinda implies DataSet*)
Also, const std::shared_ptr<DataSet> should be passed by ref, because passing shared_ptr by value adds an overhead of atomic increments and decrements of shared_ptr ref counters.

So, not

    virtual expected<DataSetPtr>
    Search(const DataSetPtr dataset, const Config& cfg, const BitsetView& bitset) const = 0;

but

    virtual expected<std::shared_ptr<DataSet>>
    Search(const std::shared_ptr<DataSet>& dataset, const Config& cfg, const BitsetView& bitset) const = 0;

Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Rotten issues close after 30d of inactivity. Reopen the issue with /reopen.

@github-actions github-actions bot added the stale label Jul 27, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants