diff --git a/internal/querynodev2/server.go b/internal/querynodev2/server.go index ffca576277..cb22e5878d 100644 --- a/internal/querynodev2/server.go +++ b/internal/querynodev2/server.go @@ -493,10 +493,10 @@ func (node *QueryNode) initHook() error { if !ok { return fmt.Errorf("fail to convert the `Hook` interface") } - if err = hoo.Init(paramtable.Get().HookCfg.QueryNodePluginConfig.GetValue()); err != nil { + if err = hoo.Init(paramtable.Get().AutoIndexConfig.AutoIndexSearchConfig.GetValue()); err != nil { return fmt.Errorf("fail to init configs for the hook, error: %s", err.Error()) } - if err = hoo.InitTuningConfig(paramtable.Get().HookCfg.QueryNodePluginTuningConfig.GetValue()); err != nil { + if err = hoo.InitTuningConfig(paramtable.Get().AutoIndexConfig.AutoIndexTuningConfig.GetValue()); err != nil { return fmt.Errorf("fail to init tuning configs for the hook, error: %s", err.Error()) } @@ -515,8 +515,8 @@ func (node *QueryNode) handleQueryHookEvent() { } } onEvent2 := func(event *config.Event) { - if node.queryHook != nil && strings.HasPrefix(event.Key, paramtable.Get().HookCfg.QueryNodePluginTuningConfig.KeyPrefix) { - realKey := strings.TrimPrefix(event.Key, paramtable.Get().HookCfg.QueryNodePluginTuningConfig.KeyPrefix) + if node.queryHook != nil && strings.HasPrefix(event.Key, paramtable.Get().AutoIndexConfig.AutoIndexTuningConfig.KeyPrefix) { + realKey := strings.TrimPrefix(event.Key, paramtable.Get().AutoIndexConfig.AutoIndexTuningConfig.KeyPrefix) if event.EventType == config.CreateType || event.EventType == config.UpdateType { if err := node.queryHook.InitTuningConfig(map[string]string{realKey: event.Value}); err != nil { log.Warn("failed to refresh hook tuning config", zap.Error(err)) @@ -528,7 +528,7 @@ func (node *QueryNode) handleQueryHookEvent() { } } } - paramtable.Get().Watch(paramtable.Get().HookCfg.QueryNodePluginConfig.Key, config.NewHandler("queryHook", onEvent)) + paramtable.Get().Watch(paramtable.Get().AutoIndexConfig.AutoIndexSearchConfig.Key, config.NewHandler("queryHook", onEvent)) - paramtable.Get().WatchKeyPrefix(paramtable.Get().HookCfg.QueryNodePluginTuningConfig.KeyPrefix, config.NewHandler("queryHook2", onEvent2)) + paramtable.Get().WatchKeyPrefix(paramtable.Get().AutoIndexConfig.AutoIndexTuningConfig.KeyPrefix, config.NewHandler("queryHook2", onEvent2)) } diff --git a/pkg/util/paramtable/autoindex_param.go b/pkg/util/paramtable/autoindex_param.go index 0017585ced..9fff408ac4 100644 --- a/pkg/util/paramtable/autoindex_param.go +++ b/pkg/util/paramtable/autoindex_param.go @@ -31,10 +31,12 @@ import ( type autoIndexConfig struct { Enable ParamItem `refreshable:"true"` - IndexParams ParamItem `refreshable:"true"` - ExtraParams ParamItem `refreshable:"true"` - IndexType ParamItem `refreshable:"true"` - AutoIndexTypeName ParamItem `refreshable:"true"` + IndexParams ParamItem `refreshable:"true"` + ExtraParams ParamItem `refreshable:"true"` + IndexType ParamItem `refreshable:"true"` + AutoIndexTypeName ParamItem `refreshable:"true"` + AutoIndexSearchConfig ParamItem `refreshable:"true"` + AutoIndexTuningConfig ParamGroup `refreshable:"true"` } func (p *autoIndexConfig) init(base *BaseTable) { @@ -77,6 +79,18 @@ func (p *autoIndexConfig) init(base *BaseTable) { } p.AutoIndexTypeName.Init(base.mgr) + p.AutoIndexSearchConfig = ParamItem{ + Key: "autoindex.params.search", + Version: "2.2.0", + } + p.AutoIndexSearchConfig.Init(base.mgr) + + p.AutoIndexTuningConfig = ParamGroup{ + KeyPrefix: "autoindex.params.tuning.", + Version: "2.3.0", + } + p.AutoIndexTuningConfig.Init(base.mgr) + p.panicIfNotValidAndSetDefaultMetricType(base.mgr) } diff --git a/pkg/util/paramtable/autoindex_param_test.go b/pkg/util/paramtable/autoindex_param_test.go index a4fa5387d0..762e7b517b 100644 --- a/pkg/util/paramtable/autoindex_param_test.go +++ b/pkg/util/paramtable/autoindex_param_test.go @@ -66,33 +66,6 @@ func TestAutoIndexParams_build(t *testing.T) { assert.Equal(t, "IVF_FLAT", CParams.AutoIndexConfig.IndexType.GetValue()) assert.Equal(t, strconv.Itoa(map2["nlist"].(int)), CParams.AutoIndexConfig.IndexParams.GetAsJSONMap()["nlist"]) }) - - // t.Run("test parseBuildParams miss total", func(t *testing.T) { - // defer func() { - // if r := recover(); r == nil { - // t.Errorf("The code did not panic") - // } - // }() - // CParams.Save(CParams.AutoIndexConfig.IndexParams.Key, "") - // - // }) - // - // t.Run("test parseBuildParams miss index_type", func(t *testing.T) { - // defer func() { - // if r := recover(); r == nil { - // t.Errorf("The code did not panic") - // } - // }() - // var err error - // map1 := map[string]any{ - // "M": 48, - // "efConstruction": 500, - // } - // var jsonStrBytes []byte - // jsonStrBytes, err = json.Marshal(map1) - // assert.NoError(t, err) - // CParams.Save(CParams.AutoIndexConfig.IndexParams.Key, string(jsonStrBytes)) - // }) } func Test_autoIndexConfig_panicIfNotValid(t *testing.T) { diff --git a/pkg/util/paramtable/component_param.go b/pkg/util/paramtable/component_param.go index ab9ab770ea..cc9b82800b 100644 --- a/pkg/util/paramtable/component_param.go +++ b/pkg/util/paramtable/component_param.go @@ -118,7 +118,7 @@ func (p *ComponentParam) init() { p.IndexNodeCfg.init(&p.BaseTable) p.HTTPCfg.init(&p.BaseTable) p.LogCfg.init(&p.BaseTable) - p.HookCfg.init(&p.BaseTable) + p.HookCfg.init() p.RootCoordGrpcServerCfg.Init("rootCoord", &p.BaseTable) p.ProxyGrpcServerCfg.Init("proxy", &p.BaseTable) diff --git a/pkg/util/paramtable/hook_config.go b/pkg/util/paramtable/hook_config.go index 5995cabe1a..1fb39ecac0 100644 --- a/pkg/util/paramtable/hook_config.go +++ b/pkg/util/paramtable/hook_config.go @@ -11,13 +11,11 @@ const hookYamlFile = "hook.yaml" type hookConfig struct { hookBase *BaseTable - SoPath ParamItem `refreshable:"false"` - SoConfig ParamGroup `refreshable:"true"` - QueryNodePluginConfig ParamItem `refreshable:"true"` - QueryNodePluginTuningConfig ParamGroup `refreshable:"true"` + SoPath ParamItem `refreshable:"false"` + SoConfig ParamGroup `refreshable:"true"` } -func (h *hookConfig) init(base *BaseTable) { +func (h *hookConfig) init() { hookBase := &BaseTable{YamlFiles: []string{hookYamlFile}} hookBase.init(2) h.hookBase = hookBase @@ -36,18 +34,6 @@ func (h *hookConfig) init(base *BaseTable) { Version: "2.2.0", } h.SoConfig.Init(hookBase.mgr) - - h.QueryNodePluginConfig = ParamItem{ - Key: "autoindex.params.search", - Version: "2.3.0", - } - h.QueryNodePluginConfig.Init(base.mgr) - - h.QueryNodePluginTuningConfig = ParamGroup{ - KeyPrefix: "autoindex.params.tuning.", - Version: "2.3.0", - } - h.QueryNodePluginTuningConfig.Init(base.mgr) } func (h *hookConfig) WatchHookWithPrefix(ident string, keyPrefix string, onEvent func(*config.Event)) {