milvus/internal/util/indexparamcheck/bin_ivf_flat_checker.go
foxspy d7b2ffe5aa
enhance: add an unify vector index config checker (#36844)
issue: #34298

Signed-off-by: xianliang.li <xianliang.li@zilliz.com>
2024-10-28 10:11:37 +08:00

36 lines
895 B
Go

package indexparamcheck
import (
"fmt"
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
)
type binIVFFlatChecker struct {
binaryVectorBaseChecker
}
func (c binIVFFlatChecker) StaticCheck(dataType schemapb.DataType, params map[string]string) error {
if !CheckStrByValues(params, Metric, BinIvfMetrics) {
return fmt.Errorf("metric type %s not found or not supported, supported: %v", params[Metric], BinIvfMetrics)
}
if !CheckIntByRange(params, NLIST, MinNList, MaxNList) {
return errOutOfRange(NLIST, MinNList, MaxNList)
}
return nil
}
func (c binIVFFlatChecker) CheckTrain(dataType schemapb.DataType, params map[string]string) error {
if err := c.binaryVectorBaseChecker.CheckTrain(dataType, params); err != nil {
return err
}
return c.StaticCheck(schemapb.DataType_BinaryVector, params)
}
func newBinIVFFlatChecker() IndexChecker {
return &binIVFFlatChecker{}
}