diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-09-12 13:19:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-12 13:19:15 +0200 |
commit | 2823e2353618573aa0513309e07cbd3c62d519f1 (patch) | |
tree | 163c4cdf9821551fe6173c9fe6e395b7bba54f76 | |
parent | 6bcdef32987edcb51257642156b9ee9d4da669f9 (diff) | |
parent | 199b282a61ad84305d9e8549d18513312190f07f (diff) |
Merge pull request #24008 from vespa-engine/balder/fetch-target-active-from-bucketdb
Fetch target active from bucketdb.
12 files changed, 94 insertions, 92 deletions
diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index b94ef025aa6..b404330df9b 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -183,7 +183,7 @@ struct MyWorld { attributeContext.add(attr); } { - SingleInt32ExtAttribute *attr = new SingleInt32ExtAttribute("a2"); + auto *attr = new SingleInt32ExtAttribute("a2"); AttributeVector::DocId docid(0); for (uint32_t i = 0; i < NUM_DOCS; ++i) { attr->addDoc(docid); @@ -193,7 +193,7 @@ struct MyWorld { attributeContext.add(attr); } { - SingleInt32ExtAttribute *attr = new SingleInt32ExtAttribute("a3"); + auto *attr = new SingleInt32ExtAttribute("a3"); AttributeVector::DocId docid(0); for (uint32_t i = 0; i < NUM_DOCS; ++i) { attr->addDoc(docid); @@ -371,10 +371,10 @@ struct MyWorld { } }; - void verify_diversity_filter(SearchRequest::SP req, bool expectDiverse) { + void verify_diversity_filter(const SearchRequest & req, bool expectDiverse) { Matcher::SP matcher = createMatcher(); search::fef::Properties overrides; - auto mtf = matcher->create_match_tools_factory(*req, searchContext, attributeContext, metaStore, overrides, true); + auto mtf = matcher->create_match_tools_factory(req, searchContext, attributeContext, metaStore, overrides, true); auto diversity = mtf->createDiversifier(HeapSize::lookup(config)); EXPECT_EQUAL(expectDiverse, static_cast<bool>(diversity)); } @@ -390,15 +390,16 @@ struct MyWorld { return match_tools->match_data().get_termwise_limit(); } - SearchReply::UP performSearch(SearchRequest::SP req, size_t threads) { + SearchReply::UP performSearch(const SearchRequest & req, size_t threads) { Matcher::SP matcher = createMatcher(); SearchSession::OwnershipBundle owned_objects; 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); - SearchReply::UP reply = matcher->match(*req, threadBundle, searchContext, attributeContext, - *sessionManager, metaStore, std::move(owned_objects)); + SearchReply::UP reply = matcher->match(req, threadBundle, searchContext, attributeContext, + *sessionManager, metaStore, metaStore.getBucketDB(), + std::move(owned_objects)); matchingStats.add(matcher->getStats()); return reply; } @@ -407,7 +408,7 @@ struct MyWorld { auto req = std::make_unique<DocsumRequest>(); setStackDump(*req, stack_dump); for (uint32_t docid: docs) { - req->hits.push_back(DocsumRequest::Hit()); + req->hits.emplace_back(); req->hits.back().docid = docid; } return req; @@ -423,7 +424,7 @@ struct MyWorld { Matcher::SP matcher = createMatcher(); const FieldInfo *field = matcher->get_index_env().getFieldByName(field_name); if (field == nullptr) { - return std::unique_ptr<FieldInfo>(); + return {}; } return std::make_unique<FieldInfo>(*field); } @@ -509,8 +510,8 @@ TEST("require that matching is performed (multi-threaded)") { MyWorld world; world.basicSetup(); world.basicResults(); - SearchRequest::SP request = world.createSimpleRequest("f1", "spread"); - SearchReply::UP reply = world.performSearch(request, threads); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "spread"); + SearchReply::UP reply = world.performSearch(*request, threads); EXPECT_EQUAL(9u, world.matchingStats.docsMatched()); EXPECT_EQUAL(9u, reply->hits.size()); EXPECT_GREATER(world.matchingStats.matchTimeAvg(), 0.0000001); @@ -523,10 +524,10 @@ TEST("require that match features are calculated (multi-threaded)") { world.basicSetup(); world.basicResults(); world.setup_match_features(); - SearchRequest::SP request = world.createSimpleRequest("f1", "spread"); - SearchReply::UP reply = world.performSearch(request, threads); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "spread"); + SearchReply::UP reply = world.performSearch(*request, threads); EXPECT_GREATER(reply->hits.size(), 0u); - world.verify_match_features(*reply, "f1"); + MyWorld::verify_match_features(*reply, "f1"); } } @@ -536,10 +537,10 @@ TEST("require that match features can be renamed") { world.basicResults(); world.setup_match_features(); world.setup_feature_renames(); - SearchRequest::SP request = world.createSimpleRequest("f1", "spread"); - SearchReply::UP reply = world.performSearch(request, 1); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "spread"); + SearchReply::UP reply = world.performSearch(*request, 1); EXPECT_GREATER(reply->hits.size(), 0u); - world.verify_match_feature_renames(*reply, "f1"); + MyWorld::verify_match_feature_renames(*reply, "f1"); } TEST("require that no hits gives no match feature names") { @@ -547,10 +548,10 @@ TEST("require that no hits gives no match feature names") { world.basicSetup(); world.basicResults(); world.setup_match_features(); - SearchRequest::SP request = world.createSimpleRequest("f1", "not_found"); - SearchReply::UP reply = world.performSearch(request, 1); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "not_found"); + SearchReply::UP reply = world.performSearch(*request, 1); EXPECT_EQUAL(reply->hits.size(), 0u); - world.verify_match_features(*reply, "f1"); + MyWorld::verify_match_features(*reply, "f1"); } TEST("require that matching also returns hits when only bitvector is used (multi-threaded)") { @@ -558,8 +559,8 @@ TEST("require that matching also returns hits when only bitvector is used (multi MyWorld world; world.basicSetup(0, 0); world.verbose_a1_result("all"); - SearchRequest::SP request = world.createSimpleRequest("a1", "all"); - SearchReply::UP reply = world.performSearch(request, threads); + SearchRequest::SP request = MyWorld::createSimpleRequest("a1", "all"); + SearchReply::UP reply = world.performSearch(*request, threads); EXPECT_EQUAL(985u, world.matchingStats.docsMatched()); EXPECT_EQUAL(10u, reply->hits.size()); EXPECT_GREATER(world.matchingStats.matchTimeAvg(), 0.0000001); @@ -571,8 +572,8 @@ TEST("require that ranking is performed (multi-threaded)") { MyWorld world; world.basicSetup(); world.basicResults(); - SearchRequest::SP request = world.createSimpleRequest("f1", "spread"); - SearchReply::UP reply = world.performSearch(request, threads); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "spread"); + SearchReply::UP reply = world.performSearch(*request, threads); EXPECT_EQUAL(9u, world.matchingStats.docsMatched()); EXPECT_EQUAL(9u, world.matchingStats.docsRanked()); EXPECT_EQUAL(0u, world.matchingStats.docsReRanked()); @@ -594,8 +595,8 @@ TEST("require that re-ranking is performed (multi-threaded)") { world.basicSetup(); world.setupSecondPhaseRanking(); world.basicResults(); - SearchRequest::SP request = world.createSimpleRequest("f1", "spread"); - SearchReply::UP reply = world.performSearch(request, threads); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "spread"); + SearchReply::UP reply = world.performSearch(*request, threads); EXPECT_EQUAL(9u, world.matchingStats.docsMatched()); EXPECT_EQUAL(9u, world.matchingStats.docsRanked()); EXPECT_EQUAL(3u, world.matchingStats.docsReRanked()); @@ -620,8 +621,8 @@ TEST("require that re-ranking is not diverse when not requested to be.") { world.basicSetup(); world.setupSecondPhaseRanking(); world.basicResults(); - SearchRequest::SP request = world.createSimpleRequest("f1", "spread"); - world.verify_diversity_filter(request, false); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "spread"); + world.verify_diversity_filter(*request, false); } using namespace search::fef::indexproperties::matchphase; @@ -631,12 +632,12 @@ TEST("require that re-ranking is diverse when requested to be") { world.basicSetup(); world.setupSecondPhaseRanking(); world.basicResults(); - SearchRequest::SP request = world.createSimpleRequest("f1", "spread"); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "spread"); auto & rankProperies = request->propertiesMap.lookupCreate(MapNames::RANK); rankProperies.add(DiversityAttribute::NAME, "a2") .add(DiversityMinGroups::NAME, "3") .add(DiversityCutoffStrategy::NAME, "strict"); - world.verify_diversity_filter(request, true); + world.verify_diversity_filter(*request, true); } TEST("require that re-ranking is diverse with diversity = 1/1") { @@ -644,12 +645,12 @@ TEST("require that re-ranking is diverse with diversity = 1/1") { world.basicSetup(); world.setupSecondPhaseRanking(); world.basicResults(); - SearchRequest::SP request = world.createSimpleRequest("f1", "spread"); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "spread"); auto & rankProperies = request->propertiesMap.lookupCreate(MapNames::RANK); rankProperies.add(DiversityAttribute::NAME, "a2") .add(DiversityMinGroups::NAME, "3") .add(DiversityCutoffStrategy::NAME, "strict"); - SearchReply::UP reply = world.performSearch(request, 1); + SearchReply::UP reply = world.performSearch(*request, 1); EXPECT_EQUAL(9u, world.matchingStats.docsMatched()); EXPECT_EQUAL(9u, world.matchingStats.docsRanked()); EXPECT_EQUAL(3u, world.matchingStats.docsReRanked()); @@ -671,12 +672,12 @@ TEST("require that re-ranking is diverse with diversity = 1/10") { world.basicSetup(); world.setupSecondPhaseRanking(); world.basicResults(); - SearchRequest::SP request = world.createSimpleRequest("f1", "spread"); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "spread"); auto & rankProperies = request->propertiesMap.lookupCreate(MapNames::RANK); rankProperies.add(DiversityAttribute::NAME, "a3") .add(DiversityMinGroups::NAME, "3") .add(DiversityCutoffStrategy::NAME, "strict"); - SearchReply::UP reply = world.performSearch(request, 1); + SearchReply::UP reply = world.performSearch(*request, 1); EXPECT_EQUAL(9u, world.matchingStats.docsMatched()); EXPECT_EQUAL(9u, world.matchingStats.docsRanked()); EXPECT_EQUAL(1u, world.matchingStats.docsReRanked()); @@ -699,9 +700,9 @@ TEST("require that sortspec can be used (multi-threaded)") { MyWorld world; world.basicSetup(); world.basicResults(); - SearchRequest::SP request = world.createSimpleRequest("f1", "spread"); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "spread"); request->sortSpec = "+a1"; - SearchReply::UP reply = world.performSearch(request, threads); + SearchReply::UP reply = world.performSearch(*request, threads); ASSERT_EQUAL(9u, reply->hits.size()); EXPECT_EQUAL(document::DocumentId("id:ns:searchdocument::100").getGlobalId(), reply->hits[0].gid); EXPECT_EQUAL(zero_rank_value, reply->hits[0].metric); @@ -720,7 +721,7 @@ TEST("require that grouping is performed (multi-threaded)") { MyWorld world; world.basicSetup(); world.basicResults(); - SearchRequest::SP request = world.createSimpleRequest("f1", "spread"); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "spread"); { vespalib::nbostream buf; vespalib::NBOSerializer os(buf); @@ -731,7 +732,7 @@ TEST("require that grouping is performed (multi-threaded)") { grequest.serialize(os); request->groupSpec.assign(buf.data(), buf.data() + buf.size()); } - SearchReply::UP reply = world.performSearch(request, threads); + SearchReply::UP reply = world.performSearch(*request, threads); { vespalib::nbostream buf(&reply->groupResult[0], reply->groupResult.size()); vespalib::NBOSerializer is(buf); @@ -754,7 +755,7 @@ TEST("require that summary features are filled") { MyWorld world; world.basicSetup(); world.basicResults(); - DocsumRequest::SP req = world.createSimpleDocsumRequest("f1", "foo"); + DocsumRequest::SP req = MyWorld::createSimpleDocsumRequest("f1", "foo"); FeatureSet::SP fs = world.getSummaryFeatures(*req); const FeatureSet::Value * f = nullptr; EXPECT_EQUAL(5u, fs->numFeatures()); @@ -796,7 +797,7 @@ TEST("require that rank features are filled") { MyWorld world; world.basicSetup(); world.basicResults(); - DocsumRequest::SP req = world.createSimpleDocsumRequest("f1", "foo"); + DocsumRequest::SP req = MyWorld::createSimpleDocsumRequest("f1", "foo"); FeatureSet::SP fs = world.getRankFeatures(*req); const FeatureSet::Value * f = nullptr; EXPECT_EQUAL(1u, fs->numFeatures()); @@ -817,11 +818,11 @@ TEST("require that search session can be cached") { MyWorld world; world.basicSetup(); world.basicResults(); - SearchRequest::SP request = world.createSimpleRequest("f1", "foo"); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "foo"); request->propertiesMap.lookupCreate(search::MapNames::CACHES).add("query", "true"); request->sessionId.push_back('a'); EXPECT_EQUAL(0u, world.sessionManager->getSearchStats().numInsert); - SearchReply::UP reply = world.performSearch(request, 1); + SearchReply::UP reply = world.performSearch(*request, 1); EXPECT_EQUAL(1u, world.sessionManager->getSearchStats().numInsert); SearchSession::SP session = world.sessionManager->pickSearch("a"); ASSERT_TRUE(session.get()); @@ -834,7 +835,7 @@ TEST("require that summary features can be renamed") { world.basicSetup(); world.setup_feature_renames(); world.basicResults(); - DocsumRequest::SP req = world.createSimpleDocsumRequest("f1", "foo"); + DocsumRequest::SP req = MyWorld::createSimpleDocsumRequest("f1", "foo"); FeatureSet::SP fs = world.getSummaryFeatures(*req); const FeatureSet::Value * f = nullptr; EXPECT_EQUAL(5u, fs->numFeatures()); @@ -853,10 +854,10 @@ TEST("require that getSummaryFeatures can use cached query setup") { MyWorld world; world.basicSetup(); world.basicResults(); - SearchRequest::SP request = world.createSimpleRequest("f1", "foo"); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "foo"); request->propertiesMap.lookupCreate(search::MapNames::CACHES).add("query", "true"); request->sessionId.push_back('a'); - world.performSearch(request, 1); + world.performSearch(*request, 1); DocsumRequest::SP docsum_request(new DocsumRequest); // no stack dump docsum_request->sessionId = request->sessionId; @@ -907,12 +908,12 @@ TEST("require that getSummaryFeatures prefers cached query setup") { MyWorld world; world.basicSetup(); world.basicResults(); - SearchRequest::SP request = world.createSimpleRequest("f1", "spread"); + SearchRequest::SP request = MyWorld::createSimpleRequest("f1", "spread"); request->propertiesMap.lookupCreate(search::MapNames::CACHES).add("query", "true"); request->sessionId.push_back('a'); - world.performSearch(request, 1); + world.performSearch(*request, 1); - DocsumRequest::SP req = world.createSimpleDocsumRequest("f1", "foo"); + DocsumRequest::SP req = MyWorld::createSimpleDocsumRequest("f1", "foo"); req->sessionId = request->sessionId; req->propertiesMap.lookupCreate(search::MapNames::CACHES).add("query", "true"); FeatureSet::SP fs = world.getSummaryFeatures(*req); @@ -1006,14 +1007,14 @@ TEST("require that match phase limiting works") { } world.add_match_phase_limiting_result("limiter", 152, descending, {948, 951, 963, 987, 991, 994, 997}); } - SearchRequest::SP request = world.createSimpleRequest("a1", "all"); + SearchRequest::SP request = MyWorld::createSimpleRequest("a1", "all"); if (query_time) { inject_match_phase_limiting(request->propertiesMap.lookupCreate(search::MapNames::RANK), "limiter", 150, descending); } if (use_sorting) { request->sortSpec = "-a1"; } - SearchReply::UP reply = world.performSearch(request, want_threads); + SearchReply::UP reply = world.performSearch(*request, want_threads); ASSERT_EQUAL(10u, reply->hits.size()); if (enable) { EXPECT_EQUAL(79u, reply->totalHitCount); @@ -1078,8 +1079,8 @@ TEST("require that same element search works") { MyWorld world; world.basicSetup(); world.add_same_element_results("foo", "bar"); - SearchRequest::SP request = world.createSameElementRequest("foo", "bar"); - SearchReply::UP reply = world.performSearch(request, 1); + SearchRequest::SP request = MyWorld::createSameElementRequest("foo", "bar"); + SearchReply::UP reply = world.performSearch(*request, 1); ASSERT_EQUAL(1u, reply->hits.size()); EXPECT_EQUAL(document::DocumentId("id:ns:searchdocument::20").getGlobalId(), reply->hits[0].gid); } @@ -1088,7 +1089,7 @@ TEST("require that docsum matcher can extract matching elements from same elemen MyWorld world; world.basicSetup(); world.add_same_element_results("foo", "bar"); - auto request = world.create_docsum_request(make_same_element_stack_dump("foo", "bar"), {20}); + auto request = MyWorld::create_docsum_request(make_same_element_stack_dump("foo", "bar"), {20}); MatchingElementsFields fields; fields.add_mapping("my", "my.a1"); fields.add_mapping("my", "my.f1"); @@ -1102,7 +1103,7 @@ TEST("require that docsum matcher can extract matching elements from single attr MyWorld world; world.basicSetup(); world.add_same_element_results("foo", "bar"); - auto request = world.create_docsum_request(make_simple_stack_dump("my.a1", "foo"), {20}); + auto request = MyWorld::create_docsum_request(make_simple_stack_dump("my.a1", "foo"), {20}); MatchingElementsFields fields; fields.add_mapping("my", "my.a1"); fields.add_mapping("my", "my.f1"); diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h index d1672eeb6dd..c4010a07709 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h @@ -133,7 +133,7 @@ private: RawDocumentMetaData removeInternal(DocId lid, uint64_t cached_iterator_sequence_id); void remove_batch_internal_btree(std::vector<LidAndRawDocumentMetaData>& removed); - MetaDataView make_meta_data_view() { return vespalib::ConstArrayRef(&_metaDataStore[0], getCommittedDocIdLimit()); } + MetaDataView make_meta_data_view() { return {&_metaDataStore[0], getCommittedDocIdLimit()}; } UnboundMetaDataView acquire_unbound_meta_data_view() const noexcept { return &_metaDataStore.acquire_elem_ref(0); } UnboundMetaDataView get_unbound_meta_data_view() const noexcept { return &_metaDataStore.get_elem_ref(0); } // Called from writer only @@ -148,13 +148,13 @@ public: sizeof(uint32_t) + GlobalId::LENGTH + sizeof(uint8_t) + sizeof(Timestamp); - DocumentMetaStore(BucketDBOwnerSP bucketDB); + explicit DocumentMetaStore(BucketDBOwnerSP bucketDB); DocumentMetaStore(BucketDBOwnerSP bucketDB, const vespalib::string & name); DocumentMetaStore(BucketDBOwnerSP bucketDB, const vespalib::string & name, const search::GrowStrategy & grow, SubDbType subDbType = SubDbType::READY); - ~DocumentMetaStore(); + ~DocumentMetaStore() override; /** * Implements documentmetastore::IStore. @@ -189,7 +189,7 @@ public: bool validLidFast(DocId lid) const { return _lidAlloc.validLid(lid); } bool validLidFast(DocId lid, uint32_t limit) const { return _lidAlloc.validLid(lid, limit); } bool validLid(DocId lid) const override { return validLidFast(lid); } - void removeBatch(const std::vector<DocId> &lidsToRemove, const DocId docIdLimit) override; + void removeBatch(const std::vector<DocId> &lidsToRemove, DocId docIdLimit) override; const RawDocumentMetaData & getRawMetaData(DocId lid) const override { return _metaDataStore.acquire_elem_ref(lid); } /** diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h index c4117f0b751..fce2968104d 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h @@ -19,7 +19,7 @@ public: search::AttributeGuard _guard; const DocumentMetaStore &_store; public: - ReadGuard(const search::AttributeVector::SP &metaStoreAttr); + explicit ReadGuard(const search::AttributeVector::SP &metaStoreAttr); const search::IDocumentMetaStore &get() const override { return _store; } }; private: @@ -27,7 +27,7 @@ private: IDocumentMetaStore::SP _metaStore; public: - DocumentMetaStoreContext(std::shared_ptr<bucketdb::BucketDBOwner> bucketDB); + explicit DocumentMetaStoreContext(std::shared_ptr<bucketdb::BucketDBOwner> bucketDB); /** * Create a new context instantiating a document meta store * with the given name, grow strategy, and comparator. @@ -40,7 +40,7 @@ public: * Create a new context with the given document meta store encapsulated * as an attribute vector. */ - DocumentMetaStoreContext(const search::AttributeVector::SP &metaStoreAttr); + explicit DocumentMetaStoreContext(const search::AttributeVector::SP &metaStoreAttr); proton::IDocumentMetaStore::SP getSP() const override { return _metaStore; } proton::IDocumentMetaStore & get() override { return *_metaStore; } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/i_document_meta_store_context.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/i_document_meta_store_context.h index 6ecc164aed2..e8e681661af 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/i_document_meta_store_context.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/i_document_meta_store_context.h @@ -14,7 +14,7 @@ struct IDocumentMetaStoreContext : public search::IDocumentMetaStoreContext { typedef std::shared_ptr<IDocumentMetaStoreContext> SP; - virtual ~IDocumentMetaStoreContext() {} + virtual ~IDocumentMetaStoreContext() = default; /** * Access to write interface. diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/i_simple_document_meta_store.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/i_simple_document_meta_store.h index b09bd808517..cbf832bb4c5 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/i_simple_document_meta_store.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/i_simple_document_meta_store.h @@ -14,7 +14,7 @@ namespace proton { struct ISimpleDocumentMetaStore : public documentmetastore::IStore, public documentmetastore::IBucketHandler { - virtual ~ISimpleDocumentMetaStore() {} + ~ISimpleDocumentMetaStore() override = default; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/matching/isearchcontext.h b/searchcore/src/vespa/searchcore/proton/matching/isearchcontext.h index 354e770f1b4..97ec283d672 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/isearchcontext.h +++ b/searchcore/src/vespa/searchcore/proton/matching/isearchcontext.h @@ -63,7 +63,7 @@ public: * Deleting the context will trigger cleanup in the * implementation. **/ - virtual ~ISearchContext() {} + virtual ~ISearchContext() = default; }; } diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp index 26ab2d10671..e8c7f2c5e44 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp @@ -8,6 +8,7 @@ #include "matcher.h" #include "sessionmanager.h" #include <vespa/searchcore/grouping/groupingcontext.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchlib/engine/docsumrequest.h> #include <vespa/searchlib/engine/searchrequest.h> #include <vespa/searchlib/engine/searchreply.h> @@ -187,7 +188,8 @@ namespace { SearchReply::UP Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundle, ISearchContext &searchContext, IAttributeContext &attrContext, SessionManager &sessionMgr, - const search::IDocumentMetaStore &metaStore, SearchSession::OwnershipBundle &&owned_objects) + const search::IDocumentMetaStore &metaStore, const bucketdb::BucketDBOwner & bucketdb, + SearchSession::OwnershipBundle &&owned_objects) { vespalib::Timer total_matching_time; MatchingStats my_stats; @@ -276,8 +278,7 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl SearchReply::Coverage & coverage = reply->coverage; coverage.setActive(numActiveLids); - //TODO this should be calculated with ClusterState calculator. - coverage.setTargetActive(numActiveLids); + coverage.setTargetActive(bucketdb.getNumActiveDocs()); coverage.setCovered(covered); if (wasLimited) { coverage.degradeMatchPhase(); @@ -322,7 +323,7 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl FeatureSet::SP Matcher::getSummaryFeatures(const DocsumRequest & req, ISearchContext & searchCtx, - IAttributeContext & attrCtx, SessionManager &sessionMgr) + IAttributeContext & attrCtx, SessionManager &sessionMgr) const { auto docsum_matcher = create_docsum_matcher(req, searchCtx, attrCtx, sessionMgr); return docsum_matcher->get_summary_features(); @@ -330,7 +331,7 @@ Matcher::getSummaryFeatures(const DocsumRequest & req, ISearchContext & searchCt FeatureSet::SP Matcher::getRankFeatures(const DocsumRequest & req, ISearchContext & searchCtx, - IAttributeContext & attrCtx, SessionManager &sessionMgr) + IAttributeContext & attrCtx, SessionManager &sessionMgr) const { auto docsum_matcher = create_docsum_matcher(req, searchCtx, attrCtx, sessionMgr); return docsum_matcher->get_rank_features(); @@ -339,7 +340,7 @@ Matcher::getRankFeatures(const DocsumRequest & req, ISearchContext & searchCtx, MatchingElements::UP Matcher::get_matching_elements(const DocsumRequest &req, ISearchContext &search_ctx, IAttributeContext &attr_ctx, SessionManager &session_manager, - const MatchingElementsFields &fields) + const MatchingElementsFields &fields) const { auto docsum_matcher = create_docsum_matcher(req, search_ctx, attr_ctx, session_manager); return docsum_matcher->get_matching_elements(fields); @@ -347,7 +348,7 @@ Matcher::get_matching_elements(const DocsumRequest &req, ISearchContext &search_ DocsumMatcher::UP Matcher::create_docsum_matcher(const DocsumRequest &req, ISearchContext &search_ctx, - IAttributeContext &attr_ctx, SessionManager &session_manager) + IAttributeContext &attr_ctx, SessionManager &session_manager) const { std::vector<uint32_t> docs; docs.reserve(req.hits.size()); diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.h b/searchcore/src/vespa/searchcore/proton/matching/matcher.h index ef79818a0b3..409f0ddeae5 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.h +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.h @@ -121,6 +121,7 @@ public: match(const SearchRequest &request, vespalib::ThreadBundle &threadBundle, ISearchContext &searchContext, IAttributeContext &attrContext, SessionManager &sessionManager, const search::IDocumentMetaStore &metaStore, + const bucketdb::BucketDBOwner & bucketdb, SearchSession::OwnershipBundle &&owned_objects); /** @@ -135,7 +136,7 @@ public: **/ search::FeatureSet::SP getSummaryFeatures(const DocsumRequest & req, ISearchContext & searchCtx, - IAttributeContext & attrCtx, SessionManager &sessionManager); + IAttributeContext & attrCtx, SessionManager &sessionManager) const; /** * Perform matching for the documents in the given docsum request @@ -149,7 +150,7 @@ public: **/ search::FeatureSet::SP getRankFeatures(const DocsumRequest & req, ISearchContext & searchCtx, - IAttributeContext & attrCtx, SessionManager &sessionManager); + IAttributeContext & attrCtx, SessionManager &sessionManager) const; /** * Perform partial matching for the documents in the given docsum request @@ -165,10 +166,10 @@ public: **/ MatchingElements::UP get_matching_elements(const DocsumRequest &req, ISearchContext &search_ctx, IAttributeContext &attr_ctx, SessionManager &session_manager, - const MatchingElementsFields &fields); + const MatchingElementsFields &fields) const; DocsumMatcher::UP create_docsum_matcher(const DocsumRequest &req, ISearchContext &search_ctx, - IAttributeContext &attr_ctx, SessionManager &session_manager); + IAttributeContext &attr_ctx, SessionManager &session_manager) const; /** * @return true if this rankprofile has summary-features enabled diff --git a/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp b/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp index 7123edd96ff..87a3de8d27a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/combiningfeedview.cpp @@ -23,9 +23,9 @@ std::shared_ptr<const DocumentTypeRepo> getRepo(const std::vector<IFeedView::SP> &views) { for (const auto &view : views) { - if (view.get() == nullptr) - continue; - return view->getDocumentTypeRepo(); + if (view) { + return view->getDocumentTypeRepo(); + } } LOG_ABORT("should not be reached"); } @@ -68,8 +68,7 @@ CombiningFeedView::getDocumentMetaStorePtr() const } void -CombiningFeedView::findPrevDbdId(const document::GlobalId &gid, - DocumentOperation &op) +CombiningFeedView::findPrevDbdId(const document::GlobalId &gid, DocumentOperation &op) { uint32_t subDbIdLim = _metaStores.size(); uint32_t skipSubDbId = std::numeric_limits<uint32_t>::max(); diff --git a/searchcore/src/vespa/searchcore/proton/server/matchview.cpp b/searchcore/src/vespa/searchcore/proton/server/matchview.cpp index 768e2c80b62..bd9c927e94e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/matchview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/matchview.cpp @@ -73,8 +73,9 @@ MatchView::match(std::shared_ptr<const ISearchHandler> searchHandler, const Sear owned_objects.context = createContext(); MatchContext *ctx = owned_objects.context.get(); const search::IDocumentMetaStore & dms = owned_objects.readGuard->get(); + const bucketdb::BucketDBOwner & bucketDB = _metaStore->get().getBucketDB(); return matcher->match(req, threadBundle, ctx->getSearchContext(), ctx->getAttributeContext(), - *_sessionMgr, dms, std::move(owned_objects)); + *_sessionMgr, dms, bucketDB, std::move(owned_objects)); } } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp index 5ad21390d10..fbb17a43ee6 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp @@ -343,9 +343,8 @@ StoreOnlyDocSubDB::getFlushTargetsInternal() StoreOnlyFeedView::Context StoreOnlyDocSubDB::getStoreOnlyFeedViewContext(const DocumentDBConfig &configSnapshot) { - return StoreOnlyFeedView::Context(getSummaryAdapter(), configSnapshot.getSchemaSP(), _metaStoreCtx, - configSnapshot.getDocumentTypeRepoSP(), _pendingLidsForCommit, - *_gidToLidChangeHandler, _writeService); + return { getSummaryAdapter(), configSnapshot.getSchemaSP(), _metaStoreCtx, configSnapshot.getDocumentTypeRepoSP(), + _pendingLidsForCommit, *_gidToLidChangeHandler, _writeService}; } StoreOnlyFeedView::PersistentParams @@ -353,7 +352,7 @@ StoreOnlyDocSubDB::getFeedViewPersistentParams() { SerialNum flushedDMSSN(_flushedDocumentMetaStoreSerialNum); SerialNum flushedDSSN(_flushedDocumentStoreSerialNum); - return StoreOnlyFeedView::PersistentParams(flushedDMSSN, flushedDSSN, _docTypeName, _subDbId, _subDbType); + return { flushedDMSSN, flushedDSSN, _docTypeName, _subDbId, _subDbType }; } void @@ -420,7 +419,7 @@ StoreOnlyDocSubDB::applyConfig(const DocumentDBConfig &newConfigSnapshot, const AllocStrategy alloc_strategy = newConfigSnapshot.get_alloc_config().make_alloc_strategy(_subDbType); reconfigure(newConfigSnapshot.getStoreConfig(), alloc_strategy); initFeedView(newConfigSnapshot); - return IReprocessingTask::List(); + return {}; } namespace { @@ -428,7 +427,7 @@ namespace { constexpr double RETIRED_DEAD_RATIO = 0.5; struct UpdateConfig : public search::attribute::IAttributeFunctor { - UpdateConfig(CompactionStrategy compactionStrategy) noexcept + explicit UpdateConfig(CompactionStrategy compactionStrategy) noexcept : _compactionStrategy(compactionStrategy) {} void operator()(search::attribute::IAttributeVector &iAttributeVector) override { @@ -490,7 +489,7 @@ StoreOnlyDocSubDB::reconfigureAttributesConsideringNodeState(OnDone onDone) { proton::IAttributeManager::SP StoreOnlyDocSubDB::getAttributeManager() const { - return proton::IAttributeManager::SP(); + return {}; } const searchcorespi::IIndexManager::SP & @@ -519,7 +518,7 @@ StoreOnlyDocSubDB::setIndexSchema(const Schema::SP &, SerialNum ) search::SearchableStats StoreOnlyDocSubDB::getSearchableStats() const { - return search::SearchableStats(); + return {}; } IDocumentRetriever::UP @@ -534,7 +533,7 @@ MatchingStats StoreOnlyDocSubDB::getMatcherStats(const vespalib::string &rankProfile) const { (void) rankProfile; - return MatchingStats(); + return {}; } void @@ -554,7 +553,7 @@ StoreOnlyDocSubDB::close() std::shared_ptr<IDocumentDBReference> StoreOnlyDocSubDB::getDocumentDBReference() { - return std::shared_ptr<IDocumentDBReference>(); + return {}; } StoreOnlySubDBFileHeaderContext:: diff --git a/searchlib/src/vespa/searchlib/common/idocumentmetastore.h b/searchlib/src/vespa/searchlib/common/idocumentmetastore.h index 5c5791f585a..0ad7f65f5c1 100644 --- a/searchlib/src/vespa/searchlib/common/idocumentmetastore.h +++ b/searchlib/src/vespa/searchlib/common/idocumentmetastore.h @@ -75,7 +75,7 @@ struct IDocumentMetaStore { typedef document::BucketId BucketId; typedef uint64_t Timestamp; - virtual ~IDocumentMetaStore() {} + virtual ~IDocumentMetaStore() = default; /** * Retrieves the gid associated with the given lid. |