mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
7be7e6f360
Signed-off-by: longjiquan <jiquan.long@zilliz.com>
35 lines
857 B
Go
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{}
|
|
}
|