Skip to content

Commit

Permalink
fix some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wraymo committed Dec 20, 2023
1 parent 628ce9b commit d9cf977
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions components/core/src/Grep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ std::optional<Query> Grep::process_raw_query(
// - (token1 as logtype) (token2 as var)
// - (token1 as var) (token2 as logtype)
// - (token1 as var) (token2 as var)
std::vector<SubQuery> sub_queries;
vector<SubQuery> sub_queries;
string logtype;
bool type_of_one_token_changed = true;
while (type_of_one_token_changed) {
Expand Down Expand Up @@ -603,7 +603,7 @@ std::optional<Query> Grep::process_raw_query(
return std::nullopt;
}

query.add_sub_queries(sub_queries);
query.set_sub_queries(std::move(sub_queries));
return query;
}

Expand Down
3 changes: 1 addition & 2 deletions components/core/src/Grep.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ class Grep {
* @param search_begin_ts
* @param search_end_ts
* @param ignore_case
* @param query
* @param forward_lexer DFA for determining if input is in the schema
* @param reverse_lexer DFA for determining if reverse of input is in the schema
* @param use_heuristic
* @return true if query may match messages, false otherwise
* @return Query if it may match a message, std::nullopt otherwise
*/
static std::optional<Query> process_raw_query(
streaming_archive::reader::Archive const& archive,
Expand Down
4 changes: 2 additions & 2 deletions components/core/src/Query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ void Query::set_search_string(string const& search_string) {
m_search_string_matches_all = (m_search_string.empty() || "*" == m_search_string);
}

void Query::add_sub_queries(std::vector<SubQuery>& sub_queries) {
void Query::set_sub_queries(std::vector<SubQuery> sub_queries) {
m_sub_queries = std::move(sub_queries);

for (auto& sub_query : m_sub_queries) {
// Add to relevant sub-queries if necessary
if (sub_query.get_ids_of_matching_segments().count(m_prev_segment_id)) {
m_relevant_sub_queries.push_back(&m_sub_queries.back());
m_relevant_sub_queries.push_back(&sub_query);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/core/src/Query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class Query {
void set_ignore_case(bool ignore_case) { m_ignore_case = ignore_case; }

void set_search_string(std::string const& search_string);
void add_sub_queries(std::vector<SubQuery>& sub_query);
void set_sub_queries(std::vector<SubQuery> sub_queries);
void clear_sub_queries();
/**
* Populates the set of relevant sub-queries with only those that match the given segment
Expand Down
8 changes: 4 additions & 4 deletions components/core/src/clg/clg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static bool search(
std::set<segment_id_t> ids_of_segments_to_search;
bool is_superseding_query = false;
for (auto const& search_string : search_strings) {
std::optional<Query> query_result = Grep::process_raw_query(
auto query_processing_result = Grep::process_raw_query(
archive,
search_string,
search_begin_ts,
Expand All @@ -216,11 +216,11 @@ static bool search(
reverse_lexer,
use_heuristic
);
if (query_result) {
Query& query = query_result.value();
if (false == query_processing_result.has_value()) {
auto& query = query_processing_result.value();
no_queries_match = false;

if (query.contains_sub_queries() == false) {
if (false == query.contains_sub_queries()) {
// Search string supersedes all other possible search strings
is_superseding_query = true;
// Remove existing queries since they are superseded by this one
Expand Down
6 changes: 3 additions & 3 deletions components/core/src/clo/clo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static bool search_archive(
auto search_begin_ts = command_line_args.get_search_begin_ts();
auto search_end_ts = command_line_args.get_search_end_ts();

std::optional<Query> query_result = Grep::process_raw_query(
auto query_processing_result = Grep::process_raw_query(
archive_reader,
command_line_args.get_search_string(),
search_begin_ts,
Expand All @@ -270,11 +270,11 @@ static bool search_archive(
*reverse_lexer,
use_heuristic
);
if (query_result) {
if (false == query_processing_result.has_value()) {
return true;
}

Query& query = query_result.value();
Query& query = query_processing_result.value();
// Get all segments potentially containing query results
std::set<segment_id_t> ids_of_segments_to_search;
for (auto& sub_query : query.get_sub_queries()) {
Expand Down

0 comments on commit d9cf977

Please sign in to comment.