fix(segment): use raw vectors for RaBitQ merge during compaction (#456)

* fix: rabitQ recall=0

* re-enable rabitQ SegmentCompactReuseTest

* chore: simplify the comment

* chore: simplify the comment
This commit is contained in:
Jalin Wang
2026-06-03 21:47:12 +08:00
committed by GitHub
parent 439dd10f5e
commit f562bdd636
2 changed files with 18 additions and 12 deletions
+11 -4
View File
@@ -726,10 +726,17 @@ Status SegmentHelper::ReduceVectorIndex(
auto vector_quan_index_path = FileHelper::MakeQuantizeVectorIndexPath(
output_segment_path, field->name(), vector_quan_block_id);
s = MergeWithOptionalReuse(
vector_quan_index_path, *field_for_quantize,
collect_merge_indexers(&Segment::get_quant_vector_indexer), filter,
concurrency, nullptr);
// RABITQ requires raw fp32 vectors as input, because re-encoding the
// already-encoded quant indexers would produce garbage data. Other
// types require the quantized vectors as input.
auto quant_merge_sources =
(vector_index_params->quantize_type() == QuantizeType::RABITQ)
? collect_merge_indexers(&Segment::get_vector_indexer)
: collect_merge_indexers(&Segment::get_quant_vector_indexer);
s = MergeWithOptionalReuse(vector_quan_index_path, *field_for_quantize,
quant_merge_sources, filter, concurrency,
nullptr);
CHECK_RETURN_STATUS(s);
s = vector_indexer->Close();
@@ -770,14 +770,13 @@ INSTANTIATE_TEST_SUITE_P(
QuantizeType::UNDEFINED),
IndexType::IVF}));
// TODO: re-enable when rabitQ merge fixed
// #if RABITQ_SUPPORTED
// INSTANTIATE_TEST_SUITE_P(HnswRabitq, SegmentCompactReuseTest,
// testing::Values(SegmentCompactReuseParam{
// std::make_shared<HnswRabitqIndexParams>(
// MetricType::IP, 7, 256, 16, 200, 0),
// IndexType::HNSW_RABITQ}));
// #endif
#if RABITQ_SUPPORTED
INSTANTIATE_TEST_SUITE_P(HnswRabitq, SegmentCompactReuseTest,
testing::Values(SegmentCompactReuseParam{
std::make_shared<HnswRabitqIndexParams>(
MetricType::IP, 7, 256, 16, 200, 0),
IndexType::HNSW_RABITQ}));
#endif
TEST_F(SegmentHelperTest, CompactTask_FilterMultiSegmentsRegression) {
auto schema = test::TestHelper::CreateSchemaWithVectorIndex();