Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix merge result #2463

Merged
merged 3 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions core/src/scheduler/JobMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,8 @@ JobMgr::worker_function() {
// TODO(zhiru): if the job is search by ids, pass any task where the ids don't exist
auto search_job = std::dynamic_pointer_cast<SearchJob>(job);
if (search_job != nullptr) {
scheduler::ResultIds ids(search_job->nq() * search_job->topk(), -1);
scheduler::ResultDistances distances(search_job->nq() * search_job->topk(),
std::numeric_limits<float>::max());
search_job->GetResultIds() = ids;
search_job->GetResultDistances() = distances;
search_job->GetResultIds().resize(search_job->nq(), -1);
search_job->GetResultDistances().resize(search_job->nq(), std::numeric_limits<float>::max());

if (search_job->vectors().float_data_.empty() && search_job->vectors().binary_data_.empty() &&
!search_job->vectors().id_array_.empty()) {
Expand Down
17 changes: 2 additions & 15 deletions core/src/scheduler/task/SearchTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,7 @@ XSearchTask::Execute() {
auto spec_k = file_->row_count_ < topk ? file_->row_count_ : topk;
if (spec_k == 0) {
LOG_ENGINE_WARNING_ << "Searching in an empty file. file location = " << file_->location_;
}

{
} else {
std::unique_lock<std::mutex> lock(search_job->mutex());
search_job->vector_count() = nq;
XSearchTask::MergeTopkToResultSet(output_ids, output_distance, spec_k, nq, topk, ascending_reduce,
Expand Down Expand Up @@ -315,19 +313,8 @@ XSearchTask::Execute() {
if (spec_k == 0) {
LOG_ENGINE_WARNING_ << LogOut("[%s][%ld] Searching in an empty file. file location = %s", "search", 0,
file_->location_.c_str());
}

{
} else {
std::unique_lock<std::mutex> lock(search_job->mutex());

if (search_job->GetResultIds().size() > spec_k) {
if (search_job->GetResultIds().front() == -1) {
// initialized results set
search_job->GetResultIds().resize(spec_k * nq);
search_job->GetResultDistances().resize(spec_k * nq);
}
}

XSearchTask::MergeTopkToResultSet(output_ids, output_distance, spec_k, nq, topk, ascending_reduce,
search_job->GetResultIds(), search_job->GetResultDistances());
}
Expand Down
6 changes: 1 addition & 5 deletions core/unittest/db/test_delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,7 @@ TEST_F(DeleteTest, delete_single_vector) {
milvus::engine::ResultDistances result_distances;
stat = db_->Query(dummy_context_,
collection_info.collection_id_, tags, topk, json_params, xb, result_ids, result_distances);
ASSERT_TRUE(result_ids.empty());
ASSERT_TRUE(result_distances.empty());
// ASSERT_EQ(result_ids[0], -1);
// ASSERT_LT(result_distances[0], 1e-4);
// ASSERT_EQ(result_distances[0], std::numeric_limits<float>::max());
ASSERT_TRUE(result_ids.empty() || (result_ids[0] == -1));
}

TEST_F(DeleteTest, delete_add_create_index) {
Expand Down
10 changes: 4 additions & 6 deletions tests/milvus_python_test/entity/test_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_delete_vector_search(self, connect, collection, get_simple_index):
status, res = connect.search(collection, top_k, vector, params=search_param)
logging.getLogger().info(res)
assert status.OK()
assert len(res) == 0
assert len(res[0]) == 0

def test_delete_vector_multi_same_ids(self, connect, collection, get_simple_index):
'''
Expand All @@ -83,7 +83,7 @@ def test_delete_vector_multi_same_ids(self, connect, collection, get_simple_inde
status, res = connect.search(collection, top_k, [vectors[0]], params=search_param)
logging.getLogger().info(res)
assert status.OK()
assert len(res) == 0
assert len(res[0]) == 0

def test_delete_vector_collection_count(self, connect, collection):
'''
Expand Down Expand Up @@ -327,7 +327,7 @@ def test_delete_vectors_after_index_created_search(self, connect, collection, ge
status, res = connect.search(collection, top_k, vector, params=search_param)
logging.getLogger().info(res)
assert status.OK()
assert len(res) == 0
assert len(res[0]) == 0

def test_insert_delete_vector(self, connect, collection, get_simple_index):
'''
Expand Down Expand Up @@ -399,9 +399,7 @@ def test_delete_vector_search(self, connect, jac_collection, get_simple_index):
status, res = connect.search(jac_collection, top_k, vector, params=search_param)
logging.getLogger().info(res)
assert status.OK()
assert len(res) == 0
assert status.OK()
assert len(res) == 0
assert len(res[0]) == 0

# TODO: soft delete
def test_delete_vector_collection_count(self, connect, jac_collection):
Expand Down