2023-05-06 10:40:39 +08:00
|
|
|
package indexparamcheck
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2023-05-29 20:35:28 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/common"
|
|
|
|
|
2023-06-09 01:28:37 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
2023-05-06 10:40:39 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type binaryVectorBaseChecker struct {
|
|
|
|
baseChecker
|
|
|
|
}
|
|
|
|
|
2023-05-29 20:35:28 +08:00
|
|
|
func (c binaryVectorBaseChecker) staticCheck(params map[string]string) error {
|
2023-05-06 10:40:39 +08:00
|
|
|
if !CheckStrByValues(params, Metric, BinIDMapMetrics) {
|
|
|
|
return fmt.Errorf("metric type not found or not supported, supported: %v", BinIDMapMetrics)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-05-29 20:35:28 +08:00
|
|
|
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 {
|
2023-05-06 10:40:39 +08:00
|
|
|
if dType != schemapb.DataType_BinaryVector {
|
|
|
|
return fmt.Errorf("binary vector is only supported")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-05-29 20:35:28 +08:00
|
|
|
func (c binaryVectorBaseChecker) SetDefaultMetricTypeIfNotExist(params map[string]string) {
|
|
|
|
setDefaultIfNotExist(params, common.MetricTypeKey, BinaryVectorDefaultMetricType)
|
|
|
|
}
|
|
|
|
|
2023-05-06 10:40:39 +08:00
|
|
|
func newBinaryVectorBaseChecker() IndexChecker {
|
|
|
|
return &binaryVectorBaseChecker{}
|
|
|
|
}
|