| 161 | } |
| 162 | |
| 163 | void |
| 164 | SparseBuild(py::array_t<uint32_t> index_pointers, |
| 165 | py::array_t<uint32_t> indices, |
| 166 | py::array_t<float> values, |
| 167 | py::array_t<int64_t> ids) { |
| 168 | auto batch = BuildSparseVectorsFromCSR(index_pointers, indices, values); |
| 169 | |
| 170 | auto buf_id = ids.request(); |
| 171 | if (buf_id.ndim != 1) { |
| 172 | throw std::invalid_argument("all inputs must be 1-dimensional"); |
| 173 | } |
| 174 | if (batch.num_elements != buf_id.shape[0]) { |
| 175 | throw std::invalid_argument( |
| 176 | fmt::format("Length of 'ids'({}) must match number of vectors({})", |
| 177 | buf_id.shape[0], |
| 178 | batch.num_elements)); |
| 179 | } |
| 180 | |
| 181 | auto dataset = vsag::Dataset::Make(); |
| 182 | dataset->Owner(false) |
| 183 | ->NumElements(batch.num_elements) |
| 184 | ->Ids(ids.data()) |
| 185 | ->SparseVectors(batch.sparse_vectors.data()); |
| 186 | |
| 187 | index_->Build(dataset); |
| 188 | } |
| 189 | |
| 190 | py::object |
| 191 | KnnSearch(py::array_t<float> vector, size_t k, std::string& parameters) { |
nothing calls this directly
no test coverage detected