diff options
| author | Will Hawkins <[email protected]> | 2024-01-27 22:02:49 -0500 |
|---|---|---|
| committer | Will Hawkins <[email protected]> | 2024-01-27 22:02:49 -0500 |
| commit | e461216c7c560c270b1759f28adc62403f3b28e2 (patch) | |
| tree | 102f9cae3f99d871bf15f0ba4883e8de841a7974 | |
| parent | e60066f572464da3a6f55999a48b1d38cf6423d6 (diff) | |
[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 <[email protected]>
| -rw-r--r-- | stabilizer/algorithm.go | 19 |
1 files changed, 18 insertions, 1 deletions
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) |
