mirror of https://github.com/tidwall/tile38.git
Array of values instead of map for whereins.
This commit is contained in:
parent
27c6980f82
commit
9e7766b346
|
@ -35,8 +35,8 @@ func BenchmarkFieldMatch(t *testing.B) {
|
||||||
{"bar", false, 10, false, 30},
|
{"bar", false, 10, false, 30},
|
||||||
},
|
},
|
||||||
whereins: []whereinT{
|
whereins: []whereinT{
|
||||||
{"foo", map[float64]struct{}{1: {}, 2: {}}},
|
{"foo", []float64{1, 2}},
|
||||||
{"bar", map[float64]struct{}{11: {}, 25: {}}},
|
{"bar", []float64{11, 25}},
|
||||||
},
|
},
|
||||||
fmap: map[string]int{"foo": 0, "bar": 1},
|
fmap: map[string]int{"foo": 0, "bar": 1},
|
||||||
farr: []string{"bar", "foo"},
|
farr: []string{"bar", "foo"},
|
||||||
|
|
|
@ -159,12 +159,16 @@ func zMinMaxFromWheres(wheres []whereT) (minZ, maxZ float64) {
|
||||||
|
|
||||||
type whereinT struct {
|
type whereinT struct {
|
||||||
field string
|
field string
|
||||||
valMap map[float64]struct{}
|
valArr []float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wherein whereinT) match(value float64) bool {
|
func (wherein whereinT) match(value float64) bool {
|
||||||
_, ok := wherein.valMap[value]
|
for _, val := range wherein.valArr {
|
||||||
return ok
|
if val == value {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
type whereevalT struct {
|
type whereevalT struct {
|
||||||
|
@ -342,9 +346,8 @@ func (s *Server) parseSearchScanBaseTokens(
|
||||||
err = errInvalidArgument(nvalsStr)
|
err = errInvalidArgument(nvalsStr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
valMap := make(map[float64]struct{})
|
valArr := make([]float64, nvals)
|
||||||
var val float64
|
var val float64
|
||||||
var empty struct{}
|
|
||||||
for i = 0; i < nvals; i++ {
|
for i = 0; i < nvals; i++ {
|
||||||
if vs, valStr, ok = tokenval(vs); !ok || valStr == "" {
|
if vs, valStr, ok = tokenval(vs); !ok || valStr == "" {
|
||||||
err = errInvalidNumberOfArguments
|
err = errInvalidNumberOfArguments
|
||||||
|
@ -354,9 +357,9 @@ func (s *Server) parseSearchScanBaseTokens(
|
||||||
err = errInvalidArgument(valStr)
|
err = errInvalidArgument(valStr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
valMap[val] = empty
|
valArr = append(valArr, val)
|
||||||
}
|
}
|
||||||
t.whereins = append(t.whereins, whereinT{field, valMap})
|
t.whereins = append(t.whereins, whereinT{field, valArr})
|
||||||
continue
|
continue
|
||||||
case "whereevalsha":
|
case "whereevalsha":
|
||||||
fallthrough
|
fallthrough
|
||||||
|
|
Loading…
Reference in New Issue