[#88] min aggregator bug fixed, tests added #164
2 changed files with 15 additions and 12 deletions
|
@ -23,7 +23,8 @@ type (
|
|||
}
|
||||
|
||||
minAgg struct {
|
||||
min *float64
|
||||
min float64
|
||||
minFound bool
|
||||
}
|
||||
|
||||
meanIQRAgg struct {
|
||||
|
@ -102,17 +103,19 @@ func (a *meanAgg) Compute() float64 {
|
|||
}
|
||||
|
||||
func (a *minAgg) Add(n float64) {
|
||||
if a.min == nil || n < *a.min {
|
||||
a.min = &n
|
||||
if !a.minFound {
|
||||
a.min = n
|
||||
a.minFound = true
|
||||
return
|
||||
}
|
||||
|
||||
if n < a.min {
|
||||
a.min = n
|
||||
}
|
||||
}
|
||||
|
||||
func (a *minAgg) Compute() float64 {
|
||||
if a.min == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
return *a.min
|
||||
return a.min
|
||||
}
|
||||
|
||||
func (a *meanIQRAgg) Add(n float64) {
|
||||
|
|
|
@ -146,19 +146,19 @@
|
|||
"select 3 nodes in 3 distinct countries, same placement": {
|
||||
"policy": {"replicas":[{"count":1,"selector":"Main"}],"containerBackupFactor":1,"selectors":[{"name":"Main","count":3,"clause":"DISTINCT","attribute":"Country","filter":"*"}],"filters":[]},
|
||||
"pivot": "Y29udGFpbmVySUQ=",
|
||||
"result": [[4, 0, 7]],
|
||||
"result": [[0, 2, 3]],
|
||||
"placement": {
|
||||
"pivot": "b2JqZWN0SUQ=",
|
||||
"result": [[4, 0, 7]]
|
||||
"result": [[0, 2, 3]]
|
||||
}
|
||||
},
|
||||
"select 6 nodes in 3 distinct countries, different placement": {
|
||||
"policy": {"replicas":[{"count":1,"selector":"Main"}],"containerBackupFactor":2,"selectors":[{"name":"Main","count":3,"clause":"DISTINCT","attribute":"Country","filter":"*"}],"filters":[]},
|
||||
"pivot": "Y29udGFpbmVySUQ=",
|
||||
"result": [[4, 3, 0, 1, 7, 2]],
|
||||
"result": [[0, 1, 2, 6, 3, 4]],
|
||||
"placement": {
|
||||
"pivot": "b2JqZWN0SUQ=",
|
||||
"result": [[4, 3, 0, 7, 2, 1]]
|
||||
"result": [[0, 1, 2, 6, 3, 4]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue