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

Redesign FT.SEARCH command line parsing in anticipation of merging with future FT.AGGREGATE code. #29

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

Conversation

allenss-amazon
Copy link
Member

Previously, the command line was parsed up to the query string. The parse of the query string had the side effect of identifying all $param substitution variables. This list was then used to generate a custom key/value parser which was then combined with the other processing clauses to finish parsing of the command line.

Now, the parsing of the query string is performed after the parsing of the entire command line. The major change here is that instead of creating a custom key/value parser that only recognized the $param substitution variables a generic hash-map of the substitution variables is generated in the first pass. During the subsequent parsing of the query string, the various places where a $param substitution is allowed is done by looking up the value in the generated hash map.

At the end of the parsing, (Verify), the hash map is walked to ensure that every $param was used at least once.

The new code will also reject an attempt to define the same $param twice. The old code would silently accept this and use the last value.

Copy link
Collaborator

@yairgott yairgott left a comment

Choose a reason for hiding this comment

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

Looks overall good to me. Thanks for driving this!

I left a couple of comments inline.

@@ -5,7 +5,7 @@
"clangd.path": "/usr/bin/clangd",
"C_Cpp.codeAnalysis.runAutomatically": true,
"editor.formatOnSave": true,
"C_Cpp.intelliSenseEngine": "disabled",
"C_Cpp.intelliSenseEngine": "default",
Copy link
Collaborator

Choose a reason for hiding this comment

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

would this enable intelliSenseEngine checks? what is the benefit of setting it to "default" and would it conflict with clang-tidy?

Copy link
Member Author

Choose a reason for hiding this comment

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

oops. not sure what happened there. I didn't check that.

.vscode/settings.json Outdated Show resolved Hide resolved
query::VectorSearchParameters &parameters, absl::string_view source) {
if (source.empty() || source[0] != '$') {
return source;
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit- here and in other places, no need to use else when the if section alway returns. It would avoid the need to indent

itr.Next();
absl::string_view key = vmsdk::ToStringView(key_str);
absl::string_view value = vmsdk::ToStringView(value_str);
if (parameters.parse_vars.params.find(key) !=
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to call parameters.parse_vars.params.insert(key, std::make_pair(0, value)) and if the key already exists, the success would be false.

src/commands/ft_search_parser.cc Show resolved Hide resolved
@@ -19,4 +19,8 @@
"bazel.buildifierFixOnFormat": false,
"clangd.inactiveRegions.useBackgroundHighlight": true,
"clangd.enableCodeCompletion": true,
"files.associations": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this required?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, and I diffed my PR against main and it showed no changes in this file. :( :( :(

src/commands/ft_search_parser.cc Show resolved Hide resolved
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.

2 participants