PushFixed function for static dataset size
Instead of Push simply appending data points to ever expanding Go slices; this change will utilize GoVector's PushFixed function to keep the array size constant as data points are added by dropping the oldest event. The goal is to keep memory allocations for long running processes constantly evaluating anomalies consistent.
eg
anomalyzer.Data: [ 1.0, 2.0, 3.0]
err := anomalyzer.PushFixed(5.0)
anomalyzer.Data: [2.0, 3.0, 5.0]
Mixing Push and FixedPush for a anomalyzer data set will result in failures. The problem stems from the len of an array changing, but the cap not also being updated. There might be a easy fix another change will need to be made to GoVector.
I really like this method and I almost wonder if it would be useful enough for others that an AnomalyzerConf option should be something like Cap. So that if Cap is unspecified, then we just default to the Push() option, otherwise if len(data) > Cap we start to PushFixed() (or whatever doesn't result in failures). @drewlanenga?
I agree, I'd like to have a safe usage of both intermixed, or configurable like you state. However it might just need a re-evaluation of my GoVector code to fix the problem.
@drewlanenga will need to merge this PR into GoVector in order for the tests I added to pass.
Took me a little bit to figure out why it's failing.. It's because my PR on GoVector hasn't been merged yet.
Otherwise :+1: