summaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'searchcore/src/vespa/searchcore/proton/matching/match_params.cpp')
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_params.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp
index 7465088d8f0..68a6f74fa50 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/match_params.cpp
@@ -8,7 +8,8 @@ namespace proton::matching {
namespace {
-uint32_t computeArraySize(uint32_t hitsPlussOffset, uint32_t heapSize, uint32_t arraySize)
+uint32_t
+computeArraySize(uint32_t hitsPlussOffset, uint32_t heapSize, uint32_t arraySize)
{
return std::max(hitsPlussOffset, std::max(heapSize, arraySize));
}
@@ -24,16 +25,17 @@ MatchParams::MatchParams(uint32_t numDocs_in,
bool hasFinalRank,
bool needRanking)
: numDocs(numDocs_in),
- heapSize((hasFinalRank && needRanking) ? heapSize_in : 0),
+ heapSize((hasFinalRank && needRanking) ? std::min(numDocs_in, heapSize_in) : 0),
arraySize((needRanking && ((heapSize_in + arraySize_in) > 0))
- ? computeArraySize(hits_in + offset_in, heapSize, arraySize_in)
+ ? std::min(numDocs_in, computeArraySize(hits_in + offset_in, heapSize, arraySize_in))
: 0),
- offset(offset_in),
- hits(hits_in),
+ offset(std::min(numDocs_in, offset_in)),
+ hits(std::min(numDocs_in - offset, hits_in)),
rankDropLimit(rankDropLimit_in)
{ }
-bool MatchParams::has_rank_drop_limit() const {
+bool
+MatchParams::has_rank_drop_limit() const {
return ! std::isnan(rankDropLimit);
}