Skip to content

Commit 0bfaf5c

Browse files
authored
refactor(clp-s): Simplify dictionary search for variable string predicates. (#1112)
1 parent 8fc0dd7 commit 0bfaf5c

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

components/core/src/clp_s/search/QueryRunner.cpp

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "ast/Literal.hpp"
1616
#include "ast/OrExpr.hpp"
1717
#include "ast/SearchUtils.hpp"
18-
#include "clp_search/EncodedVariableInterpreter.hpp"
1918
#include "clp_search/Grep.hpp"
2019
#include "EvaluateTimestampIndex.hpp"
2120

@@ -868,7 +867,7 @@ void QueryRunner::populate_string_queries(std::shared_ptr<Expression> const& exp
868867
)
869868
);
870869
}
871-
SubQuery sub_query;
870+
872871
if (filter->get_column()->matches_type(LiteralType::VarStringT)) {
873872
std::string query_string;
874873
filter->get_operand()->as_var_string(query_string, filter->get_operation());
@@ -899,25 +898,15 @@ void QueryRunner::populate_string_queries(std::shared_ptr<Expression> const& exp
899898
for (auto const& entry : entries) {
900899
matching_vars.insert(entry->get_id());
901900
}
902-
} else if (EncodedVariableInterpreter::
903-
wildcard_search_dictionary_and_get_encoded_matches(
904-
query_string,
905-
*m_var_dict,
906-
m_ignore_case,
907-
sub_query
908-
))
909-
{
910-
for (auto const& var : sub_query.get_vars()) {
911-
if (var.is_precise_var()) {
912-
auto const* entry = var.get_var_dict_entry();
913-
if (entry != nullptr) {
914-
matching_vars.insert(entry->get_id());
915-
}
916-
} else {
917-
for (auto const* entry : var.get_possible_var_dict_entries()) {
918-
matching_vars.insert(entry->get_id());
919-
}
920-
}
901+
} else {
902+
std::unordered_set<VariableDictionaryEntry const*> matching_entries;
903+
m_var_dict->get_entries_matching_wildcard_string(
904+
query_string,
905+
m_ignore_case,
906+
matching_entries
907+
);
908+
for (auto const& entry : matching_entries) {
909+
matching_vars.emplace(entry->get_id());
921910
}
922911
}
923912
}

components/core/tests/test-clp_s-search.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ TEST_CASE("clp-s-search", "[clp-s][search]") {
220220
{R"aa(idx: 0 AND NOT $*._filename.*: "clp string")aa", {0}},
221221
{R"aa(($_filename: file OR $_file_split_number: 1 OR $_archive_creator_id > 0) AND )aa"
222222
R"aa(idx: 0 OR idx: 1)aa",
223-
{1}}
223+
{1}},
224+
{R"aa(ambiguous_varstring: "a*e")aa", {10, 11, 12}},
225+
{R"aa(ambiguous_varstring: "a\*e")aa", {12}}
224226
};
225227
auto structurize_arrays = GENERATE(true, false);
226228
auto single_file_archive = GENERATE(true, false);

components/core/tests/test_log_files/test_search.jsonl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
{"idx": 7, "arr": [{"a": 999}, {"b": 1001}]}
99
{"idx": 8, "arr": {"a": 999, "b": 1001}}
1010
{"idx": 9, "var_string": "a", "clp_string": "a b", "float": 1.1, "int": 1, "bool": true, "array": [], "object": {}}
11+
{"idx": 10, "ambiguous_varstring": "abcde"}
12+
{"idx": 11, "ambiguous_varstring": "ae"}
13+
{"idx": 12, "ambiguous_varstring": "a*e"}

0 commit comments

Comments
 (0)