From e461216c7c560c270b1759f28adc62403f3b28e2 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Sat, 27 Jan 2024 22:02:49 -0500 Subject: [Bugfix] Stabilizer was optimistic The "all complete" flag incorrectly overwrote a previous value, even if that value was false. The result? If an aggregate was incomplete but any later aggregate was complete, it would conclude that all aggregates were complete. Signed-off-by: Will Hawkins --- stabilizer/algorithm.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/stabilizer/algorithm.go b/stabilizer/algorithm.go index 42dc0c6..d6bedfc 100644 --- a/stabilizer/algorithm.go +++ b/stabilizer/algorithm.go @@ -109,6 +109,12 @@ func (r3 *MeasurementStablizer[Data, Bucket]) AddMeasurement(bucket Bucket, meas r3.dbgConfig.String(), bucket) } + } else { + if debug.IsDebug(r3.dbgLevel) { + fmt.Printf("%s: A bucket (with id %v) does exist in a historical window.\n", + r3.dbgConfig.String(), + bucket) + } } } }) @@ -173,7 +179,7 @@ func (r3 *MeasurementStablizer[Data, Bucket]) IsStable() bool { r3.aggregates.ForEach(func(b int, md *utilities.Optional[series.WindowSeries[Data, Bucket]]) { if utilities.IsSome[series.WindowSeries[Data, Bucket]](*md) { md := utilities.GetSome[series.WindowSeries[Data, Bucket]](*md) - allComplete = md.Complete() + allComplete = allComplete && md.Complete() if debug.IsDebug(r3.dbgLevel) { fmt.Printf("%s\n", md.String()) } @@ -205,6 +211,17 @@ func (r3 *MeasurementStablizer[Data, Bucket]) IsStable() bool { } }) + if debug.IsDebug(r3.dbgLevel) { + r3.aggregates.ForEach(func(b int, md *utilities.Optional[series.WindowSeries[Data, Bucket]]) { + if utilities.IsSome[series.WindowSeries[Data, Bucket]](*md) { + md := utilities.GetSome[series.WindowSeries[Data, Bucket]](*md) + + filled, unfilled := md.Count() + fmt.Printf("An aggregate has %v filled and %v unfilled buckets.\n", filled, unfilled) + } + }) + } + // Calculate the standard deviation of the averages of the aggregates. sd := utilities.CalculateStandardDeviation(averages) -- cgit v1.2.3