archiver-appliance / epicsarchiverap

This is an implementation of an archiver for EPICS control systems that aims to archive millions of PVs.
Other
38 stars 37 forks source link

Bug fix in the new OptimizedWithLastSample post-processor to correctly handle no events in the last bins #117

Closed rjwills28 closed 3 years ago

rjwills28 commented 3 years ago

While testing we found an edge case where the OptimizedWithLastSample is not performing correctly. The OptimizedWithLastSample postprocessor iterates through events and allocates them to time interval bin. If bins are skipped (i.e. there were no events in that time interval), then it sets the value of those bins to the last sample in the last bin to have event. However if the last bins within the requested timeframe have no events then it never actually looks at these to do the last sample replacement. Instead the for loop iterating through the events just comes to an end.

Following this, the class SummaryStatsCollectorEventStream, iterates through the results, realises that these last bins have no values and so simply inherits from the previous bin. This does not reflect what actually happened to the PV. Instead we would want these last bins to have the value of the last sample of the last bin with events.

The fix in this PR is relatively simple. In OptimizedWithLastSample, after iterating through the events it should then check whether the last bin that it assigned a value to is equal to the last bin of the timeframe. If not it should fill all of the remaining bins with the last value of the last bin with events.