mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 19:08:30 +08:00
51fe4743f1
this hints the user passed invalid metric type in error message, so users could know what's wrong Signed-off-by: yah01 <yang.cen@zilliz.com>
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package indexparamcheck
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
|
"github.com/milvus-io/milvus/pkg/common"
|
|
)
|
|
|
|
type binaryVectorBaseChecker struct {
|
|
baseChecker
|
|
}
|
|
|
|
func (c binaryVectorBaseChecker) staticCheck(params map[string]string) error {
|
|
if !CheckStrByValues(params, Metric, BinIDMapMetrics) {
|
|
return fmt.Errorf("metric type %s not found or not supported, supported: %v", params[Metric], BinIDMapMetrics)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (c binaryVectorBaseChecker) CheckTrain(params map[string]string) error {
|
|
if err := c.baseChecker.CheckTrain(params); err != nil {
|
|
return err
|
|
}
|
|
|
|
return c.staticCheck(params)
|
|
}
|
|
|
|
func (c binaryVectorBaseChecker) CheckValidDataType(dType schemapb.DataType) error {
|
|
if dType != schemapb.DataType_BinaryVector {
|
|
return fmt.Errorf("binary vector is only supported")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c binaryVectorBaseChecker) SetDefaultMetricTypeIfNotExist(params map[string]string) {
|
|
setDefaultIfNotExist(params, common.MetricTypeKey, BinaryVectorDefaultMetricType)
|
|
}
|
|
|
|
func newBinaryVectorBaseChecker() IndexChecker {
|
|
return &binaryVectorBaseChecker{}
|
|
}
|