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

Method bind_index_params

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

Source from the content-addressed store, hash-verified

131}
132
133void ZVecPyParams::bind_index_params(pybind11::module_ &m) {
134 // binding base index params
135 py::class_<IndexParams, std::shared_ptr<IndexParams>> index_params(
136 m, "IndexParam", R"pbdoc(
137Base class for all index parameter configurations.
138
139This abstract base class defines the common interface for index types.
140It should not be instantiated directly; use derived classes instead.
141
142Attributes:
143 type (IndexType): The type of the index (e.g., HNSW, FLAT, INVERT).
144)pbdoc");
145 index_params
146 .def_property_readonly(
147 "type",
148 [](const IndexParams &self) -> IndexType { return self.type(); },
149 "IndexType: The type of the index.")
150 .def("clone", &IndexParams::clone, py::return_value_policy::copy)
151 .def(
152 "__eq__",
153 [](const IndexParams &self, const py::object &other) {
154 if (!py::isinstance<IndexParams>(other)) return false;
155 return self == other.cast<const IndexParams &>();
156 },
157 py::is_operator())
158 .def(
159 "to_dict",
160 [](const IndexParams &self) -> py::dict {
161 py::dict dict;
162 dict["type"] = index_type_to_string(self.type());
163 return dict;
164 },
165 "Convert to dictionary with all fields")
166 .def(py::pickle(
167 [](const IndexParams &self) { // __getstate__
168 return py::make_tuple(self.type());
169 },
170 [](py::tuple t) { // __setstate__
171 if (t.size() != 1)
172 throw std::runtime_error("Invalid state for IndexParams");
173 return std::shared_ptr<IndexParams>();
174 }));
175
176 // binding invert index params
177 py::class_<InvertIndexParams, IndexParams, std::shared_ptr<InvertIndexParams>>
178 invert_params(m, "InvertIndexParam", R"pbdoc(
179Parameters for configuring an invert index.
180
181This class controls whether range query
182optimization is enabled for invert index structures.
183
184Attributes:
185 type (IndexType): Always `IndexType.INVERTED`.
186 enable_range_optimization (bool): Whether range optimization is enabled.
187 enable_extended_wildcard (bool): Whether extended wildcard (suffix and infix) search is enabled.
188
189Examples:
190 >>> params = InvertIndexParam(enable_range_optimization=True, enable_extended_wildcard=False)

Callers

nothing calls this directly

Calls 15

index_type_to_stringFunction · 0.85
metric_type_to_stringFunction · 0.85
quantize_type_to_stringFunction · 0.85
initFunction · 0.85
enable_rotateMethod · 0.80
quantize_typeMethod · 0.80
saturate_graphMethod · 0.80
pq_chunk_numMethod · 0.80
list_sizeMethod · 0.80
to_stringFunction · 0.50
QuantizerParamClass · 0.50
typeMethod · 0.45

Tested by

no test coverage detected