aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-06-05 12:26:17 +0200
committerGitHub <noreply@github.com>2024-06-05 12:26:17 +0200
commit52e29fb822412399938ff1eb32770feabd8d20b3 (patch)
tree7e4c628bcf5403a65e1bbec7b0be379d5e7c3d6b
parentf1dfcd8b4864d48eb76d7a58df5f2af75bc5c11d (diff)
parentd1c7e0cdb8a3d7a9d26897445822aa51feb1358c (diff)
Merge pull request #31441 from vespa-engine/toregge/add-second-phase-rank-score-drop-limit-to-proton-matching-match-params
Add second phase rank score drop limit to proton::matching::MatchParams.
-rw-r--r--searchcore/src/tests/proton/matching/matching_test.cpp19
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_params.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_params.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/matcher.cpp3
4 files changed, 19 insertions, 9 deletions
diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp
index e3bb5d519c6..539843ae164 100644
--- a/searchcore/src/tests/proton/matching/matching_test.cpp
+++ b/searchcore/src/tests/proton/matching/matching_test.cpp
@@ -958,22 +958,24 @@ TEST(MatchingTest, require_that_getSummaryFeatures_prefers_cached_query_setup)
TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_on)
{
- MatchParams p(10, 2, 4, 0.7, 0, 1, true, true);
+ MatchParams p(10, 2, 4, 0.7, 0.75, 0, 1, true, true);
ASSERT_EQ(10u, p.numDocs);
ASSERT_EQ(2u, p.heapSize);
ASSERT_EQ(4u, p.arraySize);
ASSERT_EQ(0.7, p.first_phase_rank_score_drop_limit.value());
+ ASSERT_EQ(0.75, p.second_phase_rank_score_drop_limit.value());
ASSERT_EQ(0u, p.offset);
ASSERT_EQ(1u, p.hits);
}
-TEST(MatchingTest, require_that_match_params_can_turn_off_rank_drop_limit)
+TEST(MatchingTest, require_that_match_params_can_turn_off_rank_score_drop_limits)
{
- MatchParams p(10, 2, 4, std::nullopt, 0, 1, true, true);
+ MatchParams p(10, 2, 4, std::nullopt, std::nullopt, 0, 1, true, true);
ASSERT_EQ(10u, p.numDocs);
ASSERT_EQ(2u, p.heapSize);
ASSERT_EQ(4u, p.arraySize);
ASSERT_FALSE(p.first_phase_rank_score_drop_limit.has_value());
+ ASSERT_FALSE(p.second_phase_rank_score_drop_limit.has_value());
ASSERT_EQ(0u, p.offset);
ASSERT_EQ(1u, p.hits);
}
@@ -981,18 +983,19 @@ TEST(MatchingTest, require_that_match_params_can_turn_off_rank_drop_limit)
TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_on_arraySize_is_atleast_the_size_of_heapSize)
{
- MatchParams p(10, 6, 4, 0.7, 1, 1, true, true);
+ MatchParams p(10, 6, 4, 0.7, std::nullopt, 1, 1, true, true);
ASSERT_EQ(10u, p.numDocs);
ASSERT_EQ(6u, p.heapSize);
ASSERT_EQ(6u, p.arraySize);
ASSERT_EQ(0.7, p.first_phase_rank_score_drop_limit.value());
+ ASSERT_FALSE(p.second_phase_rank_score_drop_limit.has_value());
ASSERT_EQ(1u, p.offset);
ASSERT_EQ(1u, p.hits);
}
TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_on_arraySize_is_atleast_the_size_of_hits_plus_offset)
{
- MatchParams p(10, 6, 4, 0.7, 4, 4, true, true);
+ MatchParams p(10, 6, 4, 0.7, std::nullopt, 4, 4, true, true);
ASSERT_EQ(10u, p.numDocs);
ASSERT_EQ(6u, p.heapSize);
ASSERT_EQ(8u, p.arraySize);
@@ -1003,7 +1006,7 @@ TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_on
TEST(MatchingTest, require_that_match_params_are_capped_by_numDocs)
{
- MatchParams p(1, 6, 4, 0.7, 4, 4, true, true);
+ MatchParams p(1, 6, 4, 0.7, std::nullopt, 4, 4, true, true);
ASSERT_EQ(1u, p.numDocs);
ASSERT_EQ(1u, p.heapSize);
ASSERT_EQ(1u, p.arraySize);
@@ -1014,7 +1017,7 @@ TEST(MatchingTest, require_that_match_params_are_capped_by_numDocs)
TEST(MatchingTest, require_that_match_params_are_capped_by_numDocs_and_hits_adjusted_down)
{
- MatchParams p(5, 6, 4, 0.7, 4, 4, true, true);
+ MatchParams p(5, 6, 4, 0.7, std::nullopt, 4, 4, true, true);
ASSERT_EQ(5u, p.numDocs);
ASSERT_EQ(5u, p.heapSize);
ASSERT_EQ(5u, p.arraySize);
@@ -1025,7 +1028,7 @@ TEST(MatchingTest, require_that_match_params_are_capped_by_numDocs_and_hits_adju
TEST(MatchingTest, require_that_match_params_are_set_up_straight_with_ranking_off_array_and_heap_size_is_0)
{
- MatchParams p(10, 6, 4, 0.7, 4, 4, true, false);
+ MatchParams p(10, 6, 4, 0.7, std::nullopt, 4, 4, true, false);
ASSERT_EQ(10u, p.numDocs);
ASSERT_EQ(0u, p.heapSize);
ASSERT_EQ(0u, p.arraySize);
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp
index 2e3d7c77926..316ef003a28 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp
@@ -20,6 +20,7 @@ MatchParams::MatchParams(uint32_t numDocs_in,
uint32_t heapSize_in,
uint32_t arraySize_in,
std::optional<search::feature_t> first_phase_rank_score_drop_limit_in,
+ std::optional<search::feature_t> second_phase_rank_score_drop_limit_in,
uint32_t offset_in,
uint32_t hits_in,
bool hasFinalRank,
@@ -31,7 +32,8 @@ MatchParams::MatchParams(uint32_t numDocs_in,
: 0),
offset(std::min(numDocs_in, offset_in)),
hits(std::min(numDocs_in - offset, hits_in)),
- first_phase_rank_score_drop_limit(first_phase_rank_score_drop_limit_in)
+ first_phase_rank_score_drop_limit(first_phase_rank_score_drop_limit_in),
+ second_phase_rank_score_drop_limit(second_phase_rank_score_drop_limit_in)
{ }
}
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_params.h b/searchcore/src/vespa/searchcore/proton/matching/match_params.h
index a487b9f13f0..19abcd8e449 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/match_params.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/match_params.h
@@ -19,11 +19,13 @@ struct MatchParams {
const uint32_t offset;
const uint32_t hits;
const std::optional<search::feature_t> first_phase_rank_score_drop_limit;
+ const std::optional<search::feature_t> second_phase_rank_score_drop_limit;
MatchParams(uint32_t numDocs_in,
uint32_t heapSize_in,
uint32_t arraySize_in,
std::optional<search::feature_t> first_phase_rank_drop_limit_in,
+ std::optional<search::feature_t> second_phase_rank_score_drop_limit_in,
uint32_t offset_in,
uint32_t hits_in,
bool hasFinalRank,
diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp
index 52ec4bbedd7..e0897e0378d 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp
@@ -39,6 +39,7 @@ using search::fef::RankSetup;
using search::fef::indexproperties::hitcollector::HeapSize;
using search::fef::indexproperties::hitcollector::ArraySize;
using search::fef::indexproperties::hitcollector::FirstPhaseRankScoreDropLimit;
+using search::fef::indexproperties::hitcollector::SecondPhaseRankScoreDropLimit;
using search::queryeval::Blueprint;
using search::queryeval::SearchIterator;
using vespalib::Doom;
@@ -290,8 +291,10 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl
uint32_t heapSize = HeapSize::lookup(rankProperties, _rankSetup->getHeapSize());
uint32_t arraySize = ArraySize::lookup(rankProperties, _rankSetup->getArraySize());
auto first_phase_rank_score_drop_limit = FirstPhaseRankScoreDropLimit::lookup(rankProperties, _rankSetup->get_first_phase_rank_score_drop_limit());
+ auto second_phase_rank_score_drop_limit = SecondPhaseRankScoreDropLimit::lookup(rankProperties, _rankSetup->get_second_phase_rank_score_drop_limit());
MatchParams params(searchContext.getDocIdLimit(), heapSize, arraySize, first_phase_rank_score_drop_limit,
+ second_phase_rank_score_drop_limit,
request.offset, request.maxhits, !_rankSetup->getSecondPhaseRank().empty(),
willNeedRanking(request, groupingContext, first_phase_rank_score_drop_limit));