From 726e75c4d408b8ee59a75eb263f74aa893dbc797 Mon Sep 17 00:00:00 2001 From: chasingegg Date: Tue, 12 Nov 2024 10:41:58 +0800 Subject: [PATCH] enhance: let level param accepts more types Signed-off-by: chasingegg --- entity/genidx/genidx.go | 8 ++------ entity/indexes_search_param_gen.go | 11 +++-------- entity/indexes_search_param_gen_test.go | 20 +------------------- 3 files changed, 6 insertions(+), 33 deletions(-) diff --git a/entity/genidx/genidx.go b/entity/genidx/genidx.go index 4a4a63f3..bb737487 100644 --- a/entity/genidx/genidx.go +++ b/entity/genidx/genidx.go @@ -621,8 +621,8 @@ func main() { ConstructParams: []idxParam{}, SearchParams: []idxParam{ { - Name: "level", - ValidationRule: "[1, 9223372036854775807]", + Name: "level", + Type: "interface{}", }, }, ValidExamples: []string{ @@ -632,10 +632,6 @@ func main() { ValidSearchParams: []string{ "level = 1", }, - InvalidSearchParams: []string{ - "level = 0", - "level = -1", - }, }, { IdxName: "GPUIvfFlat", diff --git a/entity/indexes_search_param_gen.go b/entity/indexes_search_param_gen.go index 1c7efd21..124d2ccf 100755 --- a/entity/indexes_search_param_gen.go +++ b/entity/indexes_search_param_gen.go @@ -293,20 +293,15 @@ var _ SearchParam = &IndexAUTOINDEXSearchParam{} type IndexAUTOINDEXSearchParam struct { //auto generated fields baseSearchParams - level int + level interface{} } // NewIndexAUTOINDEXSearchParam create index search param func NewIndexAUTOINDEXSearchParam( - level int, + level interface{}, ) (*IndexAUTOINDEXSearchParam, error) { // auto generate parameters validation code, if any - if level < 1 { - return nil, errors.New("level has to be in range [1, 9223372036854775807]") - } - if level > 9223372036854775807 { - return nil, errors.New("level has to be in range [1, 9223372036854775807]") - } + sp := &IndexAUTOINDEXSearchParam{ baseSearchParams: newBaseSearchParams(), diff --git a/entity/indexes_search_param_gen_test.go b/entity/indexes_search_param_gen_test.go index 18c4d992..07897c65 100755 --- a/entity/indexes_search_param_gen_test.go +++ b/entity/indexes_search_param_gen_test.go @@ -336,7 +336,7 @@ func TestIndexDISKANNSearchParam(t *testing.T) { func TestIndexAUTOINDEXSearchParam(t *testing.T) { - var level int + var level interface{} t.Run("valid usage case", func(t *testing.T){ @@ -350,24 +350,6 @@ func TestIndexAUTOINDEXSearchParam(t *testing.T) { }) - t.Run("invalid usage case", func(t *testing.T){ - - level = 0 - idx0, err := NewIndexAUTOINDEXSearchParam( - level, - ) - assert.NotNil(t, err) - assert.Nil(t, idx0) - - level = -1 - idx1, err := NewIndexAUTOINDEXSearchParam( - level, - ) - assert.NotNil(t, err) - assert.Nil(t, idx1) - - }) - } func TestIndexGPUIvfFlatSearchParam(t *testing.T) {