Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
f8d06b2
Add dynamic programming to CLP.
SharafMohamed Sep 17, 2025
add11a2
Format.
SharafMohamed Sep 19, 2025
c82dbab
Merge branch 'main' into dfa-search-using-ls-port
SharafMohamed Sep 22, 2025
70f357b
Add unit-tests.
SharafMohamed Sep 26, 2025
9d3e152
Format.
SharafMohamed Sep 26, 2025
b587085
Add missing header; Flip cast for comparison to SymbolID over unit32_t.
SharafMohamed Sep 26, 2025
9d5dd94
Fix typos.
SharafMohamed Sep 26, 2025
c5bd43b
Remove magic number.
SharafMohamed Sep 26, 2025
d7cfb0d
Add missing header; Fix typo; Fix if statement.
SharafMohamed Sep 26, 2025
27ebc0f
Remove thread-unsafe statics.
SharafMohamed Sep 26, 2025
7a2f74e
Use uint64_t with bit shift operator.
SharafMohamed Sep 26, 2025
9848096
Switch to default initialization for all false map.
SharafMohamed Sep 26, 2025
3b4572b
Fix bug in string_utils and add to test-string_utils; Refactor unit-t…
SharafMohamed Oct 1, 2025
b633980
Format.
SharafMohamed Oct 1, 2025
62f23b0
Add flags to hide test helper in production.
SharafMohamed Oct 1, 2025
8b093a0
Cast to SymbolId instead of uint32_t.
SharafMohamed Oct 1, 2025
49dc925
Add missing include.
SharafMohamed Oct 1, 2025
7b73754
Avoid multiple get_logtype() calls; Reserve size.
SharafMohamed Oct 1, 2025
c8f9046
Remove more get_logtype() calls and make tokens be references into th…
SharafMohamed Oct 1, 2025
9eba2d5
Switch from contains to find to avoid double lookup.
SharafMohamed Oct 1, 2025
4115786
Fix typos.
SharafMohamed Oct 1, 2025
8aa356a
Reduce mask size to 16 bits; Update documentation to match.
SharafMohamed Oct 1, 2025
e5afe04
Use propery type for bit mask.
SharafMohamed Oct 1, 2025
7352fd2
Define cross-test constants in a single place; Make sure constants ar…
SharafMohamed Oct 1, 2025
80354f3
Reserve var dict size.
SharafMohamed Oct 1, 2025
1680f33
Cache logtype and use references into it.
SharafMohamed Oct 1, 2025
5bc40ff
Replace contain with find to avoid double lookup.
SharafMohamed Oct 1, 2025
decca7e
Reserve possible_logtype_ids.
SharafMohamed Oct 1, 2025
26c8e49
Use correct types for bit mask.
SharafMohamed Oct 1, 2025
0908106
Use constants in place of magic numbers.
SharafMohamed Oct 1, 2025
42d7a1c
Add paranthesis for bit operation clarity.
SharafMohamed Oct 1, 2025
fae5913
Add docstrings for unit-test helpers.
SharafMohamed Oct 1, 2025
2bdf381
Fix some unit-tests.
SharafMohamed Oct 1, 2025
764973c
Merge branch 'main' into dfa-search-using-ls-port
SharafMohamed Oct 1, 2025
8996cfb
Format.
SharafMohamed Oct 1, 2025
7608cab
Remove consecutive wildcards from interpretation tokens; Undo changes…
SharafMohamed Oct 3, 2025
a130b96
Format.
SharafMohamed Oct 3, 2025
ae93a4e
Merge branch 'main' into dfa-search-using-ls-port
SharafMohamed Oct 3, 2025
f2f01d6
Add missing headers.
SharafMohamed Oct 3, 2025
0eed0db
Improve docstring.
SharafMohamed Oct 3, 2025
e2c55a7
Use find over contains to avoid double lookup.
SharafMohamed Oct 3, 2025
1cbbefd
Fix type in test to use variable_dictionary_id_t.
SharafMohamed Oct 3, 2025
f3ab0a5
Update docstring for consistency.
SharafMohamed Oct 3, 2025
ddf3e23
Fix macos ULL error.
SharafMohamed Oct 3, 2025
d629ae9
Replace map with bool vector.
SharafMohamed Oct 3, 2025
9e3e9d9
Fix type mismatch.
SharafMohamed Oct 3, 2025
06ab6a6
Add missing header; Remove unused header.
SharafMohamed Oct 3, 2025
ad951ae
Add missing header.
SharafMohamed Oct 3, 2025
f3d27b7
Format.
SharafMohamed Oct 3, 2025
76ecb1d
Merge branch 'main' into dfa-search-using-ls-port
SharafMohamed Oct 3, 2025
9920bc9
Remove duplicate sub queries.
SharafMohamed Oct 4, 2025
e7dcc43
Format.
SharafMohamed Oct 4, 2025
ed13886
Rename to rhs.
SharafMohamed Oct 4, 2025
e0ecdd0
Refactor schema search classes and methods into new files; Do the sam…
SharafMohamed Dec 9, 2025
134c2a4
Remove comments.
SharafMohamed Dec 9, 2025
763f8be
Fix test names.
SharafMohamed Dec 9, 2025
c9d1da2
Fix guard format; Remove duplicate VarInfo.
SharafMohamed Dec 9, 2025
39c3f18
Remove using form logtype header.
SharafMohamed Dec 9, 2025
88dca33
Remove using from variable header.
SharafMohamed Dec 9, 2025
7479840
Fix comment indentation.
SharafMohamed Dec 9, 2025
c318db4
Fix formatting.
SharafMohamed Dec 9, 2025
d08ce9e
Fix naming.
SharafMohamed Dec 9, 2025
7caa3e7
Fix indentation.
SharafMohamed Dec 9, 2025
90c2a7f
Format.
SharafMohamed Dec 9, 2025
fc2891e
Remove using from header.
SharafMohamed Dec 9, 2025
7320c0f
Simplify ranges::find call.
SharafMohamed Dec 9, 2025
fd1eecd
Fix typo in docstring.
SharafMohamed Dec 9, 2025
43b5b3a
Check oob.
SharafMohamed Dec 9, 2025
754b4f0
Lint.
SharafMohamed Dec 10, 2025
1ebb3bf
Check lexer map contains symbol.
SharafMohamed Dec 10, 2025
f5e1f9a
Replace magic numbers.
SharafMohamed Dec 10, 2025
31fe021
Simplify ranges call.
SharafMohamed Dec 10, 2025
e2330cc
Remove explicit keyword; Add docstring for VarInfo.
SharafMohamed Dec 10, 2025
732b452
Flip check order.
SharafMohamed Dec 10, 2025
8fdd28d
Fix typo.
SharafMohamed Dec 10, 2025
322390c
Improve constexpr.
SharafMohamed Dec 10, 2025
b33a072
Merge branch 'main' into dfa-search-using-ls-port
SharafMohamed Dec 10, 2025
3dc36b2
Merge branch 'main' into dfa-search-using-ls-port
SharafMohamed Dec 10, 2025
eed8b0b
Improve make_var_dict.
SharafMohamed Dec 11, 2025
dff3df0
Add REQUIRE(false).
SharafMohamed Jan 11, 2026
e4f39a2
Update includes to use angled braces.
SharafMohamed Jan 11, 2026
426966c
Reverse order to have shorter branch first.
SharafMohamed Jan 11, 2026
510c176
Update cmake.
SharafMohamed Jan 11, 2026
db92c0d
Move todo to issue.
SharafMohamed Jan 11, 2026
934889a
Reword comments.
SharafMohamed Jan 11, 2026
21046b0
Remove std.
SharafMohamed Jan 11, 2026
b27b92b
Update includes.
SharafMohamed Jan 11, 2026
65e683d
Remove unused var.
SharafMohamed Jan 11, 2026
07fff20
Add missing header.
SharafMohamed Jan 11, 2026
6cc8df9
Remove unused headers.
SharafMohamed Jan 11, 2026
b6312f0
Fix headers.
SharafMohamed Jan 12, 2026
34bdf28
Group clp headers seperately.
SharafMohamed Jan 12, 2026
caf160f
Fix clp compile error by reverting to old include style for Query.hpp.
SharafMohamed Jan 14, 2026
45294c4
Fix clp, clo, clg, to use new include style.
SharafMohamed Jan 14, 2026
43b5bd1
Make const.
SharafMohamed Jan 14, 2026
3ce21e8
Replace static string.
SharafMohamed Jan 14, 2026
dc414a0
Switch to deque.
SharafMohamed Jan 14, 2026
71a4a8f
Use traceable exception.
SharafMohamed Jan 14, 2026
74e4688
Add consts.
SharafMohamed Jan 14, 2026
6b56c6c
Merge branch 'main' into dfa-search-using-ls-port
SharafMohamed Jan 14, 2026
2ddc90a
Fix build.
SharafMohamed Jan 14, 2026
dc542fe
Format.
SharafMohamed Jan 14, 2026
aee311c
Fix build errors.
SharafMohamed Jan 14, 2026
18499c2
Use braced initialization.
SharafMohamed Jan 16, 2026
12c926d
Use braced initialization, again.
SharafMohamed Jan 16, 2026
68660b5
Remove obvious comment.
SharafMohamed Jan 16, 2026
9425afc
Use braced initialization, again x2.
SharafMohamed Jan 16, 2026
fa8e353
Add full stop.
SharafMohamed Jan 16, 2026
3fde49f
Remove obvious comment, again.
SharafMohamed Jan 16, 2026
435a008
Move using into namespace.
SharafMohamed Jan 16, 2026
fc47f23
Use pre-increment over post-increment.
SharafMohamed Jan 16, 2026
b81360d
Switch tuple to struct.
SharafMohamed Jan 16, 2026
5922cb1
Move SchemaSearcherTest class into its own file.
SharafMohamed Jan 18, 2026
235fa74
Add doc string.
SharafMohamed Jan 18, 2026
06704c7
Move constexpr to method param.
SharafMohamed Jan 18, 2026
82251ab
Add class level docstring.
SharafMohamed Jan 18, 2026
66bd892
Update docstring.
SharafMohamed Jan 18, 2026
8133207
Remove unused header.
SharafMohamed Jan 18, 2026
73f1890
Make test vector empty.
SharafMohamed Jan 18, 2026
62600b9
Merge branch 'main' into dfa-search-using-ls-port
SharafMohamed Jan 19, 2026
d2f4e44
Add header.
SharafMohamed Jan 19, 2026
49aac57
Update using in test header.
SharafMohamed Jan 19, 2026
b0bea5f
Add missing namespace.
SharafMohamed Jan 19, 2026
ea477fb
Add missing namespace again.
SharafMohamed Jan 19, 2026
be6f629
Ensure mask shift doesn't exceed uint64_t size.
SharafMohamed Jan 19, 2026
9e0bf19
Fix using.
SharafMohamed Jan 19, 2026
2e517fb
Format.
SharafMohamed Jan 19, 2026
aaa69e4
Make it clear the c++ macro and cmake variable are seperate things by…
SharafMohamed Feb 5, 2026
0e6f078
Merge branch 'main' into dfa-search-using-ls-port
SharafMohamed Feb 5, 2026
afeda55
Merge branch 'main' into dfa-search-using-ls-port
SharafMohamed Feb 9, 2026
8c3950a
Allow timestamped headers; Remove delimiter checking code in load_lexer.
SharafMohamed Feb 11, 2026
c79077c
Allow for 0 capture header to be added to search lexer.
SharafMohamed Feb 11, 2026
0ca3ab2
Merge branch 'allow-headers-with-timestamp' into dfa-search-using-ls-…
SharafMohamed Feb 11, 2026
2039f72
Remove unused headers and unused declarations.
SharafMohamed Feb 11, 2026
a8eb0c1
Remove unused headers and unused declarations.
SharafMohamed Feb 11, 2026
b0b1d06
Remove unneeded move operation.
SharafMohamed Feb 11, 2026
065ebb9
Safety check for empty captures set.
SharafMohamed Feb 11, 2026
84fb5ee
Avoid temporary object.
SharafMohamed Feb 11, 2026
53e6c1b
Merge branch 'allow-headers-with-timestamp' into dfa-search-using-ls-…
SharafMohamed Feb 11, 2026
a1bcdb5
Add new unit-tests; Cleanup config schema.txt.
SharafMohamed Feb 11, 2026
27d6d12
Revert change to schema.
SharafMohamed Feb 18, 2026
176e828
Add drop_all comment.
SharafMohamed Feb 18, 2026
6d4c1b9
Merge branch 'allow-headers-with-timestamp' into dfa-search-using-ls-…
SharafMohamed Feb 18, 2026
8d4a3a2
Fix decompression bug.
SharafMohamed Feb 19, 2026
4ecd399
Rename macro.
SharafMohamed Feb 19, 2026
47705f7
Merge branch 'main' into dfa-search-using-ls-port
SharafMohamed Feb 19, 2026
861bc37
Fix unit-tests based on previous change.
SharafMohamed Feb 19, 2026
ced1c9a
Merge branch 'main' into dfa-search-using-ls-port
davidlion Feb 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions components/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ set(SOURCE_FILES_unitTest
src/clp/GrepCore.hpp
src/clp/hash_utils.cpp
src/clp/hash_utils.hpp
src/clp/SchemaSearcher.cpp
src/clp/SchemaSearcher.hpp
src/clp/ir/constants.hpp
src/clp/ir/EncodedTextAst.cpp
src/clp/ir/EncodedTextAst.hpp
Expand Down Expand Up @@ -704,6 +706,11 @@ set(SOURCE_FILES_unitTest
tests/clp_s_test_utils.cpp
tests/clp_s_test_utils.hpp
tests/LogSuppressor.hpp
tests/MockLogTypeDictionary.hpp
tests/MockVariableDictionary.hpp
tests/SchemaSearcherTest.hpp
tests/search_test_utils.cpp
tests/search_test_utils.hpp
tests/TestOutputCleaner.hpp
tests/test-BoundedReader.cpp
tests/test-BufferedReader.cpp
Expand Down Expand Up @@ -731,6 +738,7 @@ set(SOURCE_FILES_unitTest
tests/test-ParserWithUserSchema.cpp
tests/test-query_methods.cpp
tests/test-regex_utils.cpp
tests/test-SchemaSearcher.cpp
tests/test-Segment.cpp
tests/test-SQLiteDB.cpp
tests/test-Stopwatch.cpp
Expand Down Expand Up @@ -790,4 +798,7 @@ if(CLP_ENABLE_TESTS)
target_compile_features(unitTest
PRIVATE cxx_std_20
)
target_compile_definitions(unitTest
PRIVATE CLP_ENABLE_TESTS
)
Comment thread
davidlion marked this conversation as resolved.
endif()
139 changes: 1 addition & 138 deletions components/core/src/clp/GrepCore.cpp
Original file line number Diff line number Diff line change
@@ -1,35 +1,19 @@
#include "GrepCore.hpp"

#include <cstddef>
#include <set>
#include <string>
#include <string_view>

#include <log_surgeon/Constants.hpp>
#include <string_utils/string_utils.hpp>

#include "ir/parsing.hpp"
#include "LogSurgeonReader.hpp"
#include "QueryToken.hpp"
#include "StringReader.hpp"
#include <clp/ir/parsing.hpp>

using clp::ir::is_delim;
using clp::string_utils::is_alphabet;
using clp::string_utils::is_wildcard;
using std::string;

namespace clp {
namespace {
/**
* Wraps the tokens returned from the log_surgeon lexer, and stores the variable ids of the tokens
* in a search query in a set. This allows for optimized search performance.
*/
class SearchToken : public log_surgeon::Token {
public:
std::set<int> m_type_ids_set;
};
} // namespace

bool GrepCore::get_bounds_of_next_potential_var(
string const& value,
size_t& begin_pos,
Expand Down Expand Up @@ -149,125 +133,4 @@ bool GrepCore::get_bounds_of_next_potential_var(

return (value_length != begin_pos);
}

bool GrepCore::get_bounds_of_next_potential_var(
string const& value,
size_t& begin_pos,
size_t& end_pos,
bool& is_var,
log_surgeon::lexers::ByteLexer& lexer
) {
size_t const value_length = value.length();
if (end_pos >= value_length) {
return false;
}

is_var = false;
bool contains_wildcard = false;
while (false == is_var && false == contains_wildcard && begin_pos < value_length) {
// Start search at end of last token
begin_pos = end_pos;

// Find variable begin or wildcard
bool is_escaped = false;
for (; begin_pos < value_length; ++begin_pos) {
char c = value[begin_pos];

if (is_escaped) {
is_escaped = false;

if (false == lexer.is_delimiter(c)) {
// Found escaped non-delimiter, so reverse the index to retain the escape
// character
--begin_pos;
break;
}
} else if ('\\' == c) {
// Escape character
is_escaped = true;
} else {
if (is_wildcard(c)) {
contains_wildcard = true;
break;
}
if (false == lexer.is_delimiter(c)) {
break;
}
}
}

// Find next delimiter
is_escaped = false;
end_pos = begin_pos;
for (; end_pos < value_length; ++end_pos) {
char c = value[end_pos];

if (is_escaped) {
is_escaped = false;

if (lexer.is_delimiter(c)) {
// Found escaped delimiter, so reverse the index to retain the escape character
--end_pos;
break;
}
} else if ('\\' == c) {
// Escape character
is_escaped = true;
} else {
if (is_wildcard(c)) {
contains_wildcard = true;
} else if (lexer.is_delimiter(c)) {
// Found delimiter that's not also a wildcard
break;
}
}
}

if (end_pos > begin_pos) {
bool has_prefix_wildcard = ('*' == value[begin_pos]) || ('?' == value[begin_pos]);
bool has_suffix_wildcard = ('*' == value[end_pos - 1]) || ('?' == value[end_pos - 1]);
bool has_wildcard_in_middle = false;
for (size_t i = begin_pos + 1; i < end_pos - 1; ++i) {
if (('*' == value[i] || '?' == value[i]) && value[i - 1] != '\\') {
has_wildcard_in_middle = true;
break;
}
}
SearchToken search_token;
if (has_wildcard_in_middle || has_prefix_wildcard) {
// DO NOTHING
} else {
StringReader string_reader;
LogSurgeonReader reader_wrapper(string_reader);
log_surgeon::ParserInputBuffer parser_input_buffer;
if (has_suffix_wildcard) { // text*
// TODO: creating a string reader, setting it equal to a string, to read it into
// the ParserInputBuffer, seems like a convoluted way to set a string equal to a
// string, should be improved when adding a SearchParser to log_surgeon
string_reader.open(value.substr(begin_pos, end_pos - begin_pos - 1));
parser_input_buffer.read_if_safe(reader_wrapper);
lexer.reset();
lexer.scan_with_wildcard(parser_input_buffer, value[end_pos - 1], search_token);
} else { // no wildcards
string_reader.open(value.substr(begin_pos, end_pos - begin_pos));
parser_input_buffer.read_if_safe(reader_wrapper);
lexer.reset();
auto [err, token] = lexer.scan(parser_input_buffer);
if (log_surgeon::ErrorCode::Success != err) {
return false;
}
search_token = SearchToken{token.value()};
search_token.m_type_ids_set.insert(search_token.get_type_ids()->at(0));
}
auto const& type = search_token.get_type_ids()->at(0);
if (type != static_cast<int>(log_surgeon::SymbolId::TokenUncaughtString)
&& type != static_cast<int>(log_surgeon::SymbolId::TokenEnd))
{
is_var = true;
}
}
}
}
return (value_length != begin_pos);
}
} // namespace clp
161 changes: 67 additions & 94 deletions components/core/src/clp/GrepCore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
#include <string_utils/constants.hpp>
#include <string_utils/string_utils.hpp>

#include "Defs.h"
#include "EncodedVariableInterpreter.hpp"
#include "ir/parsing.hpp"
#include "ir/types.hpp"
#include "LogTypeDictionaryReaderReq.hpp"
#include "Query.hpp"
#include "QueryToken.hpp"
#include "VariableDictionaryReaderReq.hpp"
#include <clp/Defs.h>
#include <clp/EncodedVariableInterpreter.hpp>
#include <clp/ir/parsing.hpp>
#include <clp/ir/types.hpp>
#include <clp/LogTypeDictionaryReaderReq.hpp>
#include <clp/Query.hpp>
#include <clp/QueryToken.hpp>
#include <clp/SchemaSearcher.hpp>
#include <clp/VariableDictionaryReaderReq.hpp>

namespace clp {
class GrepCore {
Expand Down Expand Up @@ -75,24 +76,6 @@ class GrepCore {
bool& is_var
);

/**
* Returns bounds of next potential variable (either a definite variable or a token with
* wildcards)
* @param value String containing token
* @param begin_pos Begin position of last token, changes to begin position of next token
* @param end_pos End position of last token, changes to end position of next token
* @param is_var Whether the token is definitely a variable
* @param lexer DFA for determining if input is in the schema
* @return true if another potential variable was found, false otherwise
*/
static bool get_bounds_of_next_potential_var(
std::string const& value,
size_t& begin_pos,
size_t& end_pos,
bool& is_var,
log_surgeon::lexers::ByteLexer& lexer
);

private:
// Types
enum class SubQueryMatchabilityResult : uint8_t {
Expand Down Expand Up @@ -163,13 +146,18 @@ std::optional<Query> GrepCore::process_raw_query(
log_surgeon::lexers::ByteLexer& lexer,
bool use_heuristic
) {
// Split search_string into tokens with wildcards
std::vector<QueryToken> query_tokens;
size_t begin_pos = 0;
size_t end_pos = 0;
bool is_var;
std::string search_string_for_sub_queries{search_string};
if (use_heuristic) {
std::vector<SubQuery> sub_queries;
if (false == use_heuristic) {
sub_queries
= SchemaSearcher::search(search_string, lexer, logtype_dict, var_dict, ignore_case);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
} else {
// Split search_string into tokens with wildcards
std::vector<QueryToken> query_tokens;
size_t begin_pos{0};
size_t end_pos{0};
bool is_var{false};
std::string search_string_for_sub_queries{search_string};

// Replace unescaped '?' wildcards with '*' wildcards since we currently have no support for
// generating sub-queries with '?' wildcards. The final wildcard match on the decompressed
// message uses the original wildcards, so correctness will be maintained.
Expand All @@ -192,70 +180,55 @@ std::optional<Query> GrepCore::process_raw_query(
{
query_tokens.emplace_back(search_string_for_sub_queries, begin_pos, end_pos, is_var);
}
} else {
while (get_bounds_of_next_potential_var(
search_string_for_sub_queries,
begin_pos,
end_pos,
is_var,
lexer
))
{
query_tokens.emplace_back(search_string_for_sub_queries, begin_pos, end_pos, is_var);
}
}

// Get pointers to all ambiguous tokens. Exclude tokens with wildcards in the middle since we
// fall-back to decompression + wildcard matching for those.
std::vector<QueryToken*> ambiguous_tokens;
for (auto& query_token : query_tokens) {
if (!query_token.has_greedy_wildcard_in_middle() && query_token.is_ambiguous_token()) {
ambiguous_tokens.push_back(&query_token);
// Get pointers to all ambiguous tokens. Exclude tokens with wildcards in the middle since
// we fall-back to decompression + wildcard matching for those.
std::vector<QueryToken*> ambiguous_tokens;
for (auto& query_token : query_tokens) {
if (false == query_token.has_greedy_wildcard_in_middle()
&& query_token.is_ambiguous_token())
{
ambiguous_tokens.push_back(&query_token);
}
}
}

// Generate a sub-query for each combination of ambiguous tokens
// E.g., if there are two ambiguous tokens each of which could be a logtype or variable, we need
// to create:
// - (token1 as logtype) (token2 as logtype)
// - (token1 as logtype) (token2 as var)
// - (token1 as var) (token2 as logtype)
// - (token1 as var) (token2 as var)
std::vector<SubQuery> sub_queries;
std::string logtype;
bool type_of_one_token_changed = true;
while (type_of_one_token_changed) {
SubQuery sub_query;

// Compute logtypes and variables for query
auto matchability = generate_logtypes_and_vars_for_subquery(
logtype_dict,
var_dict,
search_string_for_sub_queries,
query_tokens,
ignore_case,
sub_query
);
switch (matchability) {
case SubQueryMatchabilityResult::SupercedesAllSubQueries:
// Since other sub-queries will be superceded by this one, we can stop processing
// now
return Query{search_begin_ts, search_end_ts, ignore_case, search_string, {}};
case SubQueryMatchabilityResult::MayMatch:
sub_queries.push_back(std::move(sub_query));
break;
case SubQueryMatchabilityResult::WontMatch:
default:
// Do nothing
break;
}
// Generate a sub-query for each combination of ambiguous tokens
// E.g., if there are two ambiguous tokens each of which could be a logtype or variable, we
// need to create:
// - (token1 as logtype) (token2 as logtype)
// - (token1 as logtype) (token2 as var)
// - (token1 as var) (token2 as logtype)
// - (token1 as var) (token2 as var)
bool type_of_one_token_changed{true};
while (type_of_one_token_changed) {
SubQuery sub_query;
auto matchability{generate_logtypes_and_vars_for_subquery(
logtype_dict,
var_dict,
search_string_for_sub_queries,
query_tokens,
ignore_case,
sub_query
)};
switch (matchability) {
case SubQueryMatchabilityResult::SupercedesAllSubQueries:
// Since other sub-queries will be superceded by this one, we can stop
// processing now.
return Query{search_begin_ts, search_end_ts, ignore_case, search_string, {}};
case SubQueryMatchabilityResult::MayMatch:
sub_queries.push_back(std::move(sub_query));
break;
case SubQueryMatchabilityResult::WontMatch:
default:
break;
}

// Update combination of ambiguous tokens
type_of_one_token_changed = false;
for (auto* ambiguous_token : ambiguous_tokens) {
if (ambiguous_token->change_to_next_possible_type()) {
type_of_one_token_changed = true;
break;
// Update combination of ambiguous tokens
type_of_one_token_changed = false;
Comment thread
davidlion marked this conversation as resolved.
for (auto* ambiguous_token : ambiguous_tokens) {
if (ambiguous_token->change_to_next_possible_type()) {
type_of_one_token_changed = true;
break;
}
}
}
}
Expand Down
Loading
Loading