The program
- Reads records from provided output file, and parse the record to a CounterRecord case class
- Aggregate the records to get expected statisitcs
- Display the results in console
Error handling
- The programm checks if file path for the output file is given, and throws error if no provided
- If the file is corrupted, or program fails to extract records (like missing count, or incorrect date format), runtime exception will be thrown.
- I have tried using Either / Try to handle exception in a different branch error-handling. In the branch, runtime error will be handled at top level. Skipping incorrect record can be implemented in the branch.
The project is built with SBT. Please refers to Installing SBT for setup instruction.
To run the program, use following command:
sbt "run ./data/outputs"
Expected outputs:
Total count: 398
Daily count:
Date: 2016-12-01 Count: 179
Date: 2016-12-05 Count: 81
Date: 2016-12-08 Count: 134
Date: 2016-12-09 Count: 4
Top 3 records with most count:
Datetime: 2016-12-01T07:30 Count: 46
Datetime: 2016-12-01T08:00 Count: 42
Datetime: 2016-12-08T18:00 Count: 33
Done!
To run all tests, use following command:
sbt test