[#88] netmap: use bool, fix hrw_sort tests

Signed-off-by: Andrew Danilin <andnilin@gmail.com>
This commit is contained in:
andnilin@gmail.com 2023-09-16 17:03:38 +03:00 committed by Evgenii Stratonikov
parent 163b3e1961
commit d71a0e0755
2 changed files with 15 additions and 12 deletions

View file

@ -23,7 +23,8 @@ type (
} }
minAgg struct { minAgg struct {
min *float64 min float64
minFound bool
} }
meanIQRAgg struct { meanIQRAgg struct {
@ -102,17 +103,19 @@ func (a *meanAgg) Compute() float64 {
} }
func (a *minAgg) Add(n float64) { func (a *minAgg) Add(n float64) {
if a.min == nil || n < *a.min { if !a.minFound {
a.min = &n a.min = n
a.minFound = true
return
}
if n < a.min {
a.min = n
} }
} }
func (a *minAgg) Compute() float64 { func (a *minAgg) Compute() float64 {
if a.min == nil { return a.min
return 0
}
return *a.min
} }
func (a *meanIQRAgg) Add(n float64) { func (a *meanIQRAgg) Add(n float64) {

View file

@ -146,19 +146,19 @@
"select 3 nodes in 3 distinct countries, same placement": { "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":[]}, "policy": {"replicas":[{"count":1,"selector":"Main"}],"containerBackupFactor":1,"selectors":[{"name":"Main","count":3,"clause":"DISTINCT","attribute":"Country","filter":"*"}],"filters":[]},
"pivot": "Y29udGFpbmVySUQ=", "pivot": "Y29udGFpbmVySUQ=",
"result": [[4, 0, 7]], "result": [[0, 2, 3]],
"placement": { "placement": {
"pivot": "b2JqZWN0SUQ=", "pivot": "b2JqZWN0SUQ=",
"result": [[4, 0, 7]] "result": [[0, 2, 3]]
} }
}, },
"select 6 nodes in 3 distinct countries, different placement": { "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":[]}, "policy": {"replicas":[{"count":1,"selector":"Main"}],"containerBackupFactor":2,"selectors":[{"name":"Main","count":3,"clause":"DISTINCT","attribute":"Country","filter":"*"}],"filters":[]},
"pivot": "Y29udGFpbmVySUQ=", "pivot": "Y29udGFpbmVySUQ=",
"result": [[4, 3, 0, 1, 7, 2]], "result": [[0, 1, 2, 6, 3, 4]],
"placement": { "placement": {
"pivot": "b2JqZWN0SUQ=", "pivot": "b2JqZWN0SUQ=",
"result": [[4, 3, 0, 7, 2, 1]] "result": [[0, 1, 2, 6, 3, 4]]
} }
} }
} }