mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-28 22:45:26 +08:00
add sparse float vector support to different milvus components, including proxy, data node to receive and write sparse float vectors to binlog, query node to handle search requests, index node to build index for sparse float column, etc. https://github.com/milvus-io/milvus/issues/29419 --------- Signed-off-by: Buqian Zheng <zhengbuqian@gmail.com>
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package indexparamcheck
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
|
"github.com/milvus-io/milvus/pkg/common"
|
|
)
|
|
|
|
// sparse vector don't check for dim, but baseChecker does, thus not including baseChecker
|
|
type sparseFloatVectorBaseChecker struct{}
|
|
|
|
func (c sparseFloatVectorBaseChecker) StaticCheck(params map[string]string) error {
|
|
if !CheckStrByValues(params, Metric, SparseMetrics) {
|
|
return fmt.Errorf("metric type not found or not supported, supported: %v", SparseMetrics)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (c sparseFloatVectorBaseChecker) CheckTrain(params map[string]string) error {
|
|
dropRatioBuildStr, exist := params[SparseDropRatioBuild]
|
|
if exist {
|
|
dropRatioBuild, err := strconv.ParseFloat(dropRatioBuildStr, 64)
|
|
if err != nil || dropRatioBuild < 0 || dropRatioBuild >= 1 {
|
|
return fmt.Errorf("invalid drop_ratio_build: %s, must be in range [0, 1)", dropRatioBuildStr)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (c sparseFloatVectorBaseChecker) CheckValidDataType(dType schemapb.DataType) error {
|
|
if dType != schemapb.DataType_SparseFloatVector {
|
|
return fmt.Errorf("only sparse float vector is supported for the specified index tpye")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c sparseFloatVectorBaseChecker) SetDefaultMetricTypeIfNotExist(params map[string]string) {
|
|
setDefaultIfNotExist(params, common.MetricTypeKey, SparseFloatVectorDefaultMetricType)
|
|
}
|
|
|
|
func newSparseFloatVectorBaseChecker() IndexChecker {
|
|
return &sparseFloatVectorBaseChecker{}
|
|
}
|