Skip to content

Commit d07a3fa

Browse files
authored
Merge pull request #303 from junjiejiangjjj/empty-query
Fix empty query
2 parents 4039214 + 6679282 commit d07a3fa

6 files changed

Lines changed: 23 additions & 94 deletions

File tree

python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def parse_requirements(file_name: str) -> List[str]:
142142

143143

144144
setup(name='milvus-lite',
145-
version='2.5.1',
145+
version='2.5.2',
146146
description='A lightweight version of Milvus wrapped with Python.',
147147
author='Milvus Team',
148148
author_email='milvus-team@zilliz.com',

python/src/milvus_lite/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def start(self) -> bool:
9292
fcntl.lockf(self._lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
9393
start_env = {
9494
"LD_LIBRARY_PATH": str(self._bin_path) + ':' + os.environ.get('LD_LIBRARY_PATH', ''),
95-
"DYLD_LIBRARY_PATH": str(self._bin_path) + ':' + os.environ.get('LD_LIBRARY_PATH', '')
95+
"DYLD_LIBRARY_PATH": str(self._bin_path) + ':' + os.environ.get('DYLD_LIBRARY_PATH', '')
9696
}
9797
src_env = os.environ.copy()
9898
if "LD_LIBRARY_PATH" in src_env:

src/function/bm25_stat.h

Lines changed: 0 additions & 91 deletions
This file was deleted.

src/insert_task.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <tuple>
2323
#include <vector>
2424
#include "common.h"
25-
#include "function/bm25_stat.h"
2625
#include "function/function_executor.h"
2726
#include "log/Log.h"
2827
#include "pb/schema.pb.h"

src/segcore_wrapper.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,17 @@ SegcoreWrapper::Retrieve(const std::string& plan, RetrieveResult* result) {
198198
auto status = Status(::CreateRetrievePlanByExpr(
199199
collection_, plan.c_str(), plan.size(), &retrieve_plan.plan_));
200200
CHECK_STATUS(status, "Create retrieve plan failed, invalid expr");
201+
if (::GetRowCount(segment_) == 0) {
202+
milvus::proto::segcore::RetrieveResults empty_ret;
203+
auto serialized_results = empty_ret.SerializeAsString();
204+
result->retrieve_result_.proto_blob =
205+
new uint8_t[serialized_results.size()];
206+
std::memcpy(const_cast<void*>(result->retrieve_result_.proto_blob),
207+
serialized_results.data(),
208+
serialized_results.size());
209+
result->retrieve_result_.proto_size = serialized_results.size();
210+
return Status::Ok();
211+
}
201212
auto job = ::AsyncRetrieve({},
202213
segment_,
203214
retrieve_plan.plan_,

tests/test_query.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ def setUp(self):
2727
def tearDown(self):
2828
self.milvus_client.drop_collection(self.collection_name)
2929

30+
def test_query_empty(self):
31+
self.milvus_client.query(self.collection_name, limit=3)
32+
rows = [
33+
{'id': 1, 'vector': [0.0, 1], 'a': 100},
34+
]
35+
insert_result = self.milvus_client.insert(self.collection_name, rows)
36+
self.assertEqual(insert_result['insert_count'], 1)
37+
self.milvus_client.delete(self.collection_name, ids=[1])
38+
self.milvus_client.query(self.collection_name, limit=3)
39+
3040
def test_query(self):
3141
rows = [
3242
{'id': 1, 'vector': [0.0, 1], 'a': 100},

0 commit comments

Comments
 (0)