MCPcopy Create free account
hub / github.com/alibaba/zvec / bind_index_params

Method bind_index_params

src/binding/python/model/param/python_param.cc:167–1426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167void ZVecPyParams::bind_index_params(pybind11::module_ &m) {
168 // binding base index params
169 py::class_<IndexParams, std::shared_ptr<IndexParams>> index_params(
170 m, "IndexParam", R"pbdoc(
171Base class for all index parameter configurations.
172
173This abstract base class defines the common interface for index types.
174It should not be instantiated directly; use derived classes instead.
175
176Attributes:
177 type (IndexType): The type of the index (e.g., HNSW, FLAT, INVERT).
178)pbdoc");
179 index_params
180 .def_property_readonly(
181 "type",
182 [](const IndexParams &self) -> IndexType { return self.type(); },
183 "IndexType: The type of the index.")
184 .def("clone", &IndexParams::clone, py::return_value_policy::copy)
185 .def(
186 "__eq__",
187 [](const IndexParams &self, const py::object &other) {
188 if (!py::isinstance<IndexParams>(other)) return false;
189 return self == other.cast<const IndexParams &>();
190 },
191 py::is_operator())
192 .def(
193 "to_dict",
194 [](const IndexParams &self) -> py::dict {
195 py::dict dict;
196 dict["type"] = index_type_to_string(self.type());
197 return dict;
198 },
199 "Convert to dictionary with all fields")
200 .def(py::pickle(
201 [](const IndexParams &self) { // __getstate__
202 return py::make_tuple(self.type());
203 },
204 [](py::tuple t) { // __setstate__
205 if (t.size() != 1)
206 throw std::runtime_error("Invalid state for IndexParams");
207 return std::shared_ptr<IndexParams>();
208 }));
209
210 // binding invert index params
211 py::class_<InvertIndexParams, IndexParams, std::shared_ptr<InvertIndexParams>>
212 invert_params(m, "InvertIndexParam", R"pbdoc(
213Parameters for configuring an invert index.
214
215This class controls whether range query
216optimization is enabled for invert index structures.
217
218Attributes:
219 type (IndexType): Always `IndexType.INVERTED`.
220 enable_range_optimization (bool): Whether range optimization is enabled.
221 enable_extended_wildcard (bool): Whether extended wildcard (suffix and infix) search is enabled.
222
223Examples:
224 >>> params = InvertIndexParam(enable_range_optimization=True, enable_extended_wildcard=False)

Callers

nothing calls this directly

Calls 15

index_type_to_stringFunction · 0.85
quantizer_param_to_dictFunction · 0.85
metric_type_to_stringFunction · 0.85
quantize_type_to_stringFunction · 0.85
initFunction · 0.85
data_type_to_stringFunction · 0.85
enable_rotateMethod · 0.80
num_chunkMethod · 0.80
num_bitsMethod · 0.80
fast_scanMethod · 0.80
opq_iterMethod · 0.80
opq_pq_iterMethod · 0.80

Tested by

no test coverage detected