forked from TrueCloudLab/frostfs-sdk-go
[#227] netmap: Do not use intermediate types for placement
Support preprocessing within the `NodeInfo` type. Provide methods for placement directly from the `NodeInfo` type. Returns slice of slices of `NodeInfo` from placement methods of `Netmap`. Remove no longer needed `Node` and `Nodes` types. ``` name old time/op new time/op delta ManySelects-12 19.7µs ±14% 15.8µs ±15% -19.70% (p=0.000 n=20+20) name old alloc/op new alloc/op delta ManySelects-12 8.65kB ± 0% 6.22kB ± 0% -28.03% (p=0.000 n=20+20) name old allocs/op new allocs/op delta ManySelects-12 82.0 ± 0% 81.0 ± 0% -1.22% (p=0.000 n=20+20) ``` Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
2b21146185
commit
723ba5ee45
12 changed files with 305 additions and 246 deletions
|
@ -15,7 +15,7 @@ type context struct {
|
|||
// Selectors stores processed selectors.
|
||||
Selectors map[string]*Selector
|
||||
// Selections stores result of selector processing.
|
||||
Selections map[string][]Nodes
|
||||
Selections map[string][]nodes
|
||||
|
||||
// numCache stores parsed numeric values.
|
||||
numCache map[string]uint64
|
||||
|
@ -54,11 +54,11 @@ func newContext(nm *Netmap) *context {
|
|||
Netmap: nm,
|
||||
Filters: make(map[string]*Filter),
|
||||
Selectors: make(map[string]*Selector),
|
||||
Selections: make(map[string][]Nodes),
|
||||
Selections: make(map[string][]nodes),
|
||||
|
||||
numCache: make(map[string]uint64),
|
||||
aggregator: newMeanIQRAgg,
|
||||
weightFunc: GetDefaultWeightFunc(nm.Nodes),
|
||||
weightFunc: GetDefaultWeightFunc(nm.nodes),
|
||||
cbf: defaultCBF,
|
||||
}
|
||||
}
|
||||
|
@ -79,13 +79,13 @@ func (c *context) setCBF(cbf uint32) {
|
|||
}
|
||||
|
||||
// GetDefaultWeightFunc returns default weighting function.
|
||||
func GetDefaultWeightFunc(ns Nodes) weightFunc {
|
||||
func GetDefaultWeightFunc(ns nodes) weightFunc {
|
||||
mean := newMeanAgg()
|
||||
min := newMinAgg()
|
||||
|
||||
for i := range ns {
|
||||
mean.Add(float64(ns[i].Capacity))
|
||||
min.Add(float64(ns[i].Price))
|
||||
mean.Add(float64(ns[i].capacity()))
|
||||
min.Add(float64(ns[i].price()))
|
||||
}
|
||||
|
||||
return newWeightFunc(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue