mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
Cherry-pick from master pr: #38791 #38812 #38940 #39515 #39580 #39662 #39665 #39751 --------- Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
80 lines
1.5 KiB
Go
80 lines
1.5 KiB
Go
package index
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const (
|
|
dropRatio = `drop_ratio_build`
|
|
)
|
|
|
|
var _ Index = sparseInvertedIndex{}
|
|
|
|
// IndexSparseInverted index type for SPARSE_INVERTED_INDEX
|
|
type sparseInvertedIndex struct {
|
|
baseIndex
|
|
dropRatio float64
|
|
}
|
|
|
|
func (idx sparseInvertedIndex) Params() map[string]string {
|
|
return map[string]string{
|
|
MetricTypeKey: string(idx.metricType),
|
|
IndexTypeKey: string(SparseInverted),
|
|
dropRatio: fmt.Sprintf("%v", idx.dropRatio),
|
|
}
|
|
}
|
|
|
|
func NewSparseInvertedIndex(metricType MetricType, dropRatio float64) Index {
|
|
return sparseInvertedIndex{
|
|
baseIndex: baseIndex{
|
|
metricType: metricType,
|
|
indexType: SparseInverted,
|
|
},
|
|
|
|
dropRatio: dropRatio,
|
|
}
|
|
}
|
|
|
|
var _ Index = sparseWANDIndex{}
|
|
|
|
type sparseWANDIndex struct {
|
|
baseIndex
|
|
dropRatio float64
|
|
}
|
|
|
|
func (idx sparseWANDIndex) Params() map[string]string {
|
|
return map[string]string{
|
|
MetricTypeKey: string(idx.metricType),
|
|
IndexTypeKey: string(SparseWAND),
|
|
dropRatio: fmt.Sprintf("%v", idx.dropRatio),
|
|
}
|
|
}
|
|
|
|
// IndexSparseWAND index type for SPARSE_WAND, weak-and
|
|
func NewSparseWANDIndex(metricType MetricType, dropRatio float64) Index {
|
|
return sparseWANDIndex{
|
|
baseIndex: baseIndex{
|
|
metricType: metricType,
|
|
indexType: SparseWAND,
|
|
},
|
|
|
|
dropRatio: dropRatio,
|
|
}
|
|
}
|
|
|
|
type sparseAnnParam struct {
|
|
baseAnnParam
|
|
}
|
|
|
|
func NewSparseAnnParam() sparseAnnParam {
|
|
return sparseAnnParam{
|
|
baseAnnParam: baseAnnParam{
|
|
params: make(map[string]any),
|
|
},
|
|
}
|
|
}
|
|
|
|
func (b sparseAnnParam) WithDropRatio(dropRatio float64) {
|
|
b.WithExtraParam("drop_ratio_search", dropRatio)
|
|
}
|