milvus/internal/util/indexparamcheck/utils.go
dragondriver fd57554d32
Add index params check in proxy (#5958)
Signed-off-by: dragondriver <jiquan.long@zilliz.com>
2021-06-22 15:28:04 +08:00

31 lines
547 B
Go

package indexparamcheck
import (
"strconv"
"github.com/milvus-io/milvus/internal/util/funcutil"
)
func CheckIntByRange(params map[string]string, key string, min, max int) bool {
valueStr, ok := params[key]
if !ok {
return false
}
value, err := strconv.Atoi(valueStr)
if err != nil {
return false
}
return value >= min && value <= max
}
func CheckStrByValues(params map[string]string, key string, container []string) bool {
value, ok := params[key]
if !ok {
return false
}
return funcutil.SliceContain(container, value)
}