Make TopK Limit configurable (#21151)

Signed-off-by: Enwei Jiao <enwei.jiao@zilliz.com>

Signed-off-by: Enwei Jiao <enwei.jiao@zilliz.com>
This commit is contained in:
Enwei Jiao 2022-12-15 14:03:22 +08:00 committed by GitHub
parent 0011b65338
commit e6374901f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 9 deletions

View File

@ -58,12 +58,6 @@ const (
// DefaultStringIndexType name of default index type for varChar/string field
DefaultStringIndexType = "Trie"
// Search limit, which applies on:
// maximum # of results to return (topK), and
// maximum # of search requests (nq).
// Check https://milvus.io/docs/limitations.md for more details.
searchCountLimit = 16384
)
var logger = log.L().WithOptions(zap.Fields(zap.String("role", typeutil.ProxyRole)))
@ -85,9 +79,8 @@ func isNumber(c uint8) bool {
}
func validateLimit(limit int64) error {
// TODO make this configurable
if limit <= 0 || limit > searchCountLimit {
return fmt.Errorf("should be in range [1, %d], but got %d", searchCountLimit, limit)
if limit <= 0 || limit > Params.CommonCfg.TopKLimit.GetAsInt64() {
return fmt.Errorf("should be in range [1, %d], but got %d", Params.CommonCfg.TopKLimit.GetAsInt64(), limit)
}
return nil
}

View File

@ -145,6 +145,12 @@ type commonConfig struct {
GracefulTime ParamItem
GracefulStopTimeout ParamItem // unit: s
// Search limit, which applies on:
// maximum # of results to return (topK), and
// maximum # of search requests (nq).
// Check https://milvus.io/docs/limitations.md for more details.
TopKLimit ParamItem
StorageType ParamItem
SimdType ParamItem
@ -418,6 +424,13 @@ func (p *commonConfig) init(base *BaseTable) {
}
p.GracefulStopTimeout.Init(base.mgr)
p.TopKLimit = ParamItem{
Key: "common.topKLimit",
Version: "2.2.1",
DefaultValue: "16384",
}
p.TopKLimit.Init(base.mgr)
p.BeamWidthRatio = ParamItem{
Key: "common.DiskIndex.BeamWidthRatio",
Version: "2.0.0",