Skip to content

Commit

Permalink
Fix indexcheck division by zero bug (milvus-io#18482)
Browse files Browse the repository at this point in the history
See also: milvus-io#18479

Signed-off-by: yangxuan <xuan.yang@zilliz.com>
  • Loading branch information
XuanYang-cn authored Aug 2, 2022
1 parent efc5406 commit 43c7c1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/util/indexparamcheck/conf_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (adapter *IVFPQConfAdapter) checkPQParams(params map[string]string) bool {
return false
}
m, err := strconv.Atoi(mStr)
if err != nil { // invalid m
if err != nil || m == 0 { // invalid m
return false
}

Expand Down
4 changes: 4 additions & 0 deletions internal/util/indexparamcheck/conf_adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ func TestIVFPQConfAdapter_CheckTrain(t *testing.T) {
invalidParamsM[IndexMode] = GPUMode
invalidParamsM[DIM] = strconv.Itoa(65536)

invalidParamsMzero := copyParams(validParams)
invalidParamsMzero[IVFM] = "0"

cases := []struct {
params map[string]string
want bool
Expand All @@ -152,6 +155,7 @@ func TestIVFPQConfAdapter_CheckTrain(t *testing.T) {
{invalidParamsWithoutIVF, false},
{invalidParamsIVF, false},
{invalidParamsM, false},
{invalidParamsMzero, false},
}

adapter := newIVFPQConfAdapter()
Expand Down

0 comments on commit 43c7c1f

Please sign in to comment.