[#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
|
@ -17,9 +17,8 @@ func TestContext_ProcessFilters(t *testing.T) {
|
|||
newFilter("", "IntField", "123", OpLT),
|
||||
newFilter("GoodRating", "", "", 0)),
|
||||
}
|
||||
nm, err := NewNetmap(nil)
|
||||
require.NoError(t, err)
|
||||
c := newContext(nm)
|
||||
|
||||
c := newContext(new(Netmap))
|
||||
p := newPlacementPolicy(1, nil, nil, fs)
|
||||
require.NoError(t, c.processFilters(p))
|
||||
require.Equal(t, 3, len(c.Filters))
|
||||
|
@ -81,10 +80,16 @@ func TestContext_ProcessFiltersInvalid(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFilter_MatchSimple_InvalidOp(t *testing.T) {
|
||||
b := &Node{AttrMap: map[string]string{
|
||||
"Rating": "4",
|
||||
"Country": "Germany",
|
||||
}}
|
||||
var aRating NodeAttribute
|
||||
aRating.SetKey("Rating")
|
||||
aRating.SetValue("4")
|
||||
|
||||
var aCountry NodeAttribute
|
||||
aRating.SetKey("Country")
|
||||
aRating.SetValue("Germany")
|
||||
|
||||
var b NodeInfo
|
||||
b.SetAttributes(aRating, aCountry)
|
||||
|
||||
f := newFilter("Main", "Rating", "5", OpEQ)
|
||||
c := newContext(new(Netmap))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue