MCPcopy Create free account
hub / github.com/antgroup/vsag / SparseBuild

Method SparseBuild

python_bindings/binding.cpp:163–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 6

SparseVectorsMethod · 0.45
IdsMethod · 0.45
NumElementsMethod · 0.45
OwnerMethod · 0.45
BuildMethod · 0.45

Tested by

no test coverage detected