Correct empty retrieve result handling (#11219)

Signed-off-by: yudong.cai <yudong.cai@zilliz.com>
pull/11248/head
Cai Yudong 2021-11-04 18:08:32 +08:00 committed by GitHub
parent 0ae2ef51c7
commit 0fac38000c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -2291,7 +2291,7 @@ func mergeRetrieveResults(retrieveResults []*internalpb.RetrieveResults) (*milvu
// merge results and remove duplicates
for _, rr := range retrieveResults {
// skip empty result, it will break merge result
if rr == nil || rr.Ids == nil {
if rr == nil || rr.Ids == nil || rr.Ids.GetIntId() == nil || len(rr.Ids.GetIntId().Data) == 0 {
continue
}
@ -2302,7 +2302,7 @@ func mergeRetrieveResults(retrieveResults []*internalpb.RetrieveResults) (*milvu
}
if len(ret.FieldsData) != len(rr.FieldsData) {
return nil, fmt.Errorf("mismatch FieldData in RetrieveResults")
return nil, fmt.Errorf("mismatch FieldData in proxy RetrieveResults, expect %d get %d", len(ret.FieldsData), len(rr.FieldsData))
}
for i, id := range rr.Ids.GetIntId().GetData() {
@ -2319,6 +2319,12 @@ func mergeRetrieveResults(retrieveResults []*internalpb.RetrieveResults) (*milvu
log.Debug("skip duplicated query result", zap.Int64("count", skipDupCnt))
}
if ret == nil {
ret = &milvuspb.QueryResults{
FieldsData: []*schemapb.FieldData{},
}
}
return ret, nil
}

View File

@ -1216,7 +1216,7 @@ func mergeRetrieveResults(retrieveResults []*segcorepb.RetrieveResults) (*segcor
// merge results and remove duplicates
for _, rr := range retrieveResults {
// skip empty result, it will break merge result
if rr == nil || len(rr.Offset) == 0 {
if rr == nil || rr.Offset == nil || len(rr.Offset) == 0 {
continue
}
@ -1234,7 +1234,7 @@ func mergeRetrieveResults(retrieveResults []*segcorepb.RetrieveResults) (*segcor
}
if len(ret.FieldsData) != len(rr.FieldsData) {
return nil, fmt.Errorf("mismatch FieldData in RetrieveResults")
return nil, fmt.Errorf("mismatch FieldData in querynode RetrieveResults, expect %d get %d", len(ret.FieldsData), len(rr.FieldsData))
}
dstIds := ret.Ids.GetIntId()