fix: autoindex panic with flat index type (#29071) (#29072)

issue: https://github.com/milvus-io/milvus/issues/29048
pr: https://github.com/milvus-io/milvus/pull/29071

---------

Signed-off-by: longjiquan <jiquan.long@zilliz.com>
pull/29153/head
Jiquan Long 2023-12-12 22:08:45 +08:00 committed by GitHub
parent 286dce0d3a
commit 00e6160848
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

View File

@ -4,6 +4,10 @@ type flatChecker struct {
floatVectorBaseChecker
}
func (c flatChecker) StaticCheck(m map[string]string) error {
return c.staticCheck(m)
}
func newFlatChecker() IndexChecker {
return &flatChecker{}
}

View File

@ -62,3 +62,40 @@ func Test_flatChecker_CheckTrain(t *testing.T) {
}
}
}
func Test_flatChecker_StaticCheck(t *testing.T) {
cases := []struct {
params map[string]string
errIsNil bool
}{
{
// metrics not found.
params: map[string]string{},
errIsNil: false,
},
{
// invalid metric.
params: map[string]string{
Metric: metric.HAMMING,
},
errIsNil: false,
},
{
// normal case.
params: map[string]string{
Metric: metric.L2,
},
errIsNil: true,
},
}
c := newFlatChecker()
for _, test := range cases {
err := c.StaticCheck(test.params)
if test.errIsNil {
assert.NoError(t, err)
} else {
assert.Error(t, err)
}
}
}