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

Method bind_query_params

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

Source from the content-addressed store, hash-verified

1426}
1427
1428void ZVecPyParams::bind_query_params(py::module_ &m) {
1429 // binding base query params
1430 py::class_<QueryParams, std::shared_ptr<QueryParams>> query_params(
1431 m, "QueryParam", R"pbdoc(
1432Base class for all query parameter configurations.
1433
1434This abstract base class defines common query settings such as search radius
1435and whether to force linear (brute-force) search. It should not be instantiated
1436directly; use derived classes like `HnswQueryParam` or `IVFQueryParam`.
1437
1438Attributes:
1439 type (IndexType): The index type this query is configured for.
1440 radius (float): Search radius for range queries. Used in combination with
1441 top-k to filter results. Default is 0.0 (disabled).
1442 is_linear (bool): If True, forces brute-force linear search instead of
1443 using the index. Useful for debugging or small datasets. Default is False.
1444 is_using_refiner (bool, optional): Whether to use refiner for the query. Default is False.
1445 scale_factor (float): Coarse candidate multiplier when refining. Zero selects
1446 the index-specific default; graph indexes use max(topk, ef) candidates.
1447 Positive values are rounded down with a minimum of topk candidates.
1448 Must be finite and nonnegative. Ignored when is_using_refiner is False.
1449)pbdoc");
1450 query_params
1451 .def_property_readonly(
1452 "type",
1453 [](const QueryParams &self) -> IndexType { return self.type(); },
1454 "IndexType: The type of index this query targets.")
1455 .def_property_readonly(
1456 "radius",
1457 [](const QueryParams &self) -> float { return self.radius(); },
1458 "IndexType: The type of index this query targets.")
1459 .def_property_readonly(
1460 "is_linear",
1461 [](const QueryParams &self) -> bool { return self.is_linear(); },
1462 "bool: Whether to bypass the index and use brute-force linear "
1463 "search.")
1464 .def_property_readonly(
1465 "is_using_refiner",
1466 [](const QueryParams &self) -> bool {
1467 return self.is_using_refiner();
1468 },
1469 "bool: Whether to use refiner for the query.")
1470 .def_property_readonly(
1471 "scale_factor", &QueryParams::scale_factor,
1472 "float: Coarse candidate multiplier used when refinement is enabled.")
1473 .def(py::pickle(
1474 [](const QueryParams &self) { // __getstate__
1475 return py::make_tuple(self.type(), self.radius(), self.is_linear());
1476 },
1477 [](py::tuple t) { // __setstate__
1478 if (t.size() != 3)
1479 throw std::runtime_error("Invalid state for QueryParams");
1480 return std::shared_ptr<QueryParams>();
1481 }));
1482
1483 // binding hnsw query params
1484 py::class_<HnswQueryParams, QueryParams, std::shared_ptr<HnswQueryParams>>
1485 hnsw_params(m, "HnswQueryParam", R"pbdoc(

Callers

nothing calls this directly

Calls 10

initFunction · 0.85
index_type_to_stringFunction · 0.85
nprobeMethod · 0.80
list_sizeMethod · 0.80
to_stringFunction · 0.50
typeMethod · 0.45
sizeMethod · 0.45
containsMethod · 0.45
efMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected