@@ -216,7 +216,7 @@ class Index {
216
216
}
217
217
}
218
218
219
- std::vector<std::vector<data_t >> GetDataReturnList (py::object ids_ = py::none()) {
219
+ std::vector<std::vector<data_t >> getDataReturnList (py::object ids_ = py::none()) {
220
220
std::vector<size_t > ids;
221
221
if (!ids_.is_none ()) {
222
222
py::array_t < size_t , py::array::c_style | py::array::forcecast > items (ids_);
@@ -235,6 +235,16 @@ class Index {
235
235
return data;
236
236
}
237
237
238
+ std::vector<unsigned int > getIdsList () {
239
+
240
+ std::vector<unsigned int > ids;
241
+
242
+ for (auto kv : appr_alg->label_lookup_ ) {
243
+ ids.push_back (kv.first );
244
+ }
245
+ return ids;
246
+ }
247
+
238
248
py::object knnQuery_return_numpy (py::object input, size_t k = 1 , int num_threads = -1 ) {
239
249
240
250
py::array_t < dist_t , py::array::c_style | py::array::forcecast > items (input);
@@ -360,7 +370,8 @@ PYBIND11_PLUGIN(hnswlib) {
360
370
py::arg (" ef_construction" )=200 , py::arg (" random_seed" )=100 )
361
371
.def (" knn_query" , &Index<float >::knnQuery_return_numpy, py::arg (" data" ), py::arg (" k" )=1 , py::arg (" num_threads" )=-1 )
362
372
.def (" add_items" , &Index<float >::addItems, py::arg (" data" ), py::arg (" ids" ) = py::none (), py::arg (" num_threads" )=-1 )
363
- .def (" get_items" , &Index<float , float >::GetDataReturnList, py::arg (" ids" ) = py::none ())
373
+ .def (" get_items" , &Index<float , float >::getDataReturnList, py::arg (" ids" ) = py::none ())
374
+ .def (" get_ids_list" , &Index<float >::getIdsList)
364
375
.def (" set_ef" , &Index<float >::set_ef, py::arg (" ef" ))
365
376
.def (" set_num_threads" , &Index<float >::set_num_threads, py::arg (" num_threads" ))
366
377
.def (" save_index" , &Index<float >::saveIndex, py::arg (" path_to_index" ))
0 commit comments