Log Ingestion and Query
Implement a simplified logging system that supports log ingestion and conditional queries.
Each operation is one of the following strings:
ADD timestamp service level message: append one log entryQUERY startTs endTs serviceOr* levelOr* keywordOr*: count matching logs
A log matches a query if startTs <= timestamp <= endTs, service and level match exactly unless the filter is *, and keyword appears as a substring of the message unless the filter is *.
Process all operations in order and return the outputs produced by the QUERY commands.
Complete the function runLogIngestionQueries in the editor below.
runLogIngestionQueries has the following parameter:
String[] operations: the operations to execute in order
Returns
int[]: the counts produced by the QUERY operations.
1Example 1
The three queries count all logs, then all api logs in the first two timestamps, then only the single error log whose message contains failed.
2Example 2
Substring matching on the message field allows both successful and failed login events to match the keyword login.
Constraints
Limits and guarantees your solution can rely on.
1 <= operations.length <= 2 * 10^5- Timestamps are non-negative integers.
serviceandlevelcontain no spaces.messagemay contain spaces and is matched by substring search.