milvus/internal/util/indexparamcheck/raft_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

35 lines
975 B
Go

package indexparamcheck
import (
"fmt"
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
)
// raftIVFChecker checks if a RAFT_IVF_Flat index can be built.
type raftIVFFlatChecker struct {
ivfBaseChecker
}
// CheckTrain checks if ivf-flat index can be built with the specific index parameters.
func (c *raftIVFFlatChecker) CheckTrain(dataType schemapb.DataType, params map[string]string) error {
if err := c.ivfBaseChecker.CheckTrain(dataType, params); err != nil {
return err
}
if !CheckStrByValues(params, Metric, RaftMetrics) {
return fmt.Errorf("metric type not found or not supported, supported: %v", RaftMetrics)
}
setDefaultIfNotExist(params, RaftCacheDatasetOnDevice, "false")
if !CheckStrByValues(params, RaftCacheDatasetOnDevice, []string{"true", "false"}) {
return fmt.Errorf("raft index cache_dataset_on_device param only support true false")
}
return nil
}
func newRaftIVFFlatChecker() IndexChecker {
return &raftIVFFlatChecker{}
}