This repository contains the solution for the Curieo.org assignment, specifically an Error Log Monitor System implemented in Python 3.9.
- Python 3.9
-
Clone the repository:
git clone https://github.com/DEBASMITROY2002/Curieo_debasmit.git
-
Navigate to the repository folder:
cd Curieo_debasmit
-
Create an 'input.txt' file in the repository folder to provide input data.
Sample input.txt Format
1715744138011;INTERNAL_SERVER_ERROR;23.72
1715744138012;INTERNAL_SERVER_ERROR;10.17
INTERNAL_SERVER_ERROR
1715744138012;BAD_REQUEST;15.22
1715744138013;INTERNAL_SERVER_ERROR;23.72
BEFORE 1715744138011
AFTER 1715744138010
BEFORE INTERNAL_SERVER_ERROR 1715744138011
AFTER INTERNAL_SERVER_ERROR 1715744138010
Note: Error types should not contain any non-alphanumeric characters except underscores. Ensure there are no extra whitespaces.
To run the program, execute the following command:
python3 run.py
If n is the total number of logs.
- Time complexity for inserting each log into our data structure is ๐ ( 1 ) (amortized).
- Time complexity for each query is ๐ ( log โก ๐ ).
The order is : O(n)
- Prefix array for storing minimum, maximum, and summation using python 1d list
- Monotonic stack for suffix min/max using python 1d list
- Map using python dictionary
- Each log type is mapped to its associated log entry object using string-to-object mapping. Therefore, accessing log entries under each log type is done in O(1)
- Each log entry object contains prefix-suffix utilities, total severities, and timestamps in increasing order of timestamps.
- Accessing timestamps using binary search requires O(log n) time.
- Each query over the prefix array requires O(1) time.
- Each query over the Monotonic stack requires O(log n) using binary search.
- The insertion of n elements into the monotonic stack takes O(n) time , resulting in O(1) time per element (amortized).
- The Suffix mean is calculated using: (Total Sum - Prefix Sum + Current Element) / (n-index)
cd test
python3 gen_testcase.py
Now the 'test/test_cases.txt' is generated.
The brute-force logic is in the 'test/brute_force.py'. Running this will generate 'test/output_test.txt'.
We can use 'pytest' to validate the results.
pip install pytest
python3 run.py test/test_cases.txt
cd test
python3 brute_force.py
pytest test.py