Skip to content

Commit

Permalink
Fix test-interpretation and update READme
Browse files Browse the repository at this point in the history
  • Loading branch information
SharafMohamed committed Oct 7, 2024
1 parent 9cff8ec commit 4379bc5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
8 changes: 6 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Examples

There are two example programs in this directory, `buffer-parser` and
The first two example programs in this directory are `buffer-parser` and
`reader-parser` corresponding to the [two API styles][1]. They demonstrate
parsing a log file and printing out the timestamp and log-level of each message,
as well as any multiline log messages.
as well as any multiline log messages.

The third example is `intersect-test` which demonstrates the result of taking
the intersection between a schema DFA and a search query DFA.

## Building

Expand All @@ -24,6 +27,7 @@ The example programs can be run as follows:
```shell
./examples/build/buffer-parser ./examples/schema.txt log.txt
./examples/build/reader-parser ./examples/schema.txt log.txt
./examples/build/intersect-test
```

where:
Expand Down
26 changes: 13 additions & 13 deletions examples/intersect-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ auto get_intersect_for_query(
processed_search_string.push_back(c);
}
log_surgeon::Schema schema;
schema.add_variable("search", processed_search_string, -1);
schema.add_variable(string("search:") + processed_search_string, -1);
RegexNFA<RegexNFAByteState> nfa;
auto schema_ast = schema.release_schema_ast_ptr();
for (unique_ptr<ParserAST> const& parser_ast : schema_ast->m_schema_vars) {
Expand All @@ -51,20 +51,20 @@ auto main() -> int {
log_surgeon::Schema schema;
if (0 == i) {
std::cout << "--Schema1--" << std::endl;
schema.add_variable("int", "\\-{0,1}[0-9]+", -1);
schema.add_variable("float", "\\-{0,1}[0-9]+\\.[0-9]+", -1);
schema.add_variable("hex", "[a-fA-F]+", -1);
schema.add_variable("hasNumber", ".*\\d.*", -1);
schema.add_variable("equals", ".*=.*[a-zA-Z0-9].*", -1);
schema.add_variable("logLevel", "(INFO)|(DEBUG)|(WARN)|(ERROR)|(TRACE)|(FATAL)", -1);
schema.add_variable("int:\\-{0,1}[0-9]+", -1);
schema.add_variable("float:\\-{0,1}[0-9]+\\.[0-9]+", -1);
schema.add_variable("hex:[a-fA-F]+", -1);
schema.add_variable("hasNumber:.*\\d.*", -1);
schema.add_variable("equals:.*=.*[a-zA-Z0-9].*", -1);
schema.add_variable("logLevel:(INFO)|(DEBUG)|(WARN)|(ERROR)|(TRACE)|(FATAL)", -1);
} else {
std::cout << "--Schema2--" << std::endl;
schema.add_variable("v1", "1", -1);
schema.add_variable("v2", "2", -1);
schema.add_variable("v3", "3", -1);
schema.add_variable("v4", "abc12", -1);
schema.add_variable("v5", "23def", -1);
schema.add_variable("v6", "123", -1);
schema.add_variable("v1:1", -1);
schema.add_variable("v2:2", -1);
schema.add_variable("v3:3", -1);
schema.add_variable("v4:abc12", -1);
schema.add_variable("v5:23def", -1);
schema.add_variable("v6:123", -1);
}
std::map<uint32_t, std::string> m_id_symbol;
RegexNFA<RegexNFAByteState> nfa;
Expand Down

0 comments on commit 4379bc5

Please sign in to comment.