diff options
author | Henning Baldersheim <balder@oath.com> | 2018-08-10 12:55:19 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-08-10 12:55:19 +0200 |
commit | 77368ff9a425b836f14c587d4ebe44b347a260af (patch) | |
tree | f2c14ea7651d5136b69d244a83f021cad397998f /searchcore | |
parent | 810a72ba06b31375507d9e721dce8eb3af0a16f5 (diff) |
Streamline parameter extraction.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matching/match_phase_limiter.h | 3 | ||||
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp | 51 |
2 files changed, 21 insertions, 33 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_phase_limiter.h b/searchcore/src/vespa/searchcore/proton/matching/match_phase_limiter.h index 6249f87a9fb..b39b6695b7f 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_phase_limiter.h +++ b/searchcore/src/vespa/searchcore/proton/matching/match_phase_limiter.h @@ -78,7 +78,7 @@ struct DiversityParams { cutoff_factor(cutoff_factor_), cutoff_strategy(cutoff_strategy_) { } - + bool enabled() const { return !attribute.empty() && (min_groups > 0); } vespalib::string attribute; uint32_t min_groups; double cutoff_factor; @@ -95,6 +95,7 @@ struct DegradationParams { sample_percentage(sample_percentage_), post_filter_multiplier(post_filter_multiplier_) { } + bool enabled() const { return !attribute.empty() && (max_hits > 0); } vespalib::string attribute; size_t max_hits; bool descending; diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp index faf0156ad25..fe10c1d51c3 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp @@ -41,38 +41,25 @@ void tag_match_data(const HandleRecorder::HandleSet &handles, MatchData &match_d } } -std::unique_ptr<DegradationParams> -getDegradationParams(const RankSetup & rankSetup, const Properties & rankProperties) +DegradationParams +extractDegradationParams(const RankSetup &rankSetup, const Properties &rankProperties) { - vespalib::string limit_attribute = DegradationAttribute::lookup(rankProperties); - size_t limit_maxhits = DegradationMaxHits::lookup(rankProperties); - if (!limit_attribute.empty() && limit_maxhits > 0) { - bool limit_ascending = DegradationAscendingOrder::lookup(rankProperties); - double limit_max_filter_coverage = DegradationMaxFilterCoverage::lookup(rankProperties); - double samplePercentage = DegradationSamplePercentage::lookup(rankProperties); - double postFilterMultiplier = DegradationPostFilterMultiplier::lookup(rankProperties); - return std::make_unique<DegradationParams>(limit_attribute, limit_maxhits, !limit_ascending, - limit_max_filter_coverage, samplePercentage, postFilterMultiplier); - } else if (rankSetup.hasMatchPhaseDegradation()) { - return std::make_unique<DegradationParams>(rankSetup.getDegradationAttribute(), rankSetup.getDegradationMaxHits(), - !rankSetup.isDegradationOrderAscending(), rankSetup.getDegradationMaxFilterCoverage(), - rankSetup.getDegradationSamplePercentage(), rankSetup.getDegradationPostFilterMultiplier()); - } - return std::unique_ptr<DegradationParams>(); + return DegradationParams(DegradationAttribute::lookup(rankProperties, rankSetup.getDegradationAttribute()), + DegradationMaxHits::lookup(rankProperties, rankSetup.getDegradationMaxHits()), + !DegradationAscendingOrder::lookup(rankProperties, rankSetup.isDegradationOrderAscending()), + DegradationMaxFilterCoverage::lookup(rankProperties, rankSetup.getDegradationMaxFilterCoverage()), + DegradationSamplePercentage::lookup(rankProperties, rankSetup.getDegradationSamplePercentage()), + DegradationPostFilterMultiplier::lookup(rankProperties, rankSetup.getDegradationPostFilterMultiplier())); + } DiversityParams -getDiversityParams(const RankSetup & rankSetup, const Properties & rankProperties) +extractDiversityParams(const RankSetup &rankSetup, const Properties &rankProperties) { - vespalib::string diversity_attribute = DiversityAttribute::lookup(rankProperties); - - return (!diversity_attribute.empty()) - ? DiversityParams(diversity_attribute, DiversityMinGroups::lookup(rankProperties), - DiversityCutoffFactor::lookup(rankProperties), - AttributeLimiter::toDiversityCutoffStrategy(DiversityCutoffStrategy::lookup(rankProperties))) - : DiversityParams(rankSetup.getDiversityAttribute(), rankSetup.getDiversityMinGroups(), - rankSetup.getDiversityCutoffFactor(), - AttributeLimiter::toDiversityCutoffStrategy(rankSetup.getDiversityCutoffStrategy())); + return DiversityParams(DiversityAttribute::lookup(rankProperties, rankSetup.getDiversityAttribute()), + DiversityMinGroups::lookup(rankProperties, rankSetup.getDiversityMinGroups()), + DiversityCutoffFactor::lookup(rankProperties, rankSetup.getDiversityCutoffFactor()), + AttributeLimiter::toDiversityCutoffStrategy(DiversityCutoffStrategy::lookup(rankProperties, rankSetup.getDiversityCutoffStrategy()))); } } // namespace proton::matching::<unnamed> @@ -189,12 +176,12 @@ MatchToolsFactory(QueryLimiter & queryLimiter, _query.fetchPostings(); _query.freeze(); _rankSetup.prepareSharedState(_queryEnv, _queryEnv.getObjectStore()); - _diversityParams = getDiversityParams(_rankSetup, rankProperties); - std::unique_ptr<DegradationParams> degradationParams = getDegradationParams(_rankSetup, rankProperties); + _diversityParams = extractDiversityParams(_rankSetup, rankProperties); + DegradationParams degradationParams = extractDegradationParams(_rankSetup, rankProperties); - if (degradationParams) { + if (degradationParams.enabled()) { _match_limiter = std::make_unique<MatchPhaseLimiter>(metaStore.getCommittedDocIdLimit(), searchContext.getAttributes(), - _requestContext, *degradationParams, _diversityParams); + _requestContext, degradationParams, _diversityParams); } } if ( ! _match_limiter) { @@ -214,7 +201,7 @@ MatchToolsFactory::createMatchTools() const std::unique_ptr<IDiversifier> MatchToolsFactory::createDiversifier() const { - if (_diversityParams.attribute.empty()) { + if ( !_diversityParams.enabled() ) { return std::unique_ptr<IDiversifier>(); } auto attr = _requestContext.getAttribute(_diversityParams.attribute); |