milvus/pkg/util/indexparamcheck/float_vector_base_checker.go
Xu Tong 9166011c4a
Add float16 vector (#25852)
Signed-off-by: Writer-X <1256866856@qq.com>
2023-09-08 10:03:16 +08:00

46 lines
1.1 KiB
Go

package indexparamcheck
import (
"fmt"
"github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
)
type floatVectorBaseChecker struct {
baseChecker
}
func (c floatVectorBaseChecker) staticCheck(params map[string]string) error {
if !CheckStrByValues(params, Metric, METRICS) {
return fmt.Errorf("metric type not found or not supported, supported: %v", METRICS)
}
return nil
}
func (c floatVectorBaseChecker) CheckTrain(params map[string]string) error {
if err := c.baseChecker.CheckTrain(params); err != nil {
return err
}
return c.staticCheck(params)
}
func (c floatVectorBaseChecker) CheckValidDataType(dType schemapb.DataType) error {
if dType == schemapb.DataType_FloatVector || dType == schemapb.DataType_Float16Vector {
return nil
} else {
return fmt.Errorf("float or float16 vector are only supported")
}
}
func (c floatVectorBaseChecker) SetDefaultMetricTypeIfNotExist(params map[string]string) {
setDefaultIfNotExist(params, common.MetricTypeKey, FloatVectorDefaultMetricType)
}
func newFloatVectorBaseChecker() IndexChecker {
return &floatVectorBaseChecker{}
}