From c4a01e6c3b85eb18ece1c4b5d9f337b08ba3b76d Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 17 Feb 2020 14:48:49 +0000 Subject: Use enable_shared_from_this to simplify interface and keep the details local. --- .../src/tests/proton/matchengine/matchengine.cpp | 54 ++++++++++----------- .../src/tests/proton/matching/matching_test.cpp | 2 +- .../tests/proton/summaryengine/summaryengine.cpp | 56 ++++++++++------------ .../vespa/searchcore/proton/common/doctypename.cpp | 12 ++--- .../vespa/searchcore/proton/common/handlermap.hpp | 1 - .../searchcore/proton/matchengine/matchengine.cpp | 7 ++- .../vespa/searchcore/proton/server/documentdb.cpp | 4 +- .../vespa/searchcore/proton/server/documentdb.h | 3 +- .../searchcore/proton/server/emptysearchview.cpp | 19 +++----- .../searchcore/proton/server/emptysearchview.h | 13 ++--- .../src/vespa/searchcore/proton/server/proton.cpp | 3 +- .../proton/server/searchhandlerproxy.cpp | 10 ++-- .../searchcore/proton/server/searchhandlerproxy.h | 6 +-- .../vespa/searchcore/proton/server/searchview.cpp | 5 +- .../vespa/searchcore/proton/server/searchview.h | 6 +-- .../proton/summaryengine/isearchhandler.h | 2 +- .../proton/summaryengine/summaryengine.cpp | 4 +- 17 files changed, 90 insertions(+), 117 deletions(-) diff --git a/searchcore/src/tests/proton/matchengine/matchengine.cpp b/searchcore/src/tests/proton/matchengine/matchengine.cpp index 9ae938981a4..fd48fffcb5c 100644 --- a/searchcore/src/tests/proton/matchengine/matchengine.cpp +++ b/searchcore/src/tests/proton/matchengine/matchengine.cpp @@ -18,18 +18,17 @@ class MySearchHandler : public ISearchHandler { std::string _reply; public: MySearchHandler(size_t numHits = 0) : - _numHits(numHits), _name("my"), _reply("myreply") {} - virtual DocsumReply::UP getDocsums(const DocsumRequest &) override { - return DocsumReply::UP(new DocsumReply); + _numHits(numHits), _name("my"), _reply("myreply") + {} + DocsumReply::UP getDocsums(const DocsumRequest &) override { + return std::make_unique(); } - virtual search::engine::SearchReply::UP match( - const ISearchHandler::SP &, - const search::engine::SearchRequest &, - vespalib::ThreadBundle &) const override { - SearchReply::UP retval(new SearchReply); + SearchReply::UP match(const SearchRequest &, vespalib::ThreadBundle &) const override + { + auto retval = std::make_unique(); for (size_t i = 0; i < _numHits; ++i) { - retval->hits.push_back(SearchReply::Hit()); + retval->hits.emplace_back(); } return retval; } @@ -43,7 +42,7 @@ private: public: LocalSearchClient(); - ~LocalSearchClient(); + ~LocalSearchClient() override; void searchDone(SearchReply::UP reply) override { std::lock_guard guard(_lock); _reply = std::move(reply); @@ -62,8 +61,8 @@ public: } }; -LocalSearchClient::LocalSearchClient() {} -LocalSearchClient::~LocalSearchClient() {} +LocalSearchClient::LocalSearchClient() = default; +LocalSearchClient::~LocalSearchClient() = default; TEST("requireThatSearchesExecute") { @@ -71,23 +70,23 @@ TEST("requireThatSearchesExecute") MatchEngine engine(numMatcherThreads, 1, 7); engine.setNodeUp(true); - MySearchHandler::SP handler(new MySearchHandler); + auto handler = std::make_shared(); DocTypeName dtnvfoo("foo"); engine.putSearchHandler(dtnvfoo, handler); LocalSearchClient client; SearchRequest::Source request(new SearchRequest()); SearchReply::UP reply = engine.search(std::move(request), client); - EXPECT_TRUE(reply.get() == NULL); + EXPECT_FALSE(reply); reply = client.getReply(10000); - EXPECT_TRUE(reply.get() != NULL); + EXPECT_TRUE(reply); } bool assertSearchReply(MatchEngine & engine, const std::string & searchDocType, size_t expHits) { - SearchRequest *request = new SearchRequest(); + auto *request = new SearchRequest(); request->propertiesMap.lookupCreate(search::MapNames::MATCH).add("documentdb.searchdoctype", searchDocType); LocalSearchClient client; engine.search(SearchRequest::Source(request), client); @@ -99,9 +98,9 @@ TEST("requireThatCorrectHandlerIsUsed") { MatchEngine engine(1, 1, 7); engine.setNodeUp(true); - ISearchHandler::SP h1(new MySearchHandler(2)); - ISearchHandler::SP h2(new MySearchHandler(4)); - ISearchHandler::SP h3(new MySearchHandler(6)); + auto h1 = std::make_shared(2); + auto h2 = std::make_shared(4); + auto h3 = std::make_shared(6); DocTypeName dtnvfoo("foo"); DocTypeName dtnvbar("bar"); DocTypeName dtnvbaz("baz"); @@ -120,13 +119,12 @@ struct ObserveBundleMatchHandler : MySearchHandler { mutable size_t bundleSize; ObserveBundleMatchHandler() : bundleSize(0) {} - virtual search::engine::SearchReply::UP match( - const ISearchHandler::SP &, + search::engine::SearchReply::UP match( const search::engine::SearchRequest &, vespalib::ThreadBundle &threadBundle) const override { bundleSize = threadBundle.size(); - return SearchReply::UP(new SearchReply); + return std::make_unique(); } }; @@ -135,7 +133,7 @@ TEST("requireThatBundlesAreUsed") MatchEngine engine(15, 5, 7); engine.setNodeUp(true); - ObserveBundleMatchHandler::SP handler(new ObserveBundleMatchHandler()); + auto handler = std::make_shared(); DocTypeName dtnvfoo("foo"); engine.putSearchHandler(dtnvfoo, handler); @@ -151,20 +149,20 @@ TEST("requireThatHandlersCanBeRemoved") { MatchEngine engine(1, 1, 7); engine.setNodeUp(true); - ISearchHandler::SP h(new MySearchHandler(1)); + auto h = std::make_shared(1); DocTypeName docType("foo"); engine.putSearchHandler(docType, h); ISearchHandler::SP r = engine.getSearchHandler(docType); - EXPECT_TRUE(r.get() != NULL); + EXPECT_TRUE(r); EXPECT_TRUE(h.get() == r.get()); r = engine.removeSearchHandler(docType); - EXPECT_TRUE(r.get() != NULL); + EXPECT_TRUE(r); EXPECT_TRUE(h.get() == r.get()); r = engine.getSearchHandler(docType); - EXPECT_TRUE(r.get() == NULL); + EXPECT_FALSE(r); } TEST("requireThatEmptySearchReplyIsReturnedWhenEngineIsClosed") @@ -175,7 +173,7 @@ TEST("requireThatEmptySearchReplyIsReturnedWhenEngineIsClosed") LocalSearchClient client; SearchRequest::Source request(new SearchRequest()); SearchReply::UP reply = engine.search(std::move(request), client); - EXPECT_TRUE(reply.get() != NULL); + EXPECT_TRUE(reply ); EXPECT_EQUAL(0u, reply->hits.size()); EXPECT_EQUAL(7u, reply->getDistributionKey()); } diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index 95ab43dbcba..00a319db394 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -289,7 +289,7 @@ struct MyWorld { DocsumReply::UP getDocsums(const DocsumRequest &) override { return DocsumReply::UP(); } - SearchReply::UP match(const ISearchHandler::SP &, const SearchRequest &, vespalib::ThreadBundle &) const override { + SearchReply::UP match(const SearchRequest &, vespalib::ThreadBundle &) const override { return SearchReply::UP(); } }; diff --git a/searchcore/src/tests/proton/summaryengine/summaryengine.cpp b/searchcore/src/tests/proton/summaryengine/summaryengine.cpp index a9cae7d8ab7..7cdd8d767c6 100644 --- a/searchcore/src/tests/proton/summaryengine/summaryengine.cpp +++ b/searchcore/src/tests/proton/summaryengine/summaryengine.cpp @@ -42,7 +42,7 @@ public: : _name(name), _reply(reply) {} - virtual DocsumReply::UP getDocsums(const DocsumRequest &request) override { + DocsumReply::UP getDocsums(const DocsumRequest &request) override { return (request.useRootSlime()) ? std::make_unique(createSlimeReply(request.hits.size())) : createOldDocSum(request); @@ -62,7 +62,7 @@ public: } DocsumReply::UP createOldDocSum(const DocsumRequest &request) { - DocsumReply::UP retval(new DocsumReply()); + auto retval = std::make_unique(); for (size_t i = 0; i < request.hits.size(); i++) { const DocsumRequest::Hit &h = request.hits[i]; DocsumReply::Docsum docsum; @@ -74,11 +74,8 @@ public: return retval; } - virtual search::engine::SearchReply::UP match( - const ISearchHandler::SP &, - const search::engine::SearchRequest &, - vespalib::ThreadBundle &) const override { - return SearchReply::UP(new SearchReply); + SearchReply::UP match(const SearchRequest &, vespalib::ThreadBundle &) const override { + return std::make_unique(); } }; @@ -90,8 +87,7 @@ private: public: MyDocsumClient(); - - ~MyDocsumClient(); + ~MyDocsumClient() override; void getDocsumsDone(DocsumReply::UP reply) override { std::lock_guard guard(_lock); @@ -111,19 +107,19 @@ public: } }; -MyDocsumClient::MyDocsumClient() {} +MyDocsumClient::MyDocsumClient() = default; -MyDocsumClient::~MyDocsumClient() {} +MyDocsumClient::~MyDocsumClient() = default; DocsumRequest::UP createRequest(size_t num = 1) { - DocsumRequest::UP r(new DocsumRequest()); + auto r = std::make_unique(); if (num == 1) { r->hits.emplace_back(GlobalId("aaaaaaaaaaaa")); } else { for (size_t i = 0; i < num; i++) { vespalib::string s = vespalib::make_string("aaaaaaaaaaa%c", char('a' + i % 26)); - r->hits.push_back(GlobalId(s.c_str())); + r->hits.emplace_back(GlobalId(s.c_str())); } } return r; @@ -132,7 +128,7 @@ createRequest(size_t num = 1) { TEST("requireThatGetDocsumsExecute") { int numSummaryThreads = 2; SummaryEngine engine(numSummaryThreads); - ISearchHandler::SP handler(new MySearchHandler); + auto handler = std::make_shared(); DocTypeName dtnvfoo("foo"); engine.putSearchHandler(dtnvfoo, handler); @@ -140,9 +136,9 @@ TEST("requireThatGetDocsumsExecute") { { // async call when engine running DocsumRequest::Source request(createRequest()); DocsumReply::UP reply = engine.getDocsums(std::move(request), client); - EXPECT_TRUE(reply.get() == NULL); + EXPECT_FALSE(reply); reply = client.getReply(10000); - EXPECT_TRUE(reply.get() != NULL); + EXPECT_TRUE(reply); EXPECT_EQUAL(1u, reply->docsums.size()); EXPECT_EQUAL(10u, reply->docsums[0].docid); EXPECT_EQUAL(GlobalId("aaaaaaaaaaaa"), reply->docsums[0].gid); @@ -152,7 +148,7 @@ TEST("requireThatGetDocsumsExecute") { { // sync call when engine closed DocsumRequest::Source request(createRequest()); DocsumReply::UP reply = engine.getDocsums(std::move(request), client); - EXPECT_TRUE(reply.get() != NULL); + EXPECT_TRUE(reply); } } @@ -161,23 +157,23 @@ TEST("requireThatHandlersAreStored") { DocTypeName dtnvbar("bar"); int numSummaryThreads = 2; SummaryEngine engine(numSummaryThreads); - ISearchHandler::SP h1(new MySearchHandler("foo")); - ISearchHandler::SP h2(new MySearchHandler("bar")); - ISearchHandler::SP h3(new MySearchHandler("baz")); + auto h1 = std::make_shared("foo"); + auto h2 = std::make_shared("bar"); + auto h3 = std::make_shared("baz"); // not found - EXPECT_TRUE(engine.getSearchHandler(dtnvfoo).get() == NULL); - EXPECT_TRUE(engine.removeSearchHandler(dtnvfoo).get() == NULL); + EXPECT_FALSE(engine.getSearchHandler(dtnvfoo)); + EXPECT_FALSE(engine.removeSearchHandler(dtnvfoo)); // put & get - EXPECT_TRUE(engine.putSearchHandler(dtnvfoo, h1).get() == NULL); + EXPECT_FALSE(engine.putSearchHandler(dtnvfoo, h1)); EXPECT_EQUAL(engine.getSearchHandler(dtnvfoo).get(), h1.get()); - EXPECT_TRUE(engine.putSearchHandler(dtnvbar, h2).get() == NULL); + EXPECT_FALSE(engine.putSearchHandler(dtnvbar, h2)); EXPECT_EQUAL(engine.getSearchHandler(dtnvbar).get(), h2.get()); // replace EXPECT_TRUE(engine.putSearchHandler(dtnvfoo, h3).get() == h1.get()); EXPECT_EQUAL(engine.getSearchHandler(dtnvfoo).get(), h3.get()); // remove EXPECT_EQUAL(engine.removeSearchHandler(dtnvfoo).get(), h3.get()); - EXPECT_TRUE(engine.getSearchHandler(dtnvfoo).get() == NULL); + EXPECT_FALSE(engine.getSearchHandler(dtnvfoo)); } bool @@ -196,9 +192,9 @@ TEST("requireThatCorrectHandlerIsUsed") { DocTypeName dtnvbar("bar"); DocTypeName dtnvbaz("baz"); SummaryEngine engine(1); - ISearchHandler::SP h1(new MySearchHandler("foo", "foo reply")); - ISearchHandler::SP h2(new MySearchHandler("bar", "bar reply")); - ISearchHandler::SP h3(new MySearchHandler("baz", "baz reply")); + auto h1 = std::make_shared("foo", "foo reply"); + auto h2 = std::make_shared("bar", "bar reply"); + auto h3 = std::make_shared("baz", "baz reply"); engine.putSearchHandler(dtnvfoo, h1); engine.putSearchHandler(dtnvbar, h2); engine.putSearchHandler(dtnvbaz, h3); @@ -369,7 +365,7 @@ public: Server::Server() : BaseServer(), engine(2), - handler(new MySearchHandler("slime", stringref(buf.GetDrainPos(), buf.GetUsedLen()))), + handler(std::make_shared("slime", stringref(buf.GetDrainPos(), buf.GetUsedLen()))), docsumBySlime(engine), docsumByRPC(docsumBySlime) { @@ -377,7 +373,7 @@ Server::Server() engine.putSearchHandler(dtnvfoo, handler); } -Server::~Server() {} +Server::~Server() = default; vespalib::string getAnswer(size_t num) { diff --git a/searchcore/src/vespa/searchcore/proton/common/doctypename.cpp b/searchcore/src/vespa/searchcore/proton/common/doctypename.cpp index 70daeeebeca..21b27ef6ffd 100644 --- a/searchcore/src/vespa/searchcore/proton/common/doctypename.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/doctypename.cpp @@ -4,20 +4,16 @@ #include #include -namespace proton -{ +namespace proton { DocTypeName::DocTypeName(const search::engine::Request &request) : _name(request.propertiesMap.matchProperties().lookup("documentdb", "searchdoctype").get("")) -{ -} +{} DocTypeName::DocTypeName(const document::DocumentType &docType) : _name(docType.getName()) -{ -} +{} - -} // namespace proton +} diff --git a/searchcore/src/vespa/searchcore/proton/common/handlermap.hpp b/searchcore/src/vespa/searchcore/proton/common/handlermap.hpp index 3fb32a9d1e0..e762ac527f0 100644 --- a/searchcore/src/vespa/searchcore/proton/common/handlermap.hpp +++ b/searchcore/src/vespa/searchcore/proton/common/handlermap.hpp @@ -53,7 +53,6 @@ public: bool valid() const override { return (_offset < _handlers.size()); } T *get() const override { return _handlers[_offset].get(); } - HandlerSP getSP() const { return _handlers[_offset]; } void next() override { ++_offset; } }; diff --git a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp index b170f60d71f..ad47fb98232 100644 --- a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp @@ -121,12 +121,12 @@ MatchEngine::performSearch(search::engine::SearchRequest::Source req, ISearchHandler::SP searchHandler; vespalib::SimpleThreadBundle::UP threadBundle = _threadBundlePool.obtain(); { // try to find the match handler corresponding to the specified search doc type - std::lock_guard guard(_lock); DocTypeName docTypeName(*searchRequest); + std::lock_guard guard(_lock); searchHandler = _handlers.getHandler(docTypeName); } if (searchHandler) { - ret = searchHandler->match(searchHandler, *searchRequest, *threadBundle); + ret = searchHandler->match(*searchRequest, *threadBundle); } else { HandlerMap::Snapshot snapshot; { @@ -134,8 +134,7 @@ MatchEngine::performSearch(search::engine::SearchRequest::Source req, snapshot = _handlers.snapshot(); } if (snapshot.valid()) { - ISearchHandler::SP handler = snapshot.getSP(); - ret = handler->match(handler, *searchRequest, *threadBundle); // use the first handler + ret = snapshot.get()->match(*searchRequest, *threadBundle); // use the first handler } } _threadBundlePool.release(std::move(threadBundle)); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 1b182c3e618..302ffc93f6a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -756,11 +756,11 @@ DocumentDB::getNewestFlushedSerial() } std::unique_ptr -DocumentDB::match(const ISearchHandler::SP &, const SearchRequest &req, vespalib::ThreadBundle &threadBundle) const +DocumentDB::match(const SearchRequest &req, vespalib::ThreadBundle &threadBundle) const { // Ignore input searchhandler. Use readysubdb's searchhandler instead. ISearchHandler::SP view(_subDBs.getReadySubDB()->getSearchView()); - return view->match(view, req, threadBundle); + return view->match(req, threadBundle); } std::unique_ptr diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h index 02ad144af68..f296e264903 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h @@ -368,8 +368,7 @@ public: virtual SerialNum getNewestFlushedSerial(); std::unique_ptr - match(const ISearchHandler::SP &searchHandler, - const search::engine::SearchRequest &req, + match(const search::engine::SearchRequest &req, vespalib::ThreadBundle &threadBundle) const; std::unique_ptr diff --git a/searchcore/src/vespa/searchcore/proton/server/emptysearchview.cpp b/searchcore/src/vespa/searchcore/proton/server/emptysearchview.cpp index 90cf0011685..9f2ec26ad4b 100644 --- a/searchcore/src/vespa/searchcore/proton/server/emptysearchview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/emptysearchview.cpp @@ -14,10 +14,7 @@ using search::engine::SearchRequest; namespace proton { -EmptySearchView::EmptySearchView() - : ISearchHandler() -{ -} +EmptySearchView::EmptySearchView() = default; DocsumReply::UP @@ -25,20 +22,16 @@ EmptySearchView::getDocsums(const DocsumRequest &req) { LOG(debug, "getDocsums(): resultClass(%s), numHits(%zu)", req.resultClassName.c_str(), req.hits.size()); - DocsumReply::UP reply(new DocsumReply()); - for (size_t i = 0; i < req.hits.size(); ++i) { - reply->docsums.push_back(DocsumReply::Docsum()); - reply->docsums.back().gid = req.hits[i].gid; + auto reply = std::make_unique(); + for (const auto & hit : req.hits) { + reply->docsums.emplace_back(hit.gid); } return reply; } SearchReply::UP -EmptySearchView::match(const ISearchHandler::SP &, - const SearchRequest &, - vespalib::ThreadBundle &) const { - SearchReply::UP reply(new SearchReply); - return reply; +EmptySearchView::match(const SearchRequest &, vespalib::ThreadBundle &) const { + return std::make_unique(); } diff --git a/searchcore/src/vespa/searchcore/proton/server/emptysearchview.h b/searchcore/src/vespa/searchcore/proton/server/emptysearchview.h index a3e2a2b176c..92fb97f6177 100644 --- a/searchcore/src/vespa/searchcore/proton/server/emptysearchview.h +++ b/searchcore/src/vespa/searchcore/proton/server/emptysearchview.h @@ -13,15 +13,10 @@ public: EmptySearchView(); - /** - * Implements ISearchHandler - */ - virtual std::unique_ptr getDocsums(const DocsumRequest & req) override; - - virtual std::unique_ptr - match(const ISearchHandler::SP &searchHandler, - const SearchRequest &req, - vespalib::ThreadBundle &threadBundle) const override; + std::unique_ptr getDocsums(const DocsumRequest & req) override; + + std::unique_ptr + match(const SearchRequest &req, vespalib::ThreadBundle &threadBundle) const override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index 28de4dff917..20de5bb07c1 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -628,8 +628,7 @@ Proton::removeDocumentDB(const DocTypeName &docTypeName) { // Not allowed to get to service layer to call pause(). std::unique_lock persistenceWguard(_persistenceEngine->getWLock()); - IPersistenceHandler::SP oldHandler; - oldHandler = _persistenceEngine->removeHandler(persistenceWguard, old->getBucketSpace(), docTypeName); + IPersistenceHandler::SP oldHandler = _persistenceEngine->removeHandler(persistenceWguard, old->getBucketSpace(), docTypeName); if (_initComplete && oldHandler) { // TODO: Fix race with bucket db modifying ops. _persistenceEngine->grabExtraModifiedBuckets(old->getBucketSpace(), *oldHandler); diff --git a/searchcore/src/vespa/searchcore/proton/server/searchhandlerproxy.cpp b/searchcore/src/vespa/searchcore/proton/server/searchhandlerproxy.cpp index f611b4e1f4c..6da6c09cdba 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchhandlerproxy.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchhandlerproxy.cpp @@ -7,8 +7,8 @@ namespace proton { -SearchHandlerProxy::SearchHandlerProxy(const DocumentDB::SP &documentDB) - : _documentDB(documentDB) +SearchHandlerProxy::SearchHandlerProxy(DocumentDB::SP documentDB) + : _documentDB(std::move(documentDB)) { _documentDB->retain(); } @@ -25,11 +25,9 @@ SearchHandlerProxy::getDocsums(const DocsumRequest & request) } std::unique_ptr -SearchHandlerProxy::match(const ISearchHandler::SP &searchHandler, - const SearchRequest &req, - vespalib::ThreadBundle &threadBundle) const +SearchHandlerProxy::match(const SearchRequest &req, vespalib::ThreadBundle &threadBundle) const { - return _documentDB->match(searchHandler, req, threadBundle); + return _documentDB->match(req, threadBundle); } } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/searchhandlerproxy.h b/searchcore/src/vespa/searchcore/proton/server/searchhandlerproxy.h index 4e9f5bdab8a..fc4f517fb36 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchhandlerproxy.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchhandlerproxy.h @@ -13,11 +13,11 @@ class SearchHandlerProxy : public ISearchHandler private: std::shared_ptr _documentDB; public: - SearchHandlerProxy(const std::shared_ptr &documentDB); + SearchHandlerProxy(std::shared_ptr documentDB); - virtual~SearchHandlerProxy(); + ~SearchHandlerProxy() override; std::unique_ptr getDocsums(const DocsumRequest & request) override; - std::unique_ptr match(const ISearchHandler::SP &searchHandler, const SearchRequest &req, ThreadBundle &threadBundle) const override; + std::unique_ptr match(const SearchRequest &req, ThreadBundle &threadBundle) const override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/searchview.cpp b/searchcore/src/vespa/searchcore/proton/server/searchview.cpp index 9830048cdd8..3ca0e4b0a82 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchview.cpp @@ -161,8 +161,9 @@ SearchView::getDocsumsInternal(const DocsumRequest & req) } std::unique_ptr -SearchView::match(const ISearchHandler::SP &self, const SearchRequest &req, ThreadBundle &threadBundle) const { - return _matchView->match(self, req, threadBundle); +SearchView::match(const SearchRequest &req, ThreadBundle &threadBundle) const { + ISearchHandler::SP self = const_cast(this)->shared_from_this(); + return _matchView->match(std::move(self), req, threadBundle); } } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/searchview.h b/searchcore/src/vespa/searchcore/proton/server/searchview.h index 28c7ffd2b36..8148f10feeb 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchview.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchview.h @@ -8,7 +8,7 @@ namespace proton { -class SearchView : public ISearchHandler +class SearchView : public ISearchHandler, public std::enable_shared_from_this { public: using SessionManagerSP = std::shared_ptr; @@ -21,7 +21,7 @@ public: SearchView(SearchView &&) = delete; SearchView &operator=(const SearchView &) = delete; SearchView &operator=(SearchView &&) = delete; - ~SearchView(); + ~SearchView() override; const ISummaryManager::ISummarySetup::SP & getSummarySetup() const { return _summarySetup; } const MatchView::SP & getMatchView() const { return _matchView; } @@ -34,7 +34,7 @@ public: matching::MatchingStats getMatcherStats(const vespalib::string &rankProfile) const { return _matchView->getMatcherStats(rankProfile); } std::unique_ptr getDocsums(const DocsumRequest & req) override; - std::unique_ptr match(const ISearchHandler::SP &self, const SearchRequest &req, vespalib::ThreadBundle &threadBundle) const override; + std::unique_ptr match(const SearchRequest &req, vespalib::ThreadBundle &threadBundle) const override; private: InternalDocsumReply getDocsumsInternal(const DocsumRequest & req); ISummaryManager::ISummarySetup::SP _summarySetup; diff --git a/searchcore/src/vespa/searchcore/proton/summaryengine/isearchhandler.h b/searchcore/src/vespa/searchcore/proton/summaryengine/isearchhandler.h index ffcdfbaf365..dc14ac08aef 100644 --- a/searchcore/src/vespa/searchcore/proton/summaryengine/isearchhandler.h +++ b/searchcore/src/vespa/searchcore/proton/summaryengine/isearchhandler.h @@ -39,7 +39,7 @@ public: virtual std::unique_ptr getDocsums(const DocsumRequest & request) = 0; virtual std::unique_ptr - match(const ISearchHandler::SP &self, const SearchRequest &req, ThreadBundle &threadBundle) const = 0; + match(const SearchRequest &req, ThreadBundle &threadBundle) const = 0; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp index 692b05899f4..1189e8a550c 100644 --- a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp @@ -107,13 +107,13 @@ SummaryEngine::getDocsums(DocsumRequest::Source request, DocsumClient & client) { if (_closed) { LOG(warning, "Receiving docsumrequest after engine has been shutdown"); - DocsumReply::UP ret(new DocsumReply()); + auto ret = std::make_unique(); // TODO: Notify closed. return ret; } - vespalib::Executor::Task::UP task(new DocsumTask(*this, std::move(request), client)); + auto task =std::make_unique(*this, std::move(request), client); _executor.execute(std::move(task)); return DocsumReply::UP(); } -- cgit v1.2.3 From 6a31d94bcc91fad03a8f4058edc9139d29c58118 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Fri, 21 Feb 2020 17:53:37 +0000 Subject: Only expose shared_ptr --- .../tests/proton/documentdb/configurer/configurer_test.cpp | 4 ++-- .../proton/server/searchable_doc_subdb_configurer.cpp | 10 +++++----- .../proton/server/searchable_doc_subdb_configurer.h | 5 ++--- .../src/vespa/searchcore/proton/server/searchabledocsubdb.cpp | 4 ++-- searchcore/src/vespa/searchcore/proton/server/searchview.cpp | 11 +++++++---- searchcore/src/vespa/searchcore/proton/server/searchview.h | 5 +++-- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index 3c3ed33b8ea..14ad82a0aa1 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -208,10 +208,10 @@ Fixture::initViewSet(ViewSet &views) views._lidReuseDelayer = std::make_unique(views._writeService, metaStore->get()); IndexSearchable::SP indexSearchable; MatchView::SP matchView(new MatchView(matchers, indexSearchable, attrMgr, sesMgr, metaStore, views._docIdLimit)); - views.searchView.set(make_shared + views.searchView.set(SearchView::create (summaryMgr->createSummarySetup(SummaryConfig(), SummarymapConfig(), JuniperrcConfig(), views.repo, attrMgr), - matchView)); + std::move(matchView))); views.feedView.set( make_shared(StoreOnlyFeedView::Context(summaryAdapter, schema, diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp index 069d3727850..9ef038b7325 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp @@ -84,17 +84,17 @@ reconfigureMatchView(const Matchers::SP &matchers, } void -SearchableDocSubDBConfigurer::reconfigureSearchView(const MatchView::SP &matchView) +SearchableDocSubDBConfigurer::reconfigureSearchView(MatchView::SP matchView) { SearchView::SP curr = _searchView.get(); - _searchView.set(SearchView::SP(new SearchView(curr->getSummarySetup(), matchView))); + _searchView.set(SearchView::create(curr->getSummarySetup(), std::move(matchView))); } void -SearchableDocSubDBConfigurer::reconfigureSearchView(const ISummaryManager::ISummarySetup::SP &summarySetup, - const MatchView::SP &matchView) +SearchableDocSubDBConfigurer::reconfigureSearchView(ISummaryManager::ISummarySetup::SP summarySetup, + MatchView::SP matchView) { - _searchView.set(SearchView::SP(new SearchView(summarySetup, matchView))); + _searchView.set(SearchView::create(std::move(summarySetup), std::move(matchView))); } SearchableDocSubDBConfigurer:: diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h index 5aac069853b..459c4651e67 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h @@ -65,11 +65,10 @@ private: const IAttributeManager::SP &attrMgr); void - reconfigureSearchView(const MatchView::SP &matchView); + reconfigureSearchView(MatchView::SP matchView); void - reconfigureSearchView(const ISummaryManager::ISummarySetup::SP &summarySetup, - const MatchView::SP &matchView); + reconfigureSearchView(ISummaryManager::ISummarySetup::SP summarySetup, MatchView::SP matchView); public: SearchableDocSubDBConfigurer(const SearchableDocSubDBConfigurer &) = delete; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp index 77852dcc918..e7dd64caae6 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp @@ -205,14 +205,14 @@ SearchableDocSubDB::initViews(const DocumentDBConfig &configSnapshot, const Sess Matchers::SP matchers(_configurer.createMatchers(schema, configSnapshot.getRankProfilesConfig()).release()); auto matchView = std::make_shared(matchers, indexMgr->getSearchable(), attrMgr, sessionManager, _metaStoreCtx, _docIdLimit); - _rSearchView.set(std::make_shared( + _rSearchView.set(SearchView::create( getSummaryManager()->createSummarySetup( configSnapshot.getSummaryConfig(), configSnapshot.getSummarymapConfig(), configSnapshot.getJuniperrcConfig(), configSnapshot.getDocumentTypeRepoSP(), matchView->getAttributeManager()), - matchView)); + std::move(matchView))); auto attrWriter = std::make_shared(attrMgr); { diff --git a/searchcore/src/vespa/searchcore/proton/server/searchview.cpp b/searchcore/src/vespa/searchcore/proton/server/searchview.cpp index 3ca0e4b0a82..e1afb086c95 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchview.cpp @@ -105,11 +105,14 @@ createEmptyReply(const DocsumRequest & request) } -SearchView::SearchView(const ISummaryManager::ISummarySetup::SP & summarySetup, - const MatchView::SP & matchView) +std::shared_ptr +SearchView::create(ISummaryManager::ISummarySetup::SP summarySetup, MatchView::SP matchView) { + return std::shared_ptr( new SearchView(std::move(summarySetup), std::move(matchView))); +} +SearchView::SearchView(ISummaryManager::ISummarySetup::SP summarySetup, MatchView::SP matchView) : ISearchHandler(), - _summarySetup(summarySetup), - _matchView(matchView) + _summarySetup(std::move(summarySetup)), + _matchView(std::move(matchView)) { } SearchView::~SearchView() = default; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchview.h b/searchcore/src/vespa/searchcore/proton/server/searchview.h index 8148f10feeb..630d29c32fd 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchview.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchview.h @@ -8,7 +8,7 @@ namespace proton { -class SearchView : public ISearchHandler, public std::enable_shared_from_this +class SearchView : public ISearchHandler, public std::enable_shared_from_this { public: using SessionManagerSP = std::shared_ptr; @@ -16,7 +16,7 @@ public: using InternalDocsumReply = std::pair, bool>; typedef std::shared_ptr SP; - SearchView(const ISummaryManager::ISummarySetup::SP &summarySetup, const MatchView::SP &matchView); + static std::shared_ptr create(ISummaryManager::ISummarySetup::SP summarySetup, MatchView::SP matchView); SearchView(const SearchView &) = delete; SearchView(SearchView &&) = delete; SearchView &operator=(const SearchView &) = delete; @@ -36,6 +36,7 @@ public: std::unique_ptr getDocsums(const DocsumRequest & req) override; std::unique_ptr match(const SearchRequest &req, vespalib::ThreadBundle &threadBundle) const override; private: + SearchView(ISummaryManager::ISummarySetup::SP summarySetup, MatchView::SP matchView); InternalDocsumReply getDocsumsInternal(const DocsumRequest & req); ISummaryManager::ISummarySetup::SP _summarySetup; MatchView::SP _matchView; -- cgit v1.2.3 From fb751b67469af516373874a44c307fa1af2c6a83 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Sat, 22 Feb 2020 21:29:57 +0000 Subject: Allow passing const SearchView --- .../proton/attribute/attribute_writer.cpp | 8 ++-- .../searchcore/proton/attribute/attribute_writer.h | 2 +- .../searchcore/proton/matchengine/imatchhandler.h | 46 ---------------------- .../searchcore/proton/matchengine/matchengine.h | 8 ++-- .../searchcore/proton/matching/search_session.h | 2 +- .../vespa/searchcore/proton/server/matchview.cpp | 24 +++++------ .../src/vespa/searchcore/proton/server/matchview.h | 12 +++--- .../proton/server/searchabledocsubdb.cpp | 4 +- .../vespa/searchcore/proton/server/searchview.cpp | 3 +- .../searchcore/proton/server/storeonlydocsubdb.h | 1 - .../proton/summaryengine/isearchhandler.h | 3 +- 11 files changed, 31 insertions(+), 82 deletions(-) delete mode 100644 searchcore/src/vespa/searchcore/proton/matchengine/imatchhandler.h 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 -#include - -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 UP; - typedef std::shared_ptr SP; - - virtual ~IMatchHandler() { } - - /** - * @return Use the request and produce the matching result. - */ - virtual std::unique_ptr - 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 #include #include #include @@ -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 search_handler; std::unique_ptr feature_overrides; std::unique_ptr 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 -MatchView::match(const ISearchHandler::SP &searchHandler, const SearchRequest &req, +MatchView::match(std::shared_ptr 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 - match(const std::shared_ptr &searchHandler, + match(std::shared_ptr 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(matchers, indexMgr->getSearchable(), attrMgr, + auto matchView = std::make_shared(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(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 SearchView::match(const SearchRequest &req, ThreadBundle &threadBundle) const { - ISearchHandler::SP self = const_cast(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 #include #include -#include #include #include #include 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 UP; typedef std::shared_ptr 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. -- cgit v1.2.3