| 248 | } |
| 249 | |
| 250 | void batchInsert( |
| 251 | py::array_t<float> objects, |
| 252 | size_t numThreads = 16, |
| 253 | bool append = false, |
| 254 | bool refinement = false, |
| 255 | bool build = true, |
| 256 | bool debug = false |
| 257 | ) { |
| 258 | py::buffer_info info = objects.request(); |
| 259 | if (debug) { |
| 260 | std::cerr << info.shape.size() << ":" << info.shape[0] << ":" << info.shape[1] << std::endl; |
| 261 | } |
| 262 | if ((objects.flags() & py::detail::npy_api::constants::NPY_ARRAY_C_CONTIGUOUS_) == 0) { |
| 263 | std::stringstream msg; |
| 264 | msg << "ngtpy::batchInsert: Error! The array order is not C type. " << static_cast<int>(objects.flags()) |
| 265 | << ":" << static_cast<int>(py::detail::npy_api::constants::NPY_ARRAY_C_CONTIGUOUS_); |
| 266 | NGTThrowException(msg); |
| 267 | } |
| 268 | auto ptr = static_cast<float *>(info.ptr); |
| 269 | assert(info.shape.size() == 2); |
| 270 | NGT::Property prop; |
| 271 | getProperty(prop); |
| 272 | if (prop.dimension != info.shape[1]) { |
| 273 | std::stringstream msg; |
| 274 | msg << "ngtpy::insert: Error! dimensions are inconsitency. " << prop.dimension << ":" << info.shape[1]; |
| 275 | NGTThrowException(msg); |
| 276 | } |
| 277 | NGT::Index::append(ptr, info.shape[0], append, refinement); |
| 278 | if (build) { |
| 279 | NGT::Index::createIndex(numThreads); |
| 280 | } |
| 281 | numOfDistanceComputations = 0; |
| 282 | } |
| 283 | |
| 284 | int insert( |
| 285 | py::array_t<double> object, |
nothing calls this directly
no test coverage detected