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

Add a common subclass for IndexNode::iterator #501

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

zhengbuqian
Copy link
Collaborator

@zhengbuqian zhengbuqian commented Apr 16, 2024

so that different indexes only need to implement next_batch. Any index that gradually adds new points as the iterator::Next() is called should implement their iterator by inheriting this new class.

Updated the impl for supported ivf and hnsw index.

issue: #500
/kind: enhancement

Copy link

codecov bot commented Apr 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.33%. Comparing base (3c46f4c) to head (7e667ff).
Report is 11 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           main     #501       +/-   ##
=========================================
+ Coverage      0   72.33%   +72.33%     
=========================================
  Files         0       63       +63     
  Lines         0     4319     +4319     
=========================================
+ Hits          0     3124     +3124     
- Misses        0     1195     +1195     

see 63 files with indirect coverage changes

throw std::runtime_error("raw_distance not implemented");
}

const bool refine_ratio_;
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be float

const bool refine_ratio_;
const bool refine_;

std::priority_queue<std::pair<float, int64_t>, std::vector<std::pair<float, int64_t>>, PairComparator> res_;
Copy link
Collaborator

Choose a reason for hiding this comment

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

there are too many std::pair<float, int64_t> structs in the code. I'd create a simple 2-field structure with clear field names, because the current code uses .first or .second and who knows that they mean

@@ -247,14 +247,24 @@ class IvfIndexNode : public IndexNode {
Status
TrainInternal(const DataSet& dataset, const Config& cfg);

static bool
IsQuantized() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can make this function constexpr
Also, what about SCANN?

@zhengbuqian
Copy link
Collaborator Author

/hold

this branch is currently based on #505, need to rebase after #505 is merged


std::pair<int64_t, float>
Next() override {
if (!initialized_) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why can't this initialization action be placed inside the constructor? It seems this way, you won't need to write data in the HasNext interface, which looks more like a read-only interface.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

initialization must be done after constructor of subclass has finished, which we don't know when that'll happen in this class

@zhengbuqian
Copy link
Collaborator Author

/unhold

…xes only need to implement next_batch, add impl for hnsw and ivf

Signed-off-by: Buqian Zheng <zhengbuqian@gmail.com>
Copy link
Collaborator

@foxspy foxspy left a comment

Choose a reason for hiding this comment

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

/lgtm

@sre-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: foxspy, zhengbuqian

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sre-ci-robot sre-ci-robot merged commit 0fcecb8 into zilliztech:main Apr 19, 2024
11 checks passed
@zhengbuqian zhengbuqian deleted the iterator-new-interface branch April 19, 2024 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants