zvec/python/tests/detail
Cuiys 0923f7c691
refactor: make Reranker stateless with std::variant value semantics (… (#471)
* refactor: make Reranker stateless with std::variant value semantics (#461)

Replace class hierarchy (Reranker/ScoreBasedReranker/RrfReranker/
WeightedReranker/CallbackReranker) with std::variant<RrfParams,
WeightedParams, CallbackParams> value type and a stateless free function
reranker::rerank().

Key changes:
- reranker.h: define RerankParams variant + reranker::rerank() API
- query.h: MultiQuery::reranker (shared_ptr) -> MultiQuery::rerank (value)
- schema.h: add CollectionSchema::get_field_ptr() returning FieldSchema::Ptr
- collection.cc: push field lookup to caller, pass vector<FieldSchema::Ptr>
- c_api: remove opaque zvec_reranker_t, add zvec_multi_query_set_rerank_*
- python binding: expose _RrfParams/_WeightedParams/_CallbackParams + setters
- python layer: WeightedReRanker(list[float]), remove Python rerank logic
- all tests updated to new interface

Benefits:
- Thread-safe by design: no mutable state, safe to share across threads
- Collection-decoupled: no bind_schema(), field info passed as parameter
- Simpler lifecycle: value semantics, no shared_ptr management

Closes #461

* chore: remove nightly_build.yml unrelated to reranker refactor

* chore: remove uv.lock unrelated to reranker refactor

* fix: raise ValueError when multi-query has no reranker

After the reranker stateless refactor the C++ MultiQuery rerank
strategy uses a std::variant with a default value, so the implicit
'reranker required' validation no longer triggered. Restore the
check in QueryExecutor._execute_multi_query so that a hybrid
(multi-query) request without a reranker raises ValueError.

* fix(reranker): use index_type FTS check for non-vector normalization

Replace dynamic_cast nullptr check with explicit IndexType::FTS check
and map FTS/BM25 positive scores to (0.0, 1.0) via 2*atan(score)/pi.

* refactor(reranker): move Params types into reranker namespace and qualify usages

Move RrfParams, WeightedParams, CallbackParams and RerankParams into the
zvec::reranker namespace, and add explicit reranker:: qualification at all
usage sites outside the reranker module (query.h, python/c bindings, tests).

* refactor(query): drop unused PendingQuery wrapper, use std::vector<SearchQuery> directly

* refactor(reranker): make _to_cpp_params non-abstract with default NotImplementedError

Remove @abstractmethod from RerankFunction._to_cpp_params and provide a
default implementation raising NotImplementedError. Drop the redundant
_to_cpp_params overrides from Qwen and Sentence rerankers since they use
the Python rerank path and don't need the C++ conversion.
2026-06-09 12:44:17 +08:00
..
distance_helper.py tests: add tests for recall (#196) 2026-03-05 20:13:45 +08:00
doc_helper.py tests: add tests for recall (#196) 2026-03-05 20:13:45 +08:00
fixture_helper.py feat: add diskann index (#369) 2026-06-04 20:52:43 +08:00
params_helper.py
support_helper.py tests: add tests for recall (#196) 2026-03-05 20:13:45 +08:00
test_collection_concurrency.py
test_collection_create_and_open.py fix: relax collection path restriction (#340) 2026-04-16 15:26:15 +08:00
test_collection_ddl.py fix: sync querier schema after column DDL to fix empty query fields (#429) 2026-05-29 17:36:30 +08:00
test_collection_dml.py deprecate python VectorQuery (#267) 2026-05-12 14:55:49 +08:00
test_collection_dql.py refactor: make Reranker stateless with std::variant value semantics (… (#471) 2026-06-09 12:44:17 +08:00
test_collection_exception.py deprecate python VectorQuery (#267) 2026-05-12 14:55:49 +08:00
test_collection_open.py deprecate python VectorQuery (#267) 2026-05-12 14:55:49 +08:00
test_collection_recall.py feat: add diskann index (#369) 2026-06-04 20:52:43 +08:00
test_db_config.py minor: subsequent initialization should fail silently (#79) 2026-02-06 21:16:08 +08:00