diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-02-22 21:29:57 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-02-22 21:31:21 +0000 |
commit | fb751b67469af516373874a44c307fa1af2c6a83 (patch) | |
tree | 82819b4301fb2d01ccce8b6cc133a691ecff9e22 | |
parent | 6a31d94bcc91fad03a8f4058edc9139d29c58118 (diff) |
Allow passing const SearchView
11 files changed, 31 insertions, 82 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp index 74e3e903540..f1035776a8f 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp @@ -361,7 +361,7 @@ public: _immediateCommit(immediateCommit), _onWriteDone(onWriteDone) {} - ~BatchRemoveTask() override {} + ~BatchRemoveTask() override = default; void run() override { for (auto field : _writeCtx.getFields()) { auto &attr = field.getAttribute(); @@ -469,9 +469,9 @@ AttributeWriter::internalRemove(SerialNum serialNum, DocumentIdT lid, bool immed } } -AttributeWriter::AttributeWriter(const proton::IAttributeManager::SP &mgr) - : _mgr(mgr), - _attributeFieldWriter(mgr->getAttributeFieldWriter()), +AttributeWriter::AttributeWriter(proton::IAttributeManager::SP mgr) + : _mgr(std::move(mgr)), + _attributeFieldWriter(_mgr->getAttributeFieldWriter()), _writeContexts(), _dataType(nullptr), _hasStructFieldAttribute(false), diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.h index 9e5d8f4ce5d..8c9b756cd89 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.h @@ -74,7 +74,7 @@ private: bool immediateCommit, OnWriteDoneType onWriteDone); public: - AttributeWriter(const proton::IAttributeManager::SP &mgr); + AttributeWriter(proton::IAttributeManager::SP mgr); ~AttributeWriter(); /* Only for in tests that add attributes after AttributeWriter construction. */ diff --git a/searchcore/src/vespa/searchcore/proton/matchengine/imatchhandler.h b/searchcore/src/vespa/searchcore/proton/matchengine/imatchhandler.h deleted file mode 100644 index 63283de0a4a..00000000000 --- a/searchcore/src/vespa/searchcore/proton/matchengine/imatchhandler.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include <vespa/searchcore/proton/summaryengine/isearchhandler.h> -#include <vespa/vespalib/util/thread_bundle.h> - -namespace searche { -namespace engine { - class SearchRequest; - class SearchReply; -} -} - -namespace proton { - -/** - * This interface describes a sync match operation handler. It is implemented by - * the DocumentDB class, and used by the MatchEngine class to delegate - * operations to the appropriate db. - */ -class IMatchHandler { -protected: - using SearchReply = search::engine::SearchReply; - using SearchRequest = search::engine::SearchRequest; - using ThreadBundle = vespalib::ThreadBundle; - IMatchHandler() = default; -public: - IMatchHandler(const IMatchHandler &) = delete; - IMatchHandler & operator = (const IMatchHandler &) = delete; - /** - * Convenience typedefs. - */ - typedef std::unique_ptr<IMatchHandler> UP; - typedef std::shared_ptr<IMatchHandler> SP; - - virtual ~IMatchHandler() { } - - /** - * @return Use the request and produce the matching result. - */ - virtual std::unique_ptr<SearchReply> - match(const ISearchHandler::SP &searchHandler, const SearchRequest &req, ThreadBundle &threadBundle) const = 0; -}; - -} // namespace proton - diff --git a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h index 896ac83403a..34aacdafcad 100644 --- a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h +++ b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.h @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "imatchhandler.h" +#include <vespa/searchcore/proton/summaryengine/isearchhandler.h> #include <vespa/searchcore/proton/common/doctypename.h> #include <vespa/searchcore/proton/common/handlermap.hpp> #include <vespa/searchcore/proton/common/statusreport.h> @@ -50,7 +50,7 @@ public: * Frees any allocated resources. this will also stop all internal threads * and wait for them to finish. All pending search requests are deleted. */ - ~MatchEngine(); + ~MatchEngine() override; /** * Observe and reset internal executor stats @@ -123,13 +123,11 @@ public: StatusReport::UP reportStatus() const; - // Implements SearchServer. search::engine::SearchReply::UP search( search::engine::SearchRequest::Source request, search::engine::SearchClient &client) override; - // Implements vespalib::StateExplorer - virtual void get_state(const vespalib::slime::Inserter &inserter, bool full) const override; + void get_state(const vespalib::slime::Inserter &inserter, bool full) const override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/matching/search_session.h b/searchcore/src/vespa/searchcore/proton/matching/search_session.h index 0aec02e9d31..13d24624597 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/search_session.h +++ b/searchcore/src/vespa/searchcore/proton/matching/search_session.h @@ -26,7 +26,7 @@ public: OwnershipBundle(OwnershipBundle &&) = default; OwnershipBundle & operator = (OwnershipBundle &&) = default; ~OwnershipBundle(); - ISearchHandler::SP search_handler; + std::shared_ptr<const ISearchHandler> search_handler; std::unique_ptr<search::fef::Properties> feature_overrides; std::unique_ptr<MatchContext> context; IDocumentMetaStoreContext::IReadGuard::UP readGuard; diff --git a/searchcore/src/vespa/searchcore/proton/server/matchview.cpp b/searchcore/src/vespa/searchcore/proton/server/matchview.cpp index 6f32f886637..7ba9b971715 100644 --- a/searchcore/src/vespa/searchcore/proton/server/matchview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/matchview.cpp @@ -31,17 +31,17 @@ using matching::ISearchContext; using matching::Matcher; using matching::SessionManager; -MatchView::MatchView(const Matchers::SP &matchers, - const IndexSearchable::SP &indexSearchable, - const IAttributeManager::SP &attrMgr, - const SessionManagerSP &sessionMgr, - const IDocumentMetaStoreContext::SP &metaStore, +MatchView::MatchView(Matchers::SP matchers, + IndexSearchable::SP indexSearchable, + IAttributeManager::SP attrMgr, + SessionManagerSP sessionMgr, + IDocumentMetaStoreContext::SP metaStore, DocIdLimit &docIdLimit) - : _matchers(matchers), - _indexSearchable(indexSearchable), - _attrMgr(attrMgr), - _sessionMgr(sessionMgr), - _metaStore(metaStore), + : _matchers(std::move(matchers)), + _indexSearchable(std::move(indexSearchable)), + _attrMgr(std::move(attrMgr)), + _sessionMgr(std::move(sessionMgr)), + _metaStore(std::move(metaStore)), _docIdLimit(docIdLimit) { } @@ -68,12 +68,12 @@ MatchView::createContext() const { std::unique_ptr<SearchReply> -MatchView::match(const ISearchHandler::SP &searchHandler, const SearchRequest &req, +MatchView::match(std::shared_ptr<const ISearchHandler> searchHandler, const SearchRequest &req, vespalib::ThreadBundle &threadBundle) const { Matcher::SP matcher = getMatcher(req.ranking); SearchSession::OwnershipBundle owned_objects; - owned_objects.search_handler = searchHandler; + owned_objects.search_handler = std::move(searchHandler); owned_objects.context = createContext(); owned_objects.readGuard = _metaStore->getReadGuard();; MatchContext *ctx = owned_objects.context.get(); diff --git a/searchcore/src/vespa/searchcore/proton/server/matchview.h b/searchcore/src/vespa/searchcore/proton/server/matchview.h index 983e06d3414..721cb439508 100644 --- a/searchcore/src/vespa/searchcore/proton/server/matchview.h +++ b/searchcore/src/vespa/searchcore/proton/server/matchview.h @@ -36,11 +36,11 @@ public: MatchView(const MatchView &) = delete; MatchView & operator = (const MatchView &) = delete; - MatchView(const Matchers::SP &matchers, - const searchcorespi::IndexSearchable::SP &indexSearchable, - const IAttributeManager::SP &attrMgr, - const SessionManagerSP &sessionMgr, - const IDocumentMetaStoreContext::SP &metaStore, + MatchView(Matchers::SP matchers, + searchcorespi::IndexSearchable::SP indexSearchable, + IAttributeManager::SP attrMgr, + SessionManagerSP sessionMgr, + IDocumentMetaStoreContext::SP metaStore, DocIdLimit &docIdLimit); ~MatchView(); @@ -62,7 +62,7 @@ public: matching::MatchContext::UP createContext() const; std::unique_ptr<search::engine::SearchReply> - match(const std::shared_ptr<ISearchHandler> &searchHandler, + match(std::shared_ptr<const ISearchHandler> searchHandler, const search::engine::SearchRequest &req, vespalib::ThreadBundle &threadBundle) const; }; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp index e7dd64caae6..3ca8a4cff49 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp @@ -203,7 +203,7 @@ SearchableDocSubDB::initViews(const DocumentDBConfig &configSnapshot, const Sess const IIndexManager::SP &indexMgr = getIndexManager(); _constantValueRepo.reconfigure(configSnapshot.getRankingConstants()); Matchers::SP matchers(_configurer.createMatchers(schema, configSnapshot.getRankProfilesConfig()).release()); - auto matchView = std::make_shared<MatchView>(matchers, indexMgr->getSearchable(), attrMgr, + auto matchView = std::make_shared<MatchView>(std::move(matchers), indexMgr->getSearchable(), attrMgr, sessionManager, _metaStoreCtx, _docIdLimit); _rSearchView.set(SearchView::create( getSummaryManager()->createSummarySetup( @@ -211,7 +211,7 @@ SearchableDocSubDB::initViews(const DocumentDBConfig &configSnapshot, const Sess configSnapshot.getSummarymapConfig(), configSnapshot.getJuniperrcConfig(), configSnapshot.getDocumentTypeRepoSP(), - matchView->getAttributeManager()), + attrMgr), std::move(matchView))); auto attrWriter = std::make_shared<AttributeWriter>(attrMgr); diff --git a/searchcore/src/vespa/searchcore/proton/server/searchview.cpp b/searchcore/src/vespa/searchcore/proton/server/searchview.cpp index e1afb086c95..36d873d9948 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchview.cpp @@ -165,8 +165,7 @@ SearchView::getDocsumsInternal(const DocsumRequest & req) std::unique_ptr<SearchReply> SearchView::match(const SearchRequest &req, ThreadBundle &threadBundle) const { - ISearchHandler::SP self = const_cast<SearchView *>(this)->shared_from_this(); - return _matchView->match(std::move(self), req, threadBundle); + return _matchView->match(shared_from_this(), req, threadBundle); } } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h index 9d5b8c18d01..14f62513c34 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h @@ -13,7 +13,6 @@ #include <vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h> #include <vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.h> #include <vespa/searchcore/proton/documentmetastore/ilidreusedelayer.h> -#include <vespa/searchcore/proton/matchengine/imatchhandler.h> #include <vespa/searchcore/proton/summaryengine/isearchhandler.h> #include <vespa/searchcore/proton/common/commit_time_tracker.h> #include <vespa/searchcore/proton/persistenceengine/i_document_retriever.h> diff --git a/searchcore/src/vespa/searchcore/proton/summaryengine/isearchhandler.h b/searchcore/src/vespa/searchcore/proton/summaryengine/isearchhandler.h index dc14ac08aef..b7dd438ae29 100644 --- a/searchcore/src/vespa/searchcore/proton/summaryengine/isearchhandler.h +++ b/searchcore/src/vespa/searchcore/proton/summaryengine/isearchhandler.h @@ -26,12 +26,11 @@ protected: using DocsumRequest = search::engine::DocsumRequest; using ThreadBundle = vespalib::ThreadBundle; public: - typedef std::unique_ptr<ISearchHandler> UP; typedef std::shared_ptr<ISearchHandler> SP; ISearchHandler(const ISearchHandler &) = delete; ISearchHandler & operator = (const ISearchHandler &) = delete; - virtual ~ISearchHandler() { } + virtual ~ISearchHandler() = default; /** * @return Use the request and produce the document summary result. |