Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunjiangZhu committed Oct 24, 2019
1 parent dcca140 commit 129b72e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions python_bindings/nmslib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ struct IndexWrapper {
py::gil_scoped_release l;
index->Search(&rq, -1);
}
std::unique_ptr<RangeQuery<dist_t>> res(rq.Result());//->Clone()
return convertResult(res.get());
return convertResult_rq(rq.ResultSet());
}

py::object knnQueryBatch(py::object input, size_t k, int num_threads) {
Expand Down Expand Up @@ -197,6 +196,22 @@ struct IndexWrapper {
}
return py::make_tuple(ids, distances);
}

py::object convertResult_rq(std::set<const Object*> res) {
// Create numpy arrays for the output
size_t size = res->Size();
py::array_t<int> ids(size);
py::array_t<dist_t> distances(size);

std::set<const Object*>::iterator it = setOfStr.begin();
while (it != setOfStr.end())
{
ids.mutable_at(i) = it->id();
//distances.mutable_at(size) = res->at(i)->id();
it++;
}
return py::make_tuple(ids, distances);
}

const Object * readObject(py::object input, int id = 0) {
switch (data_type) {
Expand Down

0 comments on commit 129b72e

Please sign in to comment.