milvus/pkg/util/indexparamcheck/ivf_sq_checker.go
Jiquan Long 7be7e6f360
Refactor check logic of index parameters (#23856)
Signed-off-by: longjiquan <jiquan.long@zilliz.com>
2023-05-06 10:40:39 +08:00

35 lines
857 B
Go

package indexparamcheck
import (
"fmt"
)
// ivfSQChecker checks if a IVF_SQ index can be built.
type ivfSQChecker struct {
ivfBaseChecker
}
func (c *ivfSQChecker) checkNBits(params map[string]string) error {
// cgo will set this key to DefaultNBits (8), which is the only value Milvus supports.
_, exist := params[NBITS]
if exist {
// 8 is the only supported nbits.
if !CheckIntByRange(params, NBITS, DefaultNBits, DefaultNBits) {
return fmt.Errorf("nbits can be only set to 8 for IVF_SQ")
}
}
return nil
}
// CheckTrain returns true if the index can be built with the specific index parameters.
func (c *ivfSQChecker) CheckTrain(params map[string]string) error {
if err := c.checkNBits(params); err != nil {
return err
}
return c.ivfBaseChecker.CheckTrain(params)
}
func newIVFSQChecker() IndexChecker {
return &ivfSQChecker{}
}