mirror of https://github.com/milvus-io/milvus.git
Make autoindex config clean (#26732)
Signed-off-by: chasingegg <chao.gao@zilliz.com>pull/26746/head
parent
41d37409e9
commit
7e36f819b4
|
@ -493,10 +493,10 @@ func (node *QueryNode) initHook() error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("fail to convert the `Hook` interface")
|
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())
|
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())
|
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) {
|
onEvent2 := func(event *config.Event) {
|
||||||
if node.queryHook != nil && strings.HasPrefix(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().HookCfg.QueryNodePluginTuningConfig.KeyPrefix)
|
realKey := strings.TrimPrefix(event.Key, paramtable.Get().AutoIndexConfig.AutoIndexTuningConfig.KeyPrefix)
|
||||||
if event.EventType == config.CreateType || event.EventType == config.UpdateType {
|
if event.EventType == config.CreateType || event.EventType == config.UpdateType {
|
||||||
if err := node.queryHook.InitTuningConfig(map[string]string{realKey: event.Value}); err != nil {
|
if err := node.queryHook.InitTuningConfig(map[string]string{realKey: event.Value}); err != nil {
|
||||||
log.Warn("failed to refresh hook tuning config", zap.Error(err))
|
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))
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,12 @@ import (
|
||||||
type autoIndexConfig struct {
|
type autoIndexConfig struct {
|
||||||
Enable ParamItem `refreshable:"true"`
|
Enable ParamItem `refreshable:"true"`
|
||||||
|
|
||||||
IndexParams ParamItem `refreshable:"true"`
|
IndexParams ParamItem `refreshable:"true"`
|
||||||
ExtraParams ParamItem `refreshable:"true"`
|
ExtraParams ParamItem `refreshable:"true"`
|
||||||
IndexType ParamItem `refreshable:"true"`
|
IndexType ParamItem `refreshable:"true"`
|
||||||
AutoIndexTypeName ParamItem `refreshable:"true"`
|
AutoIndexTypeName ParamItem `refreshable:"true"`
|
||||||
|
AutoIndexSearchConfig ParamItem `refreshable:"true"`
|
||||||
|
AutoIndexTuningConfig ParamGroup `refreshable:"true"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *autoIndexConfig) init(base *BaseTable) {
|
func (p *autoIndexConfig) init(base *BaseTable) {
|
||||||
|
@ -77,6 +79,18 @@ func (p *autoIndexConfig) init(base *BaseTable) {
|
||||||
}
|
}
|
||||||
p.AutoIndexTypeName.Init(base.mgr)
|
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)
|
p.panicIfNotValidAndSetDefaultMetricType(base.mgr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,33 +66,6 @@ func TestAutoIndexParams_build(t *testing.T) {
|
||||||
assert.Equal(t, "IVF_FLAT", CParams.AutoIndexConfig.IndexType.GetValue())
|
assert.Equal(t, "IVF_FLAT", CParams.AutoIndexConfig.IndexType.GetValue())
|
||||||
assert.Equal(t, strconv.Itoa(map2["nlist"].(int)), CParams.AutoIndexConfig.IndexParams.GetAsJSONMap()["nlist"])
|
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) {
|
func Test_autoIndexConfig_panicIfNotValid(t *testing.T) {
|
||||||
|
|
|
@ -118,7 +118,7 @@ func (p *ComponentParam) init() {
|
||||||
p.IndexNodeCfg.init(&p.BaseTable)
|
p.IndexNodeCfg.init(&p.BaseTable)
|
||||||
p.HTTPCfg.init(&p.BaseTable)
|
p.HTTPCfg.init(&p.BaseTable)
|
||||||
p.LogCfg.init(&p.BaseTable)
|
p.LogCfg.init(&p.BaseTable)
|
||||||
p.HookCfg.init(&p.BaseTable)
|
p.HookCfg.init()
|
||||||
|
|
||||||
p.RootCoordGrpcServerCfg.Init("rootCoord", &p.BaseTable)
|
p.RootCoordGrpcServerCfg.Init("rootCoord", &p.BaseTable)
|
||||||
p.ProxyGrpcServerCfg.Init("proxy", &p.BaseTable)
|
p.ProxyGrpcServerCfg.Init("proxy", &p.BaseTable)
|
||||||
|
|
|
@ -11,13 +11,11 @@ const hookYamlFile = "hook.yaml"
|
||||||
type hookConfig struct {
|
type hookConfig struct {
|
||||||
hookBase *BaseTable
|
hookBase *BaseTable
|
||||||
|
|
||||||
SoPath ParamItem `refreshable:"false"`
|
SoPath ParamItem `refreshable:"false"`
|
||||||
SoConfig ParamGroup `refreshable:"true"`
|
SoConfig ParamGroup `refreshable:"true"`
|
||||||
QueryNodePluginConfig ParamItem `refreshable:"true"`
|
|
||||||
QueryNodePluginTuningConfig ParamGroup `refreshable:"true"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *hookConfig) init(base *BaseTable) {
|
func (h *hookConfig) init() {
|
||||||
hookBase := &BaseTable{YamlFiles: []string{hookYamlFile}}
|
hookBase := &BaseTable{YamlFiles: []string{hookYamlFile}}
|
||||||
hookBase.init(2)
|
hookBase.init(2)
|
||||||
h.hookBase = hookBase
|
h.hookBase = hookBase
|
||||||
|
@ -36,18 +34,6 @@ func (h *hookConfig) init(base *BaseTable) {
|
||||||
Version: "2.2.0",
|
Version: "2.2.0",
|
||||||
}
|
}
|
||||||
h.SoConfig.Init(hookBase.mgr)
|
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)) {
|
func (h *hookConfig) WatchHookWithPrefix(ident string, keyPrefix string, onEvent func(*config.Event)) {
|
||||||
|
|
Loading…
Reference in New Issue