From 55aa254adb493ee1efe6d0af80b40d50ed6dd4ca Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Sat, 30 Nov 2024 13:03:50 +0100 Subject: [PATCH] Extend semantic lifetime of weights vector. --- .../sparse_vector_benchmark/sparse_vector_benchmark_test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp index 00224e4eda0..15b37b9971c 100644 --- a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp +++ b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp @@ -225,10 +225,12 @@ struct RiseWandFactory : SparseVectorFactory { struct WeightedSetFactory : SparseVectorFactory { mutable TermFieldMatchData tfmd; + mutable std::vector weights; bool field_is_filter; WeightedSetFactory(bool field_is_filter_, bool term_is_not_needed) : tfmd(), + weights(), field_is_filter(field_is_filter_) { if (term_is_not_needed) { @@ -240,7 +242,7 @@ struct WeightedSetFactory : SparseVectorFactory { } SearchIterator::UP createSparseVector(ChildFactory &childFactory, uint32_t childCnt, uint32_t limit) const override { std::vector terms; - std::vector weights; + weights.clear(); for (size_t i = 0; i < childCnt; ++i) { // TODO: pass ownership with unique_ptr terms.push_back(childFactory.createChild(i, limit).release());