Repository navigation
fix(core): Update DictionaryReader::get_entry_matching_value to handle case-insensitive searches (fixes #648).
#690
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
Changes from 9 commits
327c317
b4fdba2
8a515f8
aaac6a0
aecae49
8824757
df673c1
bc77a12
1f7f35a
0127c4f
e2367ce
ffd536f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| #include <cassert> | ||||||||||||||||||||||||||||||||||||||
| #include <cmath> | ||||||||||||||||||||||||||||||||||||||
| #include <unordered_set> | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| #include <string_utils/string_utils.hpp> | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
@@ -386,15 +387,29 @@ bool EncodedVariableInterpreter::encode_and_search_dictionary( | |||||||||||||||||||||||||||||||||||||
| LogTypeDictionaryEntry::add_float_var(logtype); | ||||||||||||||||||||||||||||||||||||||
| sub_query.add_non_dict_var(encoded_var); | ||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||
| auto entry = var_dict.get_entry_matching_value(var_str, ignore_case); | ||||||||||||||||||||||||||||||||||||||
| if (nullptr == entry) { | ||||||||||||||||||||||||||||||||||||||
| auto const entries = var_dict.get_entry_matching_value(var_str, ignore_case); | ||||||||||||||||||||||||||||||||||||||
| if (entries.empty()) { | ||||||||||||||||||||||||||||||||||||||
| // Not in dictionary | ||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| encoded_var = encode_var_dict_id(entry->get_id()); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| LogTypeDictionaryEntry::add_dict_var(logtype); | ||||||||||||||||||||||||||||||||||||||
| sub_query.add_dict_var(encoded_var, entry); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if (entries.size() == 1) { | ||||||||||||||||||||||||||||||||||||||
| auto const* entry = entries.at(0); | ||||||||||||||||||||||||||||||||||||||
| sub_query.add_dict_var(encode_var_dict_id(entry->get_id()), entry); | ||||||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| std::unordered_set<clp::VariableDictionaryEntry const*> const entries_set{ | ||||||||||||||||||||||||||||||||||||||
| entries.cbegin(), | ||||||||||||||||||||||||||||||||||||||
| entries.cend() | ||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||
| std::unordered_set<encoded_variable_t> encoded_vars; | ||||||||||||||||||||||||||||||||||||||
|
aestriplex marked this conversation as resolved.
Resolved
aestriplex marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||||||||||||||||||
| for (auto const* entry : entries) { | ||||||||||||||||||||||||||||||||||||||
| encoded_vars.emplace(encode_var_dict_id(entry->get_id())); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+404
to
+412
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Some coding style related comments. If we choose to go with the design as discussed in another comment we might not need to apply this change in the end, but I still leave it here just to get u on board to our C++ coding guidelines for future development :D
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you @LinZhihao-723 for this feedback. I implemented your suggestions both in clp and in clp_s namespaces |
||||||||||||||||||||||||||||||||||||||
| sub_query.add_imprecise_dict_var(encoded_vars, entries_set); | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+404
to
+413
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you think about adding a new signature for sub_query.add_imprecise_dict_var that takes in a vector of entires as argument?. So we can replace this piece of code witha a single call to the new signature @LinZhihao-723 Note this won't solve the code duplication problem, because CLP-S duplicates the entire Query class
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of returning a vector, can we directly return an unordered set? |
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gibber9809 The change in CLP-S looks reasonable to me, but can you take another look? |
Uh oh!
There was an error while loading. Please reload this page.