* Fix #5191

Signed-off-by: yhmo <yihua.mo@zilliz.com>
This commit is contained in:
groot 2021-05-28 11:34:00 +08:00 committed by GitHub
parent 3099039eef
commit ce0e75e6a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,11 +29,17 @@ class ServiceHandler(milvus_pb2_grpc.MilvusServiceServicer):
def _reduce(self, source_ids, ids, source_diss, diss, k, reverse):
sort_f = (lambda x, y: x >= y) if reverse else (lambda x, y: x <= y)
if len(ids) == 0:
return source_ids, source_diss
if len(source_ids) == 0:
return ids, diss
src_last = len(source_diss) - 1
if sort_f(source_diss[src_last], diss[0]):
if sort_f(source_diss[src_last], diss[0]) and len(source_ids) >= k:
return source_ids, source_diss
last = len(diss) - 1
if sort_f(diss[last], source_diss[0]):
if sort_f(diss[last], source_diss[0]) and len(ids) >= k:
return ids, diss
source_diss.extend(diss)