-
Notifications
You must be signed in to change notification settings - Fork 33
[MOD-17706] finalize SVSIndex::relabelVector #1045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 15 commits
48fe6db
a68d357
326edc0
06d42e6
f548f3d
4115d72
219cd1d
7066792
743cd20
086a3ba
87d8fc5
b7c0c38
cd09a53
52c5917
98e7edc
88be7eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,12 +106,11 @@ class PyVecSimIndex { | |
| template <typename DataType, typename DistType, typename NPArrayType = DataType> | ||
| inline py::object rawVectorsAsNumpy(labelType label, size_t dim) { | ||
| std::vector<std::vector<DataType>> vectors; | ||
| if (index->basicInfo().algo == VecSimAlgo_BF) { | ||
| dynamic_cast<BruteForceIndex<DataType, DistType> *>(this->index.get()) | ||
| ->getDataByLabel(label, vectors); | ||
| if (auto *tiered = | ||
| dynamic_cast<VecSimTieredIndex<DataType, DistType> *>(this->index.get())) { | ||
| tiered->getDataByLabel(label, vectors); | ||
| } else { | ||
| // index is HNSW | ||
| dynamic_cast<HNSWIndex<DataType, DistType> *>(this->index.get()) | ||
| dynamic_cast<VecSimIndexAbstract<DataType, DistType> *>(this->index.get()) | ||
| ->getDataByLabel(label, vectors); | ||
| } | ||
| size_t n_vectors = vectors.size(); | ||
|
|
@@ -216,6 +215,11 @@ class PyVecSimIndex { | |
|
|
||
| void runGC() { VecSimTieredIndex_GC(index.get()); } | ||
|
|
||
| VecSimRelabelCode relabelVector(labelType old_label, labelType new_label) { | ||
| py::gil_scoped_release py_gil; | ||
| return VecSimIndex_RelabelVector(index.get(), old_label, new_label); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think we need to find a way to synchronize the new |
||
| } | ||
|
|
||
| py::object getVector(labelType label) { | ||
| VecSimIndexBasicInfo info = index->basicInfo(); | ||
| size_t dim = info.dim; | ||
|
|
@@ -713,6 +717,14 @@ PYBIND11_MODULE(VecSim, m) { | |
| .def_readwrite("initialCapacity", &BFParams::initialCapacity) | ||
| .def_readwrite("blockSize", &BFParams::blockSize); | ||
|
|
||
| py::enum_<VecSimRelabelCode>(m, "VecSimRelabelCode") | ||
| .value("VecSimRelabel_OK", VecSimRelabel_OK) | ||
| .value("VecSimRelabel_OldLabelMissing", VecSimRelabel_OldLabelMissing) | ||
| .value("VecSimRelabel_NewLabelTaken", VecSimRelabel_NewLabelTaken) | ||
| .value("VecSimRelabel_SameLabel", VecSimRelabel_SameLabel) | ||
| .value("VecSimRelabel_Unsupported", VecSimRelabel_Unsupported) | ||
| .export_values(); | ||
|
|
||
| py::enum_<VecSimSvsQuantBits>(m, "VecSimSvsQuantBits") | ||
| .value("VecSimSvsQuant_NONE", VecSimSvsQuant_NONE) | ||
| .value("VecSimSvsQuant_Scalar", VecSimSvsQuant_Scalar) | ||
|
|
@@ -799,6 +811,8 @@ PYBIND11_MODULE(VecSim, m) { | |
| .def("create_batch_iterator", &PyVecSimIndex::createBatchIterator, py::arg("query_blob"), | ||
| py::arg("query_param") = nullptr) | ||
| .def("get_vector", &PyVecSimIndex::getVector) | ||
| .def("relabel_vector", &PyVecSimIndex::relabelVector, py::arg("old_label"), | ||
| py::arg("new_label")) | ||
| .def("run_gc", &PyVecSimIndex::runGC); | ||
|
|
||
| py::class_<PyHNSWLibIndex, PyVecSimIndex>(m, "HNSWIndex") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.