diff options
author | Henning Baldersheim <balder@oath.com> | 2018-08-24 19:52:07 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-08-27 09:22:14 +0200 |
commit | f19fa359f112f0009a4a39e9e8358a5458ca4fb2 (patch) | |
tree | a48dc619eadb646480ee1cabca0d596e9b795f09 /searchcore | |
parent | be6729d2eadb3abe61613acb82c59a137ccf12a0 (diff) |
Wire in the attribute execution via the IAttributeContext.
Also execution in a task for containment.
Diffstat (limited to 'searchcore')
30 files changed, 180 insertions, 287 deletions
diff --git a/searchcore/src/tests/grouping/CMakeLists.txt b/searchcore/src/tests/grouping/CMakeLists.txt index 8108028c717..781f0cab66f 100644 --- a/searchcore/src/tests/grouping/CMakeLists.txt +++ b/searchcore/src/tests/grouping/CMakeLists.txt @@ -5,5 +5,6 @@ vespa_add_executable(searchcore_grouping_test_app TEST DEPENDS searchcore_grouping searchcore_matching + searchlib_test ) vespa_add_test(NAME searchcore_grouping_test_app COMMAND searchcore_grouping_test_app) diff --git a/searchcore/src/tests/grouping/grouping.cpp b/searchcore/src/tests/grouping/grouping.cpp index 7e21fffe9fd..3f166ee9723 100644 --- a/searchcore/src/tests/grouping/grouping.cpp +++ b/searchcore/src/tests/grouping/grouping.cpp @@ -10,6 +10,7 @@ #include <vespa/searchcore/grouping/groupingmanager.h> #include <vespa/searchcore/grouping/groupingsession.h> #include <vespa/searchcore/proton/matching/sessionmanager.h> +#include <vespa/searchlib/test/mock_attribute_context.h> #include <iostream> #include <vespa/log/log.h> @@ -20,7 +21,7 @@ using namespace search::aggregation; using namespace search::expression; using namespace search::grouping; using namespace search; - +using search::attribute::test::MockAttributeContext; using proton::matching::SessionManager; @@ -30,55 +31,8 @@ const uint32_t NUM_DOCS = 1000; //----------------------------------------------------------------------------- -class MyAttributeContext : public IAttributeContext -{ -private: - typedef std::map<string, IAttributeVector *> Map; - Map _vectors; - -public: - const IAttributeVector *get(const string &name) const { - if (_vectors.find(name) == _vectors.end()) { - return 0; - } - return _vectors.find(name)->second; - } - virtual const IAttributeVector * - getAttribute(const string &name) const override { - return get(name); - } - virtual const IAttributeVector * - getAttributeStableEnum(const string &name) const override { - return get(name); - } - virtual void - getAttributeList(std::vector<const IAttributeVector *> & list) const override { - Map::const_iterator pos = _vectors.begin(); - Map::const_iterator end = _vectors.end(); - for (; pos != end; ++pos) { - list.push_back(pos->second); - } - } - ~MyAttributeContext() { - Map::iterator pos = _vectors.begin(); - Map::iterator end = _vectors.end(); - for (; pos != end; ++pos) { - delete pos->second; - } - } - - //------------------------------------------------------------------------- - - void add(IAttributeVector *attr) { - _vectors[attr->getName()] = attr; - } -}; - - -//----------------------------------------------------------------------------- - struct MyWorld { - MyAttributeContext attributeContext; + MockAttributeContext attributeContext; void basicSetup() { // attribute context diff --git a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp index bd539999b5d..b0bf905ba75 100644 --- a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp @@ -19,7 +19,7 @@ #include <vespa/searchcore/proton/test/attribute_utils.h> #include <vespa/searchcore/proton/test/attribute_vectors.h> #include <vespa/searchlib/attribute/attributefactory.h> -#include <vespa/searchlib/attribute/i_attribute_functor.h> +#include <vespa/searchcommon/attribute/i_attribute_functor.h> #include <vespa/searchlib/attribute/attributevector.hpp> #include <vespa/searchlib/attribute/attribute_read_guard.h> #include <vespa/searchlib/attribute/imported_attribute_vector.h> @@ -85,7 +85,7 @@ class MyAttributeFunctor : public search::attribute::IAttributeFunctor public: void - operator()(const search::AttributeVector &attributeVector) override { + operator()(const search::attribute::IAttributeVector &attributeVector) override { _names.push_back(attributeVector.getName()); } diff --git a/searchcore/src/tests/proton/common/CMakeLists.txt b/searchcore/src/tests/proton/common/CMakeLists.txt index 751314791a0..da0bc9b5b10 100644 --- a/searchcore/src/tests/proton/common/CMakeLists.txt +++ b/searchcore/src/tests/proton/common/CMakeLists.txt @@ -4,6 +4,7 @@ vespa_add_executable(searchcore_selectpruner_test_app TEST selectpruner_test.cpp DEPENDS searchcore_pcommon + searchlib_test ) vespa_add_test(NAME searchcore_selectpruner_test_app COMMAND searchcore_selectpruner_test_app) vespa_add_executable(searchcore_cachedselect_test_app TEST @@ -11,5 +12,6 @@ vespa_add_executable(searchcore_cachedselect_test_app TEST cachedselect_test.cpp DEPENDS searchcore_pcommon + searchlib_test ) vespa_add_test(NAME searchcore_cachedselect_test_app COMMAND searchcore_cachedselect_test_app) diff --git a/searchcore/src/tests/proton/document_iterator/CMakeLists.txt b/searchcore/src/tests/proton/document_iterator/CMakeLists.txt index 729bf09446f..27bd4cef68d 100644 --- a/searchcore/src/tests/proton/document_iterator/CMakeLists.txt +++ b/searchcore/src/tests/proton/document_iterator/CMakeLists.txt @@ -5,5 +5,6 @@ vespa_add_executable(searchcore_document_iterator_test_app TEST DEPENDS searchcore_persistenceengine searchcore_pcommon + searchlib_test ) vespa_add_test(NAME searchcore_document_iterator_test_app COMMAND searchcore_document_iterator_test_app) diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/maintenancecontroller/CMakeLists.txt index 6769c964959..6b25971df83 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/CMakeLists.txt +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/CMakeLists.txt @@ -16,6 +16,7 @@ vespa_add_executable(searchcore_maintenancecontroller_test_app TEST searchcore_proton_metrics searchcore_util searchcore_fconfig + searchlib_test ) vespa_add_test(NAME searchcore_maintenancecontroller_test_app COMMAND searchcore_maintenancecontroller_test_app) vespa_add_executable(searchcore_frozenbucketsmap_test_app TEST diff --git a/searchcore/src/tests/proton/matching/CMakeLists.txt b/searchcore/src/tests/proton/matching/CMakeLists.txt index 14f3960c43e..0fce2f6aca2 100644 --- a/searchcore/src/tests/proton/matching/CMakeLists.txt +++ b/searchcore/src/tests/proton/matching/CMakeLists.txt @@ -14,6 +14,7 @@ vespa_add_executable(searchcore_matching_test_app TEST searchcore_grouping searchcore_util searchlib_searchlib_uca + searchlib_test ) vespa_add_test(NAME searchcore_matching_test_app COMMAND searchcore_matching_test_app) vespa_add_executable(searchcore_sessionmanager_test_app TEST diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index 8d75c8b8d24..de6a452baf3 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -24,6 +24,7 @@ #include <vespa/searchlib/engine/searchrequest.h> #include <vespa/searchlib/engine/docsumreply.h> #include <vespa/searchlib/engine/searchreply.h> +#include <vespa/searchlib/test/mock_attribute_context.h> #include <vespa/searchlib/fef/properties.h> #include <vespa/searchlib/query/tree/querybuilder.h> #include <vespa/searchlib/query/tree/stackdumpcreator.h> @@ -49,6 +50,7 @@ using namespace search::query; using namespace search::queryeval; using namespace search; +using search::attribute::test::MockAttributeContext; using search::index::schema::DataType; using storage::spi::Timestamp; @@ -93,52 +95,6 @@ vespalib::string make_same_element_stack_dump(const vespalib::string &a1_term, c const uint32_t NUM_DOCS = 1000; -//----------------------------------------------------------------------------- - -class MyAttributeContext : public IAttributeContext -{ -private: - typedef std::map<string, IAttributeVector *> Map; - Map _vectors; - -public: - const IAttributeVector *get(const string &name) const { - if (_vectors.find(name) == _vectors.end()) { - return 0; - } - return _vectors.find(name)->second; - } - const IAttributeVector * - getAttribute(const string &name) const override { - return get(name); - } - const IAttributeVector * - getAttributeStableEnum(const string &name) const override { - return get(name); - } - void - getAttributeList(std::vector<const IAttributeVector *> & list) const override { - Map::const_iterator pos = _vectors.begin(); - Map::const_iterator end = _vectors.end(); - for (; pos != end; ++pos) { - list.push_back(pos->second); - } - } - ~MyAttributeContext() override { - Map::iterator pos = _vectors.begin(); - Map::iterator end = _vectors.end(); - for (; pos != end; ++pos) { - delete pos->second; - } - } - - //------------------------------------------------------------------------- - - void add(IAttributeVector *attr) { - _vectors[attr->getName()] = attr; - } -}; - struct EmptyConstantValueRepo : public proton::matching::IConstantValueRepo { virtual vespalib::eval::ConstantValue::UP getConstant(const vespalib::string &) const override { return std::make_unique<proton::matching::ErrorConstantValue>(); @@ -151,7 +107,7 @@ struct MyWorld { Schema schema; Properties config; FakeSearchContext searchContext; - MyAttributeContext attributeContext; + MockAttributeContext attributeContext; SessionManager::SP sessionManager; DocumentMetaStore metaStore; MatchingStats matchingStats; @@ -327,14 +283,10 @@ struct MyWorld { } }; - struct DummyAttributeExecutor : public IAttributeExecutor { - void asyncForAttribute(const vespalib::string &, std::shared_ptr<IAttributeFunctor>) const override {} - }; void verify_diversity_filter(SearchRequest::SP req, bool expectDiverse) { Matcher::SP matcher = createMatcher(); search::fef::Properties overrides; - DummyAttributeExecutor attrExec; - auto mtf = matcher->create_match_tools_factory(*req, searchContext, attributeContext, attrExec, metaStore, overrides); + auto mtf = matcher->create_match_tools_factory(*req, searchContext, attributeContext, metaStore, overrides); auto diversity = mtf->createDiversifier(); EXPECT_EQUAL(expectDiverse, static_cast<bool>(diversity)); } @@ -343,9 +295,8 @@ struct MyWorld { Matcher::SP matcher = createMatcher(); SearchRequest::SP request = createSimpleRequest("f1", "spread"); search::fef::Properties overrides; - DummyAttributeExecutor attrExec; MatchToolsFactory::UP match_tools_factory = matcher->create_match_tools_factory( - *request, searchContext, attributeContext, attrExec, metaStore, overrides); + *request, searchContext, attributeContext, metaStore, overrides); MatchTools::UP match_tools = match_tools_factory->createMatchTools(); match_tools->setup_first_phase(); return match_tools->match_data().get_termwise_limit(); @@ -354,13 +305,12 @@ struct MyWorld { SearchReply::UP performSearch(SearchRequest::SP req, size_t threads) { Matcher::SP matcher = createMatcher(); SearchSession::OwnershipBundle owned_objects; - owned_objects.search_handler.reset(new MySearchHandler(matcher)); - owned_objects.context.reset(new MatchContext(std::make_unique<MyAttributeContext>(), - std::make_unique<FakeSearchContext>())); + owned_objects.search_handler = std::make_shared<MySearchHandler>(matcher); + owned_objects.context = std::make_unique<MatchContext>(std::make_unique<MockAttributeContext>(), + std::make_unique<FakeSearchContext>()); vespalib::SimpleThreadBundle threadBundle(threads); - DummyAttributeExecutor attrExec; SearchReply::UP reply = matcher->match(*req, threadBundle, searchContext, attributeContext, - attrExec, *sessionManager, metaStore, std::move(owned_objects)); + *sessionManager, metaStore, std::move(owned_objects)); matchingStats.add(matcher->getStats()); return reply; } @@ -392,14 +342,12 @@ struct MyWorld { FeatureSet::SP getSummaryFeatures(DocsumRequest::SP req) { Matcher::SP matcher = createMatcher(); - DummyAttributeExecutor attrExec; - return matcher->getSummaryFeatures(*req, searchContext, attributeContext, attrExec, *sessionManager); + return matcher->getSummaryFeatures(*req, searchContext, attributeContext, *sessionManager); } FeatureSet::SP getRankFeatures(DocsumRequest::SP req) { Matcher::SP matcher = createMatcher(); - DummyAttributeExecutor attrExec; - return matcher->getRankFeatures(*req, searchContext, attributeContext, attrExec, *sessionManager); + return matcher->getRankFeatures(*req, searchContext, attributeContext, *sessionManager); } }; diff --git a/searchcore/src/tests/proton/reference/document_db_reference/CMakeLists.txt b/searchcore/src/tests/proton/reference/document_db_reference/CMakeLists.txt index 00826843d9e..5dbe031d6aa 100644 --- a/searchcore/src/tests/proton/reference/document_db_reference/CMakeLists.txt +++ b/searchcore/src/tests/proton/reference/document_db_reference/CMakeLists.txt @@ -5,5 +5,6 @@ vespa_add_executable(searchcore_document_db_reference_test_app TEST DEPENDS searchcore_reference searchcore_attribute + searchlib_test ) vespa_add_test(NAME searchcore_document_db_reference_test_app COMMAND searchcore_document_db_reference_test_app) diff --git a/searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt b/searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt index 1db6f2118b3..46fe9ac0781 100644 --- a/searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt +++ b/searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt @@ -5,5 +5,6 @@ vespa_add_executable(searchcore_document_db_reference_resolver_test_app TEST DEPENDS searchcore_reference searchcore_attribute + searchlib_test ) vespa_add_test(NAME searchcore_document_db_reference_resolver_test_app COMMAND searchcore_document_db_reference_resolver_test_app) diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_usage_sampler_functor.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_usage_sampler_functor.cpp index e271f2f0bef..a1a8409e93b 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_usage_sampler_functor.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_usage_sampler_functor.cpp @@ -17,9 +17,10 @@ AttributeUsageSamplerFunctor::AttributeUsageSamplerFunctor( AttributeUsageSamplerFunctor::~AttributeUsageSamplerFunctor() = default; void -AttributeUsageSamplerFunctor::operator()(const search::AttributeVector & attributeVector) +AttributeUsageSamplerFunctor::operator()(const search::attribute::IAttributeVector & iAttributeVector) { // Executed by attribute writer thread + const auto & attributeVector = dynamic_cast<const search::AttributeVector &>(iAttributeVector); search::AddressSpaceUsage usage = attributeVector.getAddressSpaceUsage(); vespalib::string attributeName = attributeVector.getName(); _samplerContext->merge(usage, attributeName, _subDbName); diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_usage_sampler_functor.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_usage_sampler_functor.h index 1b06e1dff45..12461af0d27 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_usage_sampler_functor.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_usage_sampler_functor.h @@ -2,7 +2,7 @@ #pragma once -#include <vespa/searchlib/attribute/i_attribute_functor.h> +#include <vespa/searchcommon/attribute/i_attribute_functor.h> #include <memory> namespace proton { @@ -21,7 +21,7 @@ public: AttributeUsageSamplerFunctor(std::shared_ptr<AttributeUsageSamplerContext> samplerContext, const std::string &subDbname); ~AttributeUsageSamplerFunctor() override; - void operator()(const search::AttributeVector &attributeVector) override; + void operator()(const search::attribute::IAttributeVector &attributeVector) override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp index f08300ba3c6..2ca4fd0a20d 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.cpp @@ -11,7 +11,7 @@ #include <vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.h> #include <vespa/searchlib/attribute/attributecontext.h> #include <vespa/searchlib/attribute/attribute_read_guard.h> -#include <vespa/searchlib/attribute/i_attribute_functor.h> +#include <vespa/searchcommon/attribute/i_attribute_functor.h> #include <vespa/searchlib/attribute/interlock.h> #include <vespa/searchlib/common/isequencedtaskexecutor.h> #include <vespa/searchlib/common/threaded_compactable_lid_space.h> @@ -423,6 +423,7 @@ namespace { class CombinedAttributeContext : public IAttributeContext { private: + using IAttributeFunctor = search::attribute::IAttributeFunctor; AttributeContext _ctx; ImportedAttributesContext _importedCtx; @@ -433,28 +434,31 @@ public: _importedCtx(importedAttributes) { } - virtual const IAttributeVector *getAttribute(const vespalib::string &name) const override { + const IAttributeVector *getAttribute(const vespalib::string &name) const override { const IAttributeVector *result = _ctx.getAttribute(name); if (result == nullptr) { result = _importedCtx.getAttribute(name); } return result; } - virtual const IAttributeVector *getAttributeStableEnum(const vespalib::string &name) const override { + const IAttributeVector *getAttributeStableEnum(const vespalib::string &name) const override { const IAttributeVector *result = _ctx.getAttributeStableEnum(name); if (result == nullptr) { result = _importedCtx.getAttributeStableEnum(name); } return result; } - virtual void getAttributeList(std::vector<const IAttributeVector *> &list) const override { + void getAttributeList(std::vector<const IAttributeVector *> &list) const override { _ctx.getAttributeList(list); _importedCtx.getAttributeList(list); } - virtual void releaseEnumGuards() override { + void releaseEnumGuards() override { _ctx.releaseEnumGuards(); _importedCtx.releaseEnumGuards(); } + void asyncForAttribute(const vespalib::string &name, std::shared_ptr<IAttributeFunctor> func) const override { + _ctx.asyncForAttribute(name, std::move(func)); + } }; } @@ -462,8 +466,8 @@ public: IAttributeContext::UP AttributeManager::createContext() const { - if (_importedAttributes.get() != nullptr) { - return std::make_unique<CombinedAttributeContext>(*this, *_importedAttributes.get()); + if (_importedAttributes) { + return std::make_unique<CombinedAttributeContext>(*this, *_importedAttributes); } return std::make_unique<AttributeContext>(*this); } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h index 1ddba45ac46..78760d466e8 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributemanager.h @@ -36,6 +36,7 @@ private: using ShrinkerSP = std::shared_ptr<ShrinkLidSpaceFlushTarget>; using IFlushTargetSP = std::shared_ptr<searchcorespi::IFlushTarget>; using AttributeVectorSP = std::shared_ptr<search::AttributeVector>; + using AttributeReadGuard = search::attribute::AttributeReadGuard; class AttributeWrap { @@ -80,9 +81,7 @@ private: HwInfo _hwInfo; std::unique_ptr<ImportedAttributesRepo> _importedAttributes; - AttributeVectorSP internalAddAttribute(const AttributeSpec &spec, - uint64_t serialNum, - const IAttributeFactory &factory); + AttributeVectorSP internalAddAttribute(const AttributeSpec &spec, uint64_t serialNum, const IAttributeFactory &factory); void addAttribute(const AttributeWrap &attribute, const ShrinkerSP &shrinker); @@ -90,12 +89,9 @@ private: const FlushableWrap *findFlushable(const vespalib::string &name) const; - void transferExistingAttributes(const AttributeManager &currMgr, - const Spec &newSpec, - Spec::AttributeList &toBeAdded); + void transferExistingAttributes(const AttributeManager &currMgr, const Spec &newSpec, Spec::AttributeList &toBeAdded); - void addNewAttributes(const Spec &newSpec, - const Spec::AttributeList &toBeAdded, + void addNewAttributes(const Spec &newSpec, const Spec::AttributeList &toBeAdded, IAttributeInitializerRegistry &initializerRegistry); void transferExtraAttributes(const AttributeManager &currMgr); @@ -118,8 +114,7 @@ public: const IAttributeFactory::SP &factory, const HwInfo &hwInfo); - AttributeManager(const AttributeManager &currMgr, - const Spec &newSpec, + AttributeManager(const AttributeManager &currMgr, const Spec &newSpec, IAttributeInitializerRegistry &initializerRegistry); ~AttributeManager() override; @@ -141,7 +136,7 @@ public: // Implements search::IAttributeManager search::AttributeGuard::UP getAttribute(const vespalib::string &name) const override; - std::unique_ptr<search::attribute::AttributeReadGuard> getAttributeReadGuard(const string &name, bool stableEnumGuard) const override; + std::unique_ptr<AttributeReadGuard> getAttributeReadGuard(const string &name, bool stableEnumGuard) const override; /** * Fills all regular registered attributes (not extra attributes) diff --git a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp index e8878b29678..7928bc5cc27 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/filter_attribute_manager.cpp @@ -4,7 +4,7 @@ #include <vespa/searchlib/common/isequencedtaskexecutor.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/searchlib/attribute/attributevector.h> -#include <vespa/searchlib/attribute/i_attribute_functor.h> +#include <vespa/searchcommon/attribute/i_attribute_functor.h> #include <vespa/searchlib/attribute/attribute_read_guard.h> using search::AttributeGuard; diff --git a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h index 6df9b207281..5df8cf0d0bf 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/i_attribute_manager.h @@ -5,7 +5,7 @@ #include "attribute_collection_spec.h" #include "exclusive_attribute_read_accessor.h" #include "i_attribute_factory.h" -#include <vespa/searchlib/attribute/i_attribute_functor.h> +#include <vespa/searchcommon/attribute/i_attribute_functor.h> #include <vespa/searchcorespi/flush/iflushtarget.h> #include <vespa/searchlib/attribute/iattributemanager.h> #include <vespa/searchlib/common/serialnum.h> @@ -26,7 +26,7 @@ class ImportedAttributesRepo; * The attribute manager should handle initialization and loading of attribute vectors, * and then provide access to the attributes for feeding, searching and flushing. */ -struct IAttributeManager : public search::IAttributeManager, public search::attribute::IAttributeExecutor +struct IAttributeManager : public search::IAttributeManager { using SP = std::shared_ptr<IAttributeManager>; using OnWriteDoneType = const std::shared_ptr<search::IDestructorCallback> &; diff --git a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp index 8e4714d6fa2..92b4d70893d 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.cpp @@ -14,17 +14,15 @@ using LockGuard = std::lock_guard<std::mutex>; namespace proton { const IAttributeVector * -ImportedAttributesContext::getOrCacheAttribute(const vespalib::string &name, - AttributeCache &attributes, - bool stableEnumGuard, - const LockGuard &) const +ImportedAttributesContext::getOrCacheAttribute(const vespalib::string &name, AttributeCache &attributes, + bool stableEnumGuard, const LockGuard &) const { auto itr = attributes.find(name); if (itr != attributes.end()) { return itr->second->attribute(); } ImportedAttributeVector::SP result = _repo.get(name); - if (result.get() != nullptr) { + if (result) { auto insRes = attributes.emplace(name, result->makeReadGuard(stableEnumGuard)); return insRes.first->second->attribute(); } else { @@ -40,9 +38,7 @@ ImportedAttributesContext::ImportedAttributesContext(const ImportedAttributesRep { } -ImportedAttributesContext::~ImportedAttributesContext() -{ -} +ImportedAttributesContext::~ImportedAttributesContext() = default; const IAttributeVector * ImportedAttributesContext::getAttribute(const vespalib::string &name) const @@ -74,5 +70,10 @@ ImportedAttributesContext::releaseEnumGuards() LockGuard guard(_cacheMutex); _enumGuardedAttributes.clear(); } - + +void +ImportedAttributesContext::asyncForAttribute(const vespalib::string &, std::shared_ptr<IAttributeFunctor> ) const { + throw std::runtime_error("proton::ImportedAttributesContext::asyncForAttribute should never be called."); +} + } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.h b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.h index 90f95ce6447..0c81a5c4688 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_context.h @@ -7,13 +7,12 @@ #include <mutex> #include <unordered_map> -namespace search { -class AttributeGuard; -namespace attribute { -class AttributeReadGuard; -class IAttributeVector; -class ImportedAttributeVector; -}} +namespace search { class AttributeGuard; } +namespace search::attribute { + class AttributeReadGuard; + class IAttributeVector; + class ImportedAttributeVector; +} namespace proton { @@ -30,6 +29,7 @@ private: using AttributeReadGuard = search::attribute::AttributeReadGuard; using IAttributeVector = search::attribute::IAttributeVector; using ImportedAttributeVector = search::attribute::ImportedAttributeVector; + using IAttributeFunctor = search::attribute::IAttributeFunctor; using AttributeCache = std::unordered_map<vespalib::string, std::unique_ptr<AttributeReadGuard>, vespalib::hash<vespalib::string>>; using LockGuard = std::lock_guard<std::mutex>; @@ -39,20 +39,20 @@ private: mutable AttributeCache _enumGuardedAttributes; mutable std::mutex _cacheMutex; - const IAttributeVector *getOrCacheAttribute(const vespalib::string &name, - AttributeCache &attributes, - bool stableEnumGuard, - const LockGuard &) const; + const IAttributeVector *getOrCacheAttribute(const vespalib::string &name, AttributeCache &attributes, + bool stableEnumGuard, const LockGuard &) const; public: ImportedAttributesContext(const ImportedAttributesRepo &repo); - ~ImportedAttributesContext(); + ~ImportedAttributesContext() override; // Implements search::attribute::IAttributeContext - virtual const IAttributeVector *getAttribute(const vespalib::string &name) const override; - virtual const IAttributeVector *getAttributeStableEnum(const vespalib::string &name) const override; - virtual void getAttributeList(std::vector<const IAttributeVector *> &list) const override; - virtual void releaseEnumGuards() override; + const IAttributeVector *getAttribute(const vespalib::string &name) const override; + const IAttributeVector *getAttributeStableEnum(const vespalib::string &name) const override; + void getAttributeList(std::vector<const IAttributeVector *> &list) const override; + void releaseEnumGuards() override; + + void asyncForAttribute(const vespalib::string &name, std::shared_ptr<IAttributeFunctor> func) const override; }; } diff --git a/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.cpp b/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.cpp index 908c7e887a3..a9d599c316d 100644 --- a/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.cpp +++ b/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.cpp @@ -137,8 +137,7 @@ DocsumContext::createSlimeReply() DocsumContext::DocsumContext(const DocsumRequest & request, IDocsumWriter & docsumWriter, IDocsumStore & docsumStore, const Matcher::SP & matcher, ISearchContext & searchCtx, IAttributeContext & attrCtx, - IAttributeManager & attrMgr, const IAttributeExecutor & attrExec, - SessionManager & sessionMgr) : + IAttributeManager & attrMgr, SessionManager & sessionMgr) : _request(request), _docsumWriter(docsumWriter), _docsumStore(docsumStore), @@ -146,7 +145,6 @@ DocsumContext::DocsumContext(const DocsumRequest & request, IDocsumWriter & docs _searchCtx(searchCtx), _attrCtx(attrCtx), _attrMgr(attrMgr), - _attrExec(attrExec), _docsumState(*this), _sessionMgr(sessionMgr) { @@ -167,7 +165,7 @@ DocsumContext::FillSummaryFeatures(search::docsummary::GetDocsumsState * state, { assert(&_docsumState == state); if (_matcher->canProduceSummaryFeatures()) { - state->_summaryFeatures = _matcher->getSummaryFeatures(_request, _searchCtx, _attrCtx, _attrExec, _sessionMgr); + state->_summaryFeatures = _matcher->getSummaryFeatures(_request, _searchCtx, _attrCtx, _sessionMgr); } state->_summaryFeaturesCached = false; } @@ -180,7 +178,7 @@ DocsumContext::FillRankFeatures(search::docsummary::GetDocsumsState * state, sea if ((state->_args.GetQueryFlags() & search::fs4transport::QFLAG_DUMP_FEATURES) == 0) { return; } - state->_rankFeatures = _matcher->getRankFeatures(_request, _searchCtx, _attrCtx, _attrExec, _sessionMgr); + state->_rankFeatures = _matcher->getRankFeatures(_request, _searchCtx, _attrCtx, _sessionMgr); } namespace { diff --git a/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.h b/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.h index 4be67628b1f..45f3ca8e44f 100644 --- a/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.h +++ b/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.h @@ -23,7 +23,6 @@ private: matching::ISearchContext & _searchCtx; search::attribute::IAttributeContext & _attrCtx; search::IAttributeManager & _attrMgr; - const search::attribute::IAttributeExecutor & _attrExec; search::docsummary::GetDocsumsState _docsumState; matching::SessionManager & _sessionMgr; @@ -41,7 +40,6 @@ public: matching::ISearchContext & searchCtx, search::attribute::IAttributeContext & attrCtx, search::IAttributeManager & attrMgr, - const search::attribute::IAttributeExecutor & attrExec, matching::SessionManager & sessionMgr); search::engine::DocsumReply::UP getDocsums(); diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp index a88a44130f2..63c3be1aa14 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp @@ -139,9 +139,10 @@ MatchMaster::getFeatureSet(const MatchToolsFactory &mtf, LOG(debug, "getFeatureSet: Did not find hit for docid '%u'. Skipping hit", docs[i]); } } - if (mtf.hasOnReRankOperation()) { - mtf.runOnReRankOperation(AttributeOperation::create(mtf.getOnSummaryAttributeType(), - mtf.getOnSummaryOperation(), docs)); + auto onSummaryTask = mtf.createOnSummaryTask(); + if (onSummaryTask) { + onSummaryTask->run(AttributeOperation::create(onSummaryTask->getAttributeType(), + onSummaryTask->getOperation(), docs)); } return retval; } diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp index 2591a176e19..da4e5972cd5 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp @@ -3,7 +3,7 @@ #include "match_thread.h" #include "document_scorer.h" #include <vespa/searchlib/attribute/attribute_operation.h> -#include <vespa/searchlib/attribute/i_attribute_functor.h> +#include <vespa/searchcommon/attribute/i_attribute_functor.h> #include <vespa/searchcore/grouping/groupingmanager.h> #include <vespa/searchcore/grouping/groupingcontext.h> #include <vespa/searchlib/common/bitvector.h> @@ -280,9 +280,10 @@ MatchThread::findMatches(MatchTools &tools) kept_hits.clear(); } uint32_t reRanked = hits.reRank(scorer, std::move(kept_hits)); - if (mtf.hasOnReRankOperation()) { - mtf.runOnReRankOperation(AttributeOperation::create(mtf.getOnReRankAttributeType(), - mtf.getOnReRankOperation(), hits.getReRankedHits())); + auto onReRankTask = mtf.createOnReRankTask(); + if (onReRankTask) { + onReRankTask->run(AttributeOperation::create(onReRankTask->getAttributeType(), + onReRankTask->getOperation(), hits.getReRankedHits())); } thread_stats.docsReRanked(reRanked); } @@ -351,8 +352,9 @@ MatchThread::processResult(const Doom & hardDoom, } } const MatchToolsFactory & mtf = matchToolsFactory; - if (mtf.hasOnMatchOperation() ) { - mtf.runOnMatchOperation(AttributeOperation::create(mtf.getOnMatchAttributeType(), mtf.getOnMatchOperation(), + auto onMatchTask = mtf.createOnMatchTask(); + if (onMatchTask ) { + onMatchTask->run(AttributeOperation::create(onMatchTask->getAttributeType(), onMatchTask->getOperation(), search::ResultSet::stealResult(std::move(*result)))); } if (hasGrouping) { diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp index 8b289bd10eb..f2147029458 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp @@ -12,6 +12,7 @@ using search::attribute::IAttributeContext; using search::queryeval::IRequestContext; using search::queryeval::IDiversifier; using search::attribute::diversity::DiversityFilter; +using search::attribute::BasicType; using namespace search::fef; using namespace search::fef::indexproperties::matchphase; @@ -151,7 +152,6 @@ MatchToolsFactory(QueryLimiter & queryLimiter, vespalib::stringref queryStack, const vespalib::string & location, const ViewResolver & viewResolver, - const IAttributeExecutor & attrExec, const IDocumentMetaStore & metaStore, const IIndexEnvironment & indexEnv, const RankSetup & rankSetup, @@ -164,7 +164,6 @@ MatchToolsFactory(QueryLimiter & queryLimiter, _match_limiter(), _queryEnv(indexEnv, attributeContext, rankProperties), _mdl(), - _attrExec(attrExec), _rankSetup(rankSetup), _featureOverrides(featureOverrides), _diversityParams(), @@ -218,70 +217,45 @@ MatchToolsFactory::createDiversifier() const _diversityParams.cutoff_strategy == DiversityParams::CutoffStrategy::STRICT); } -bool -MatchToolsFactory::hasOnMatchOperation() const { - return ! execute::onmatch::Attribute::lookup(_queryEnv.getProperties()).empty() && - ! execute::onmatch::Operation::lookup(_queryEnv.getProperties()).empty(); +std::unique_ptr<AttributeOperationTask> +MatchToolsFactory::createTask(vespalib::stringref attribute, vespalib::stringref operation) const { + return (!attribute.empty() && ! operation.empty()) + ? std::make_unique<AttributeOperationTask>(_requestContext, attribute, operation) + : std::unique_ptr<AttributeOperationTask>(); } - -vespalib::string -MatchToolsFactory::getOnMatchOperation() const { - return execute::onmatch::Operation::lookup(_queryEnv.getProperties()); -} - -void -MatchToolsFactory::runOnMatchOperation(std::shared_ptr<IAttributeFunctor> count) const { - _attrExec.asyncForAttribute(execute::onmatch::Attribute::lookup(_queryEnv.getProperties()), std::move(count)); -} - -search::attribute::BasicType -MatchToolsFactory::getOnMatchAttributeType() const { - auto attr = _requestContext.getAttribute(execute::onmatch::Attribute::lookup(_queryEnv.getProperties())); - return attr ? attr->getBasicType() : BasicType::NONE; +std::unique_ptr<AttributeOperationTask> +MatchToolsFactory::createOnMatchTask() const { + return createTask(execute::onmatch::Attribute::lookup(_queryEnv.getProperties()), + execute::onmatch::Operation::lookup(_queryEnv.getProperties())); } - -bool -MatchToolsFactory::hasOnReRankOperation() const { - return ! execute::onrerank::Attribute::lookup(_queryEnv.getProperties()).empty() && - ! execute::onrerank::Operation::lookup(_queryEnv.getProperties()).empty(); +std::unique_ptr<AttributeOperationTask> +MatchToolsFactory::createOnReRankTask() const { + return createTask(execute::onrerank::Attribute::lookup(_queryEnv.getProperties()), + execute::onrerank::Operation::lookup(_queryEnv.getProperties())); } - -vespalib::string -MatchToolsFactory::getOnReRankOperation() const { - return execute::onrerank::Operation::lookup(_queryEnv.getProperties()); +std::unique_ptr<AttributeOperationTask> +MatchToolsFactory::createOnSummaryTask() const { + return createTask(execute::onsummary::Attribute::lookup(_queryEnv.getProperties()), + execute::onsummary::Operation::lookup(_queryEnv.getProperties())); } -void -MatchToolsFactory::runOnReRankOperation(std::shared_ptr<IAttributeFunctor> count) const { - _attrExec.asyncForAttribute(execute::onrerank::Attribute::lookup(_queryEnv.getProperties()), std::move(count)); +AttributeOperationTask::AttributeOperationTask(const RequestContext & requestContext, + vespalib::stringref attribute, vespalib::stringref operation) + : _requestContext(requestContext), + _attribute(attribute), + _operation(operation) +{ } search::attribute::BasicType -MatchToolsFactory::getOnReRankAttributeType() const { - auto attr = _requestContext.getAttribute(execute::onrerank::Attribute::lookup(_queryEnv.getProperties())); +AttributeOperationTask::getAttributeType() const { + auto attr = _requestContext.getAttribute(_attribute); return attr ? attr->getBasicType() : BasicType::NONE; } -bool -MatchToolsFactory::hasOnSummaryOperation() const { - return ! execute::onsummary::Attribute::lookup(_queryEnv.getProperties()).empty() && - ! execute::onsummary::Operation::lookup(_queryEnv.getProperties()).empty(); -} - -vespalib::string -MatchToolsFactory::getOnSummaryOperation() const { - return execute::onsummary::Operation::lookup(_queryEnv.getProperties()); -} - void -MatchToolsFactory::runOnSummaryOperation(std::shared_ptr<IAttributeFunctor> count) const { - _attrExec.asyncForAttribute(execute::onsummary::Attribute::lookup(_queryEnv.getProperties()), std::move(count)); -} - -search::attribute::BasicType -MatchToolsFactory::getOnSummaryAttributeType() const { - auto attr = _requestContext.getAttribute(execute::onsummary::Attribute::lookup(_queryEnv.getProperties())); - return attr ? attr->getBasicType() : BasicType::NONE; +AttributeOperationTask::run(std::shared_ptr<IAttributeFunctor> func) const { + _requestContext.asyncForAttribute(_attribute, std::move(func)); } } diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.h b/searchcore/src/vespa/searchcore/proton/matching/match_tools.h index 9a28dc1ed05..af3665c4d72 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.h +++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.h @@ -10,7 +10,7 @@ #include "match_phase_limiter.h" #include "handlerecorder.h" #include "requestcontext.h" -#include <vespa/searchlib/attribute/i_attribute_functor.h> +#include <vespa/searchcommon/attribute/i_attribute_functor.h> #include <vespa/searchlib/queryeval/blueprint.h> #include <vespa/searchlib/fef/fef.h> #include <vespa/searchlib/common/idocumentmetastore.h> @@ -69,10 +69,23 @@ public: void setup_dump(); }; +class AttributeOperationTask { +public: + using IAttributeFunctor = search::attribute::IAttributeFunctor; + AttributeOperationTask(const RequestContext & requestContext, + vespalib::stringref attribute, vespalib::stringref operation); + void run(std::shared_ptr<IAttributeFunctor> func) const; + search::attribute::BasicType getAttributeType() const; + const vespalib::string & getOperation() const { return _operation; } +private: + const RequestContext & _requestContext; + vespalib::string _attribute; + vespalib::string _operation; +}; + class MatchToolsFactory : public vespalib::noncopyable { private: - using IAttributeExecutor = search::attribute::IAttributeExecutor; using IAttributeFunctor = search::attribute::IAttributeFunctor; QueryLimiter & _queryLimiter; RequestContext _requestContext; @@ -81,11 +94,13 @@ private: MaybeMatchPhaseLimiter::UP _match_limiter; QueryEnvironment _queryEnv; search::fef::MatchDataLayout _mdl; - const IAttributeExecutor & _attrExec; const search::fef::RankSetup & _rankSetup; const search::fef::Properties & _featureOverrides; DiversityParams _diversityParams; bool _valid; + + std::unique_ptr<AttributeOperationTask> + createTask(vespalib::stringref attribute, vespalib::stringref operation) const; public: using UP = std::unique_ptr<MatchToolsFactory>; using BasicType = search::attribute::BasicType; @@ -98,7 +113,6 @@ public: vespalib::stringref queryStack, const vespalib::string &location, const ViewResolver &viewResolver, - const IAttributeExecutor & attrExec, const search::IDocumentMetaStore &metaStore, const search::fef::IIndexEnvironment &indexEnv, const search::fef::RankSetup &rankSetup, @@ -112,18 +126,10 @@ public: std::unique_ptr<search::queryeval::IDiversifier> createDiversifier() const; search::queryeval::Blueprint::HitEstimate estimate() const { return _query.estimate(); } bool has_first_phase_rank() const { return !_rankSetup.getFirstPhaseRank().empty(); } - bool hasOnMatchOperation() const; - BasicType getOnMatchAttributeType() const; - vespalib::string getOnMatchOperation() const; - void runOnMatchOperation(std::shared_ptr<IAttributeFunctor> count) const; - bool hasOnReRankOperation() const; - BasicType getOnReRankAttributeType() const; - vespalib::string getOnReRankOperation() const; - void runOnReRankOperation(std::shared_ptr<IAttributeFunctor> count) const; - bool hasOnSummaryOperation() const; - BasicType getOnSummaryAttributeType() const; - vespalib::string getOnSummaryOperation() const; - void runOnSummaryOperation(std::shared_ptr<IAttributeFunctor> count) const; + std::unique_ptr<AttributeOperationTask> createOnMatchTask() const; + std::unique_ptr<AttributeOperationTask> createOnReRankTask() const; + std::unique_ptr<AttributeOperationTask> createOnSummaryTask() const; + const RequestContext & requestContext() const { return _requestContext; } }; diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp index c387d3ea4eb..be0a720f1c1 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp @@ -95,7 +95,7 @@ bool willNotNeedRanking(const SearchRequest & request, const GroupingContext & g FeatureSet::SP Matcher::getFeatureSet(const DocsumRequest & req, ISearchContext & searchCtx, IAttributeContext & attrCtx, - const IAttributeExecutor & attrExec, SessionManager & sessionMgr, bool summaryFeatures) + SessionManager & sessionMgr, bool summaryFeatures) { SessionId sessionId(&req.sessionId[0], req.sessionId.size()); if (!sessionId.empty()) { @@ -113,7 +113,7 @@ Matcher::getFeatureSet(const DocsumRequest & req, ISearchContext & searchCtx, IA } StupidMetaStore metaStore; - MatchToolsFactory::UP mtf = create_match_tools_factory(req, searchCtx, attrCtx, attrExec, metaStore, + MatchToolsFactory::UP mtf = create_match_tools_factory(req, searchCtx, attrCtx, metaStore, req.propertiesMap.featureOverrides()); if (!mtf->valid()) { LOG(warning, "getFeatureSet(%s): query execution failed (invalid query). Returning empty feature set", @@ -159,8 +159,8 @@ using search::fef::indexproperties::softtimeout::Factor; std::unique_ptr<MatchToolsFactory> Matcher::create_match_tools_factory(const search::engine::Request &request, ISearchContext &searchContext, - IAttributeContext &attrContext, const IAttributeExecutor & attrExec, - const search::IDocumentMetaStore &metaStore, const Properties &feature_overrides) const + IAttributeContext &attrContext, const search::IDocumentMetaStore &metaStore, + const Properties &feature_overrides) const { const Properties & rankProperties = request.propertiesMap.rankProperties(); bool softTimeoutEnabled = Enabled::lookup(rankProperties, _rankSetup->getSoftTimeoutEnabled()); @@ -176,8 +176,7 @@ Matcher::create_match_tools_factory(const search::engine::Request &request, ISea return std::make_unique<MatchToolsFactory>(_queryLimiter, vespalib::Doom(_clock, safeDoom), vespalib::Doom(_clock, request.getTimeOfDoom()), searchContext, attrContext, request.getStackRef(), request.location, _viewResolver, - attrExec, metaStore, _indexEnv, *_rankSetup, - rankProperties, feature_overrides); + metaStore, _indexEnv, *_rankSetup, rankProperties, feature_overrides); } SearchReply::UP @@ -205,8 +204,7 @@ Matcher::computeNumThreadsPerSearch(Blueprint::HitEstimate hits, const Propertie SearchReply::UP Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundle, - ISearchContext &searchContext, IAttributeContext &attrContext, - const IAttributeExecutor & attrExec, SessionManager &sessionMgr, + ISearchContext &searchContext, IAttributeContext &attrContext, SessionManager &sessionMgr, const search::IDocumentMetaStore &metaStore, SearchSession::OwnershipBundle &&owned_objects) { fastos::StopWatch total_matching_time; @@ -237,7 +235,7 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl feature_overrides = owned_objects.feature_overrides.get(); } MatchToolsFactory::UP mtf = create_match_tools_factory(request, searchContext, attrContext, - attrExec, metaStore, *feature_overrides); + metaStore, *feature_overrides); if (!mtf->valid()) { reply->errorCode = ECODE_QUERY_PARSE_ERROR; reply->errorMessage = "query execution failed (invalid query)"; @@ -326,17 +324,17 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl } FeatureSet::SP -Matcher::getSummaryFeatures(const DocsumRequest & req, ISearchContext & searchCtx, IAttributeContext & attrCtx, - const IAttributeExecutor & attrExec, SessionManager &sessionMgr) +Matcher::getSummaryFeatures(const DocsumRequest & req, ISearchContext & searchCtx, + IAttributeContext & attrCtx, SessionManager &sessionMgr) { - return getFeatureSet(req, searchCtx, attrCtx, attrExec, sessionMgr, true); + return getFeatureSet(req, searchCtx, attrCtx, sessionMgr, true); } FeatureSet::SP -Matcher::getRankFeatures(const DocsumRequest & req, ISearchContext & searchCtx, IAttributeContext & attrCtx, - const IAttributeExecutor & attrExec, SessionManager &sessionMgr) +Matcher::getRankFeatures(const DocsumRequest & req, ISearchContext & searchCtx, + IAttributeContext & attrCtx, SessionManager &sessionMgr) { - return getFeatureSet(req, searchCtx, attrCtx, attrExec, sessionMgr, false); + return getFeatureSet(req, searchCtx, attrCtx, sessionMgr, false); } } diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.h b/searchcore/src/vespa/searchcore/proton/matching/matcher.h index 15df21378d2..0fed257f0c0 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.h +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.h @@ -8,7 +8,7 @@ #include "search_session.h" #include "viewresolver.h" #include <vespa/searchcore/proton/matching/querylimiter.h> -#include <vespa/searchlib/attribute/i_attribute_functor.h> +#include <vespa/searchcommon/attribute/i_attribute_functor.h> #include <vespa/searchlib/common/featureset.h> #include <vespa/searchlib/common/resultset.h> #include <vespa/searchlib/queryeval/blueprint.h> @@ -45,7 +45,9 @@ class MatchToolsFactory; class Matcher { private: - using IAttributeExecutor = search::attribute::IAttributeExecutor; + using IAttributeContext = search::attribute::IAttributeContext; + using DocsumRequest = search::engine::DocsumRequest; + using Properties = search::fef::Properties; IndexEnvironment _indexEnv; search::fef::BlueprintFactory _blueprintFactory; search::fef::RankSetup::SP _rankSetup; @@ -57,16 +59,15 @@ private: uint32_t _distributionKey; search::FeatureSet::SP - getFeatureSet(const search::engine::DocsumRequest & req, ISearchContext & searchCtx, - search::attribute::IAttributeContext & attrCtx, - const IAttributeExecutor & attrExec, SessionManager &sessionMgr, bool summaryFeatures); + getFeatureSet(const DocsumRequest & req, ISearchContext & searchCtx, IAttributeContext & attrCtx, + SessionManager &sessionMgr, bool summaryFeatures); std::unique_ptr<search::engine::SearchReply> handleGroupingSession(SessionManager &sessionMgr, search::grouping::GroupingContext & groupingContext, std::unique_ptr<search::grouping::GroupingSession> gs); size_t computeNumThreadsPerSearch(search::queryeval::Blueprint::HitEstimate hits, - const search::fef::Properties & rankProperties) const; + const Properties & rankProperties) const; public: /** * Convenience typedefs. @@ -85,7 +86,7 @@ public: * @param props ranking configuration * @param clock used for timeout handling **/ - Matcher(const search::index::Schema &schema, const search::fef::Properties &props, + Matcher(const search::index::Schema &schema, const Properties &props, const vespalib::Clock &clock, QueryLimiter &queryLimiter, const IConstantValueRepo &constantValueRepo, uint32_t distributionKey); @@ -104,10 +105,8 @@ public: **/ std::unique_ptr<MatchToolsFactory> create_match_tools_factory(const search::engine::Request &request, ISearchContext &searchContext, - search::attribute::IAttributeContext &attrContext, - const IAttributeExecutor & attrExec, - const search::IDocumentMetaStore &metaStore, - const search::fef::Properties &feature_overrides) const; + IAttributeContext &attrContext, const search::IDocumentMetaStore &metaStore, + const Properties &feature_overrides) const; /** * Perform a search against this matcher. @@ -122,8 +121,8 @@ public: **/ std::unique_ptr<search::engine::SearchReply> match(const search::engine::SearchRequest &request, vespalib::ThreadBundle &threadBundle, - ISearchContext &searchContext, search::attribute::IAttributeContext &attrContext, - const IAttributeExecutor & attrExec, SessionManager &sessionManager, const search::IDocumentMetaStore &metaStore, + ISearchContext &searchContext, IAttributeContext &attrContext, + SessionManager &sessionManager, const search::IDocumentMetaStore &metaStore, SearchSession::OwnershipBundle &&owned_objects); /** @@ -137,9 +136,8 @@ public: * @return calculated summary features. **/ search::FeatureSet::SP - getSummaryFeatures(const search::engine::DocsumRequest & req, ISearchContext & searchCtx, - search::attribute::IAttributeContext & attrCtx, - const IAttributeExecutor & attrExec, SessionManager &sessionManager); + getSummaryFeatures(const DocsumRequest & req, ISearchContext & searchCtx, + IAttributeContext & attrCtx, SessionManager &sessionManager); /** * Perform matching for the documents in the given docsum request @@ -152,9 +150,8 @@ public: * @return calculated rank features. **/ search::FeatureSet::SP - getRankFeatures(const search::engine::DocsumRequest & req, ISearchContext & searchCtx, - search::attribute::IAttributeContext & attrCtx, - const IAttributeExecutor & attrExec, SessionManager &sessionManager); + getRankFeatures(const DocsumRequest & req, ISearchContext & searchCtx, + IAttributeContext & attrCtx, SessionManager &sessionManager); /** * @return true if this rankprofile has summary-features enabled diff --git a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp index 8cf8a2a7807..c275337cc7e 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp @@ -23,4 +23,8 @@ RequestContext::getAttributeStableEnum(const vespalib::string &name) const return _attributeContext.getAttributeStableEnum(name); } +void RequestContext::asyncForAttribute(const vespalib::string &name, std::shared_ptr<IAttributeFunctor> func) const { + _attributeContext.asyncForAttribute(name, std::move(func)); +} + } diff --git a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h index 60e9c638c33..91e1e906e87 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h +++ b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h @@ -7,14 +7,19 @@ namespace proton { -class RequestContext : public search::queryeval::IRequestContext +class RequestContext : public search::queryeval::IRequestContext, + public search::attribute::IAttributeExecutor { public: using IAttributeContext = search::attribute::IAttributeContext; + using IAttributeFunctor = search::attribute::IAttributeFunctor; using Doom = vespalib::Doom; RequestContext(const Doom & softDoom, IAttributeContext & attributeContext); const Doom & getSoftDoom() const override { return _softDoom; } const search::attribute::IAttributeVector *getAttribute(const vespalib::string &name) const override; + + void asyncForAttribute(const vespalib::string &name, std::shared_ptr<IAttributeFunctor> func) const override; + const search::attribute::IAttributeVector *getAttributeStableEnum(const vespalib::string &name) const override; private: const Doom _softDoom; diff --git a/searchcore/src/vespa/searchcore/proton/server/matchview.cpp b/searchcore/src/vespa/searchcore/proton/server/matchview.cpp index ab9a4b93b5f..9af648917c4 100644 --- a/searchcore/src/vespa/searchcore/proton/server/matchview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/matchview.cpp @@ -77,7 +77,7 @@ MatchView::match(const ISearchHandler::SP &searchHandler, const SearchRequest &r MatchContext *ctx = owned_objects.context.get(); const search::IDocumentMetaStore & dms = owned_objects.readGuard->get(); return matcher->match(req, threadBundle, ctx->getSearchContext(), ctx->getAttributeContext(), - *_attrMgr, *_sessionMgr, dms, std::move(owned_objects)); + *_sessionMgr, dms, std::move(owned_objects)); } diff --git a/searchcore/src/vespa/searchcore/proton/server/searchview.cpp b/searchcore/src/vespa/searchcore/proton/server/searchview.cpp index 6879e106c5e..c5572923784 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchview.cpp @@ -149,8 +149,7 @@ SearchView::getDocsumsInternal(const DocsumRequest & req) MatchContext::UP mctx = _matchView->createContext(); auto ctx = std::make_unique<DocsumContext>(req, _summarySetup->getDocsumWriter(), *store, matcher, mctx->getSearchContext(), mctx->getAttributeContext(), - *_summarySetup->getAttributeManager(), *_matchView->getAttributeManager(), - *getSessionManager()); + *_summarySetup->getAttributeManager(), *getSessionManager()); SearchView::InternalDocsumReply reply(ctx->getDocsums(), true); uint64_t endGeneration = readGuard->get().getCurrentGeneration(); if (startGeneration != endGeneration) { |