Skip to content

Commit

Permalink
Update readme; rename unclean query string
Browse files Browse the repository at this point in the history
  • Loading branch information
LinZhihao-723 committed Sep 29, 2023
1 parent a362358 commit 499ef7d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ from clp_ffi_py.ir import ClpIrFileReader, Query, QueryBuilder
# Create a QueryBuilder object to build the search query.
query_builder: QueryBuilder = QueryBuilder()

# Add wildcard patterns to filter log messages:
# Add wildcard patterns to filter log messages.By default, the partial match
# will be executed. Please refer to the documents of `WildcardQuery` object for
# the difference between partial and full matches.
query_builder.add_wildcard_query("uid=*,status=failed")
query_builder.add_wildcard_query("UID=*,Status=KILLED", case_sensitive=True)

Expand Down
2 changes: 1 addition & 1 deletion src/clp_ffi_py/ir/native/PyQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ auto serialize_wildcard_queries(std::vector<WildcardQuery> const& wildcard_queri
Py_ssize_t idx{0};
for (auto const& wildcard_query : wildcard_queries) {
PyObjectPtr<PyObject> const wildcard_py_str_ptr{
PyUnicode_FromString(wildcard_query.get_uncleaned_wildcard_query().c_str())
PyUnicode_FromString(wildcard_query.get_original_query_string().c_str())
};
auto* wildcard_py_str{wildcard_py_str_ptr.get()};
if (nullptr == wildcard_py_str) {
Expand Down
12 changes: 6 additions & 6 deletions src/clp_ffi_py/ir/native/Query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ class WildcardQuery {
* @param partial_match Partial match indicator.
*/
WildcardQuery(std::string wildcard_query, bool case_sensitive, bool partial_match)
: m_uncleaned_wildcard_query(std::move(wildcard_query)),
: m_original_query_string(std::move(wildcard_query)),
m_case_sensitive(case_sensitive),
m_partial_match(partial_match) {
if (partial_match) {
m_wildcard_query = "*";
m_wildcard_query += m_uncleaned_wildcard_query;
m_wildcard_query += m_original_query_string;
m_wildcard_query += "*";
m_wildcard_query = clean_up_wildcard_search_string(m_wildcard_query);
} else {
m_wildcard_query = clean_up_wildcard_search_string(m_uncleaned_wildcard_query);
m_wildcard_query = clean_up_wildcard_search_string(m_original_query_string);
}
}

[[nodiscard]] auto get_uncleaned_wildcard_query() const -> std::string const& {
return m_uncleaned_wildcard_query;
[[nodiscard]] auto get_original_query_string() const -> std::string const& {
return m_original_query_string;
}

[[nodiscard]] auto get_wildcard_query() const -> std::string const& { return m_wildcard_query; }
Expand All @@ -52,7 +52,7 @@ class WildcardQuery {
[[nodiscard]] auto is_partial_match() const -> bool { return m_partial_match; }

private:
std::string m_uncleaned_wildcard_query;
std::string m_original_query_string;
std::string m_wildcard_query;
bool m_case_sensitive;
bool m_partial_match;
Expand Down

0 comments on commit 499ef7d

Please sign in to comment.