Skip to content

Commit

Permalink
Fix RHNSWPQ pqm divide by zero (milvus-io#18700)
Browse files Browse the repository at this point in the history
See also: milvus-io#18671

Signed-off-by: yangxuan <xuan.yang@zilliz.com>

Signed-off-by: yangxuan <xuan.yang@zilliz.com>
  • Loading branch information
XuanYang-cn authored Aug 18, 2022
1 parent cf1c590 commit a782ded
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 @@ -419,7 +419,7 @@ func (adapter *RHNSWPQConfAdapter) CheckTrain(params map[string]string) bool {
return false
}
pqm, err := strconv.Atoi(pqmStr)
if err != nil {
if err != nil || pqm == 0 {
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 @@ -461,6 +461,9 @@ func TestRHNSWPQConfAdapter_CheckTrain(t *testing.T) {
invalidParamsPQM := copyParams(validParams)
invalidParamsPQM[PQM] = "NAN"

invalidParamsPQMZero := copyParams(validParams)
invalidParamsPQMZero[PQM] = "0"

cases := []struct {
params map[string]string
want bool
Expand All @@ -473,6 +476,7 @@ func TestRHNSWPQConfAdapter_CheckTrain(t *testing.T) {
{invalidMParamsMax, false},
{invalidParamsWithoutPQM, false},
{invalidParamsPQM, false},
{invalidParamsPQMZero, false},
}

adapter := newRHNSWPQConfAdapter()
Expand Down

0 comments on commit a782ded

Please sign in to comment.