From 5c15bc48b16c9c86ffce7f73f3fcb5d3fba0fcd8 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Thu, 18 Jun 2020 18:11:33 +0200 Subject: Wire in nearest neighbor brute force limit. --- .../proton/matching/request_context/request_context_test.cpp | 4 +++- .../src/vespa/searchcore/proton/matching/match_tools.cpp | 10 +++++++++- .../src/vespa/searchcore/proton/matching/requestcontext.cpp | 12 ++++++++++-- .../src/vespa/searchcore/proton/matching/requestcontext.h | 6 +++++- 4 files changed, 27 insertions(+), 5 deletions(-) (limited to 'searchcore') diff --git a/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp b/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp index c3338a973c4..3b54768f223 100644 --- a/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp +++ b/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp @@ -3,10 +3,12 @@ #include #include #include +#include #include #include #include +using search::attribute::AttributeBlueprintParams; using search::attribute::IAttributeContext; using search::attribute::IAttributeFunctor; using search::attribute::IAttributeVector; @@ -45,7 +47,7 @@ public: _doom(_clock, vespalib::steady_time(), vespalib::steady_time(), false), _attr_ctx(), _props(), - _request_ctx(_doom, _attr_ctx, _props), + _request_ctx(_doom, _attr_ctx, _props, AttributeBlueprintParams()), _query_tensor(DefaultTensorEngine::ref().from_spec(TensorSpec("tensor(x[2])") .add({{"x", 0}}, 3).add({{"x", 1}}, 5))) { diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp index f19b416b92f..fadea4b7962 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -19,6 +20,7 @@ using search::queryeval::IRequestContext; using search::queryeval::IDiversifier; using search::attribute::diversity::DiversityFilter; using search::attribute::BasicType; +using search::attribute::AttributeBlueprintParams; using namespace search::fef; using namespace search::fef::indexproperties::matchphase; @@ -64,6 +66,12 @@ extractDiversityParams(const RankSetup &rankSetup, const Properties &rankPropert AttributeLimiter::toDiversityCutoffStrategy(DiversityCutoffStrategy::lookup(rankProperties, rankSetup.getDiversityCutoffStrategy()))); } +AttributeBlueprintParams +extractAttributeBlueprintParams(const RankSetup& rank_setup, const Properties &rankProperties) +{ + return AttributeBlueprintParams(NearestNeighborBruteForceLimit::lookup(rankProperties, rank_setup.get_nearest_neighbor_brute_force_limit())); +} + } // namespace proton::matching:: void @@ -161,7 +169,7 @@ MatchToolsFactory(QueryLimiter & queryLimiter, const Properties & rankProperties, const Properties & featureOverrides) : _queryLimiter(queryLimiter), - _requestContext(doom, attributeContext, rankProperties), + _requestContext(doom, attributeContext, rankProperties, extractAttributeBlueprintParams(rankSetup, rankProperties)), _query(), _match_limiter(), _queryEnv(indexEnv, attributeContext, rankProperties, searchContext.getIndexes()), diff --git a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp index c30854c051f..86afeb5de24 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp @@ -15,10 +15,12 @@ namespace proton { using search::attribute::IAttributeVector; RequestContext::RequestContext(const Doom & doom, IAttributeContext & attributeContext, - const search::fef::Properties& rank_properties) + const search::fef::Properties& rank_properties, + const search::attribute::AttributeBlueprintParams& attribute_blueprint_params) : _doom(doom), _attributeContext(attributeContext), - _rank_properties(rank_properties) + _rank_properties(rank_properties), + _attribute_blueprint_params(attribute_blueprint_params) { } @@ -57,4 +59,10 @@ RequestContext::get_query_tensor(const vespalib::string& tensor_name) const return vespalib::eval::Value::UP(); } +const search::attribute::AttributeBlueprintParams& +RequestContext::get_attribute_blueprint_params() const +{ + return _attribute_blueprint_params; +} + } diff --git a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h index 31d3d573a20..ada11167983 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h +++ b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace search::fef { class Properties; } @@ -19,7 +20,8 @@ public: using IAttributeFunctor = search::attribute::IAttributeFunctor; using Doom = vespalib::Doom; RequestContext(const Doom & softDoom, IAttributeContext & attributeContext, - const search::fef::Properties& rank_properties); + const search::fef::Properties& rank_properties, + const search::attribute::AttributeBlueprintParams& attribute_blueprint_params); const Doom & getDoom() const override { return _doom; } const search::attribute::IAttributeVector *getAttribute(const vespalib::string &name) const override; @@ -30,11 +32,13 @@ public: vespalib::eval::Value::UP get_query_tensor(const vespalib::string& tensor_name) const override; + const search::attribute::AttributeBlueprintParams& get_attribute_blueprint_params() const override; private: const Doom _doom; IAttributeContext & _attributeContext; const search::fef::Properties & _rank_properties; + search::attribute::AttributeBlueprintParams _attribute_blueprint_params; }; } -- cgit v1.2.3