-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(search): Add DD option support for FT.DROPINDEX command #5885
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
Conversation
src/server/search/search_family.cc
Outdated
| // Collect document keys (if DD is set), drop index, and delete documents in single transaction | ||
| vector<vector<string>> shard_doc_keys(delete_docs ? shard_set->size() : 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this inside the command, you can store the keys inside the transaction callback locally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
src/server/search/search_family.cc
Outdated
| if (delete_docs) { | ||
| auto* index = es->search_indices()->GetIndex(idx_name); | ||
| if (index) { | ||
| shard_doc_keys[es->shard_id()] = index->GetAllKeys(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to copy all the keys, you're gonna delete the index anyway. You can just return the DocKeyIndex by value from DropIndex() and empty it either with a helper function or by moving the ids_ map out of it directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
src/server/search/doc_index.cc
Outdated
| keys.reserve(ids_.size()); | ||
|
|
||
| for (const auto& [key, id] : ids_) { | ||
| if (!key.empty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keys shouldn't be empty inside ids_ (only inside keys_), but see previous comment on that we don't need this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small style comments
src/server/search/search_family.cc
Outdated
| // TODO: Handle optional DD param | ||
|
|
||
| // Parse optional DD (Delete Documents) parameter | ||
| bool delete_docs = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool delete_docs = args.size() > 1 && absl::EqualsIgnoreCase(args[1], "DD")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
src/server/search/search_family.cc
Outdated
| // Get const reference to document keys map (index will be destroyed after this scope) | ||
| const auto& doc_keys = index->key_index().GetDocKeysMap(); | ||
|
|
||
| if (!doc_keys.empty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the if, you can just iterate over it right away
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it's clean, simple and efficient👍🏻
Implements the
DD(Delete Documents) option forFT.DROPINDEXcommand.Fixes: #5513