diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-30 17:09:41 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-10-30 17:09:41 +0000 |
commit | 588e5d8e5bf4b9c9a3694e805fa889263c9cd6ff (patch) | |
tree | dd76f9f4881cebb84472437f21b4e04a8e84027f /searchcore | |
parent | 7b57360527d407f6588d99d8bef2333243e83f21 (diff) |
Use shared_ptr instead of reference.
Diffstat (limited to 'searchcore')
17 files changed, 131 insertions, 153 deletions
diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index 25cf028ecca..203b6646880 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -151,7 +151,7 @@ struct Fixture EmptyConstantValueFactory _constantValueFactory; ConstantValueRepo _constantValueRepo; vespalib::ThreadStackExecutor _summaryExecutor; - PendingLidTracker _pendingLidsForCommit; + std::shared_ptr<PendingLidTrackerBase> _pendingLidsForCommit; ViewSet _views; MyDocumentDBReferenceResolver _resolver; ConfigurerUP _configurer; @@ -166,7 +166,7 @@ Fixture::Fixture() _constantValueFactory(), _constantValueRepo(_constantValueFactory), _summaryExecutor(8, 128*1024), - _pendingLidsForCommit(), + _pendingLidsForCommit(std::make_shared<PendingLidTracker>()), _views(), _resolver(), _configurer() @@ -210,18 +210,14 @@ Fixture::initViewSet(ViewSet &views) std::move(matchView))); views.feedView.set( make_shared<SearchableFeedView>(StoreOnlyFeedView::Context(summaryAdapter, - schema, - views.searchView.get()->getDocumentMetaStore(), - *views._gidToLidChangeHandler, - views.repo, - views._writeService), - SearchableFeedView::PersistentParams( - views.serialNum, - views.serialNum, - views._docTypeName, - 0u /* subDbId */, - SubDbType::READY), - _pendingLidsForCommit, + schema, + views.searchView.get()->getDocumentMetaStore(), + views.repo, + _pendingLidsForCommit, + *views._gidToLidChangeHandler, + views._writeService), + SearchableFeedView::PersistentParams(views.serialNum, views.serialNum, + views._docTypeName, 0u, SubDbType::READY), FastAccessFeedView::Context(attrWriter, views._docIdLimit), SearchableFeedView::Context(indexWriter))); } @@ -238,35 +234,37 @@ struct MyFastAccessFeedView proton::IDocumentMetaStoreContext::SP _dmsc; std::shared_ptr<IGidToLidChangeHandler> _gidToLidChangeHandler; + std::shared_ptr<PendingLidTrackerBase> _pendingLidsForCommit; VarHolder<FastAccessFeedView::SP> _feedView; - explicit MyFastAccessFeedView(IThreadingService &writeService, PendingLidTrackerBase & pendinglidsForCommit) + explicit MyFastAccessFeedView(IThreadingService &writeService) : _fileHeaderContext(), _docIdLimit(0), _writeService(writeService), _hwInfo(), _dmsc(), _gidToLidChangeHandler(make_shared<DummyGidToLidChangeHandler>()), + _pendingLidsForCommit(std::make_shared<PendingLidTracker>()), _feedView() { - init(pendinglidsForCommit); + init(); } ~MyFastAccessFeedView(); - void init(PendingLidTrackerBase & pendinglidsForCommit) { + void init() { MySummaryAdapter::SP summaryAdapter = std::make_shared<MySummaryAdapter>(); Schema::SP schema = std::make_shared<Schema>(); _dmsc = make_shared<DocumentMetaStoreContext>(std::make_shared<BucketDBOwner>()); std::shared_ptr<const DocumentTypeRepo> repo = createRepo(); - StoreOnlyFeedView::Context storeOnlyCtx(summaryAdapter, schema, _dmsc, *_gidToLidChangeHandler, repo, - _writeService); + StoreOnlyFeedView::Context storeOnlyCtx(summaryAdapter, schema, _dmsc, repo, + _pendingLidsForCommit, *_gidToLidChangeHandler, _writeService); StoreOnlyFeedView::PersistentParams params(1, 1, DocTypeName(DOC_TYPE), 0, SubDbType::NOTREADY); auto mgr = make_shared<AttributeManager>(BASE_DIR, "test.subdb", TuneFileAttributes(), _fileHeaderContext, _writeService.attributeFieldWriter(), _writeService.shared(), _hwInfo); auto writer = std::make_shared<AttributeWriter>(mgr); FastAccessFeedView::Context fastUpdateCtx(writer, _docIdLimit); - _feedView.set(std::make_shared<FastAccessFeedView>(storeOnlyCtx, params, pendinglidsForCommit, fastUpdateCtx)); + _feedView.set(std::make_shared<FastAccessFeedView>(std::move(storeOnlyCtx), params, fastUpdateCtx)); } }; @@ -276,13 +274,12 @@ struct FastAccessFixture { vespalib::ThreadStackExecutor _sharedExecutor; ExecutorThreadingService _writeService; - PendingLidTracker _pendingLidsForCommit; MyFastAccessFeedView _view; FastAccessDocSubDBConfigurer _configurer; FastAccessFixture() : _sharedExecutor(1, 0x10000), _writeService(_sharedExecutor), - _view(_writeService, _pendingLidsForCommit), + _view(_writeService), _configurer(_view._feedView, std::make_unique<AttributeWriterFactory>(), "test") { vespalib::rmdir(BASE_DIR, true); @@ -466,7 +463,7 @@ TEST_F("require that we can reconfigure attribute manager", Fixture) AttributeCollectionSpec spec(specList, 1, 0); ReconfigParams params(CCR().setAttributesChanged(true).setSchemaChanged(true)); // Use new config snapshot == old config snapshot (only relevant for reprocessing) - f._configurer->reconfigure(*createConfig(), *createConfig(), spec, params, f._resolver, f._pendingLidsForCommit); + f._configurer->reconfigure(*createConfig(), *createConfig(), spec, params, f._resolver); ViewPtrs n = f._views.getViewPtrs(); { // verify search view @@ -505,7 +502,7 @@ checkAttributeWriterChangeOnRepoChange(Fixture &f, bool docTypeRepoChanged) AttributeCollectionSpec spec(specList, 1, 0); ReconfigParams params(CCR().setDocumentTypeRepoChanged(docTypeRepoChanged)); // Use new config snapshot == old config snapshot (only relevant for reprocessing) - f._configurer->reconfigure(*createConfig(), *createConfig(), spec, params, f._resolver, f._pendingLidsForCommit); + f._configurer->reconfigure(*createConfig(), *createConfig(), spec, params, f._resolver); auto newAttributeWriter = getAttributeWriter(f); if (docTypeRepoChanged) { EXPECT_NOT_EQUAL(oldAttributeWriter, newAttributeWriter); @@ -526,7 +523,7 @@ TEST_F("require that reconfigure returns reprocessing initializer when changing AttributeCollectionSpec spec(specList, 1, 0); ReconfigParams params(CCR().setAttributesChanged(true).setSchemaChanged(true)); IReprocessingInitializer::UP init = - f._configurer->reconfigure(*createConfig(), *createConfig(), spec, params, f._resolver, f._pendingLidsForCommit); + f._configurer->reconfigure(*createConfig(), *createConfig(), spec, params, f._resolver); EXPECT_TRUE(init.get() != nullptr); EXPECT_TRUE((dynamic_cast<AttributeReprocessingInitializer *>(init.get())) != nullptr); @@ -538,7 +535,7 @@ TEST_F("require that we can reconfigure attribute writer", FastAccessFixture) AttributeCollectionSpec::AttributeList specList; AttributeCollectionSpec spec(specList, 1, 0); FastAccessFeedView::SP o = f._view._feedView.get(); - f._configurer.reconfigure(*createConfig(), *createConfig(), spec, f._pendingLidsForCommit); + f._configurer.reconfigure(*createConfig(), *createConfig(), spec); FastAccessFeedView::SP n = f._view._feedView.get(); FastAccessFeedViewComparer cmp(o, n); @@ -553,7 +550,7 @@ TEST_F("require that reconfigure returns reprocessing initializer", FastAccessFi AttributeCollectionSpec::AttributeList specList; AttributeCollectionSpec spec(specList, 1, 0); IReprocessingInitializer::UP init = - f._configurer.reconfigure(*createConfig(), *createConfig(), spec, f._pendingLidsForCommit); + f._configurer.reconfigure(*createConfig(), *createConfig(), spec); EXPECT_TRUE(init.get() != nullptr); EXPECT_TRUE((dynamic_cast<AttributeReprocessingInitializer *>(init.get())) != nullptr); @@ -565,7 +562,7 @@ TEST_F("require that we can reconfigure summary manager", Fixture) ViewPtrs o = f._views.getViewPtrs(); ReconfigParams params(CCR().setSummarymapChanged(true)); // Use new config snapshot == old config snapshot (only relevant for reprocessing) - f._configurer->reconfigure(*createConfig(), *createConfig(), params, f._resolver, f._pendingLidsForCommit); + f._configurer->reconfigure(*createConfig(), *createConfig(), params, f._resolver); ViewPtrs n = f._views.getViewPtrs(); { // verify search view @@ -585,7 +582,7 @@ TEST_F("require that we can reconfigure matchers", Fixture) ViewPtrs o = f._views.getViewPtrs(); // Use new config snapshot == old config snapshot (only relevant for reprocessing) f._configurer->reconfigure(*createConfig(o.fv->getSchema()), *createConfig(o.fv->getSchema()), - ReconfigParams(CCR().setRankProfilesChanged(true)), f._resolver, f._pendingLidsForCommit); + ReconfigParams(CCR().setRankProfilesChanged(true)), f._resolver); ViewPtrs n = f._views.getViewPtrs(); { // verify search view diff --git a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp index 3adca0abb25..b875ab8e058 100644 --- a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp @@ -489,7 +489,7 @@ FeedTokenContext::~FeedTokenContext() = default; struct FixtureBase { MyTracer _tracer; - PendingLidTracker _pendingLidsForCommit; + std::shared_ptr<PendingLidTracker> _pendingLidsForCommit; SchemaContext sc; IIndexWriter::SP iw; ISummaryAdapter::SP sa; @@ -678,7 +678,7 @@ struct FixtureBase FixtureBase::FixtureBase() : _tracer(), - _pendingLidsForCommit(), + _pendingLidsForCommit(std::make_shared<PendingLidTracker>()), sc(), iw(std::make_shared<MyIndexWriter>(_tracer)), sa(std::make_shared<MySummaryAdapter>(*sc._builder->getDocumentTypeRepo())), @@ -716,14 +716,10 @@ struct SearchableFeedViewFixture : public FixtureBase SearchableFeedView fv; SearchableFeedViewFixture() : FixtureBase(), - fv(StoreOnlyFeedView::Context(sa, - sc._schema, - _dmsc, - *_gidToLidChangeHandler, - sc.getRepo(), - _writeService), + fv(StoreOnlyFeedView::Context(sa, sc._schema, _dmsc, + sc.getRepo(), _pendingLidsForCommit, + *_gidToLidChangeHandler, _writeService), pc.getParams(), - _pendingLidsForCommit, FastAccessFeedView::Context(aw, _docIdLimit), SearchableFeedView::Context(iw)) { @@ -740,14 +736,9 @@ struct FastAccessFeedViewFixture : public FixtureBase FastAccessFeedView fv; FastAccessFeedViewFixture() : FixtureBase(), - fv(StoreOnlyFeedView::Context(sa, - sc._schema, - _dmsc, - *_gidToLidChangeHandler, - sc.getRepo(), - _writeService), + fv(StoreOnlyFeedView::Context(sa, sc._schema, _dmsc, sc.getRepo(), _pendingLidsForCommit, + *_gidToLidChangeHandler, _writeService), pc.getParams(), - _pendingLidsForCommit, FastAccessFeedView::Context(aw, _docIdLimit)) { } diff --git a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp index 5f033b1b73a..cc8b3a85f18 100644 --- a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp @@ -86,17 +86,17 @@ struct MyMinimalFeedView : public MyMinimalFeedViewBase, public StoreOnlyFeedVie const DocumentMetaStore::SP &metaStore, searchcorespi::index::IThreadingService &writeService, const PersistentParams ¶ms, - PendingLidTrackerBase & pendingLidsForCommit, + std::shared_ptr<PendingLidTrackerBase> pendingLidsForCommit, int &outstandingMoveOps_) : MyMinimalFeedViewBase(), StoreOnlyFeedView(StoreOnlyFeedView::Context(summaryAdapter, - search::index::Schema::SP(), - std::make_shared<DocumentMetaStoreContext>(metaStore), - *gidToLidChangeHandler, + search::index::Schema::SP(), + std::make_shared<DocumentMetaStoreContext>(metaStore), myGetDocumentTypeRepo(), + std::move(pendingLidsForCommit), + *gidToLidChangeHandler, writeService), - params, - pendingLidsForCommit), + params), removeMultiAttributesCount(0), removeMultiIndexFieldsCount(0), heartBeatAttributesCount(0), @@ -134,10 +134,10 @@ struct MoveOperationFeedView : public MyMinimalFeedView { const DocumentMetaStore::SP &metaStore, searchcorespi::index::IThreadingService &writeService, const PersistentParams ¶ms, - PendingLidTrackerBase & pendingLidsForCommit, + std::shared_ptr<PendingLidTrackerBase> pendingLidsForCommit, int &outstandingMoveOps_) : MyMinimalFeedView(summaryAdapter, metaStore, writeService, - params, pendingLidsForCommit, outstandingMoveOps_), + params, std::move(pendingLidsForCommit), outstandingMoveOps_), putAttributesCount(0), putIndexFieldsCount(0), removeAttributesCount(0), @@ -190,7 +190,7 @@ struct FixtureBase { DocumentMetaStore::SP metaStore; vespalib::ThreadStackExecutor sharedExecutor; ExecutorThreadingService writeService; - PendingLidTracker pendingLidsForCoomit; + std::shared_ptr<PendingLidTrackerBase> pendingLidsForCoomit; typename FeedViewType::UP feedview; SerialNum serial_num; @@ -206,7 +206,7 @@ struct FixtureBase { subDbType)), sharedExecutor(1, 0x10000), writeService(sharedExecutor), - pendingLidsForCoomit(), + pendingLidsForCoomit(std::make_shared<PendingLidTracker>()), feedview(), serial_num(2u) { diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp index 6fcf4fc609d..be63bea85e4 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp @@ -116,7 +116,6 @@ FastAccessDocSubDB::initFeedView(IAttributeWriter::SP writer, const DocumentDBCo auto feedView = std::make_shared<FastAccessFeedView>( getStoreOnlyFeedViewContext(configSnapshot), getFeedViewPersistentParams(), - getUncommittedLidsTracker(), FastAccessFeedView::Context(std::move(writer), _docIdLimit)); _fastAccessFeedView.set(feedView); @@ -265,7 +264,7 @@ FastAccessDocSubDB::applyConfig(const DocumentDBConfig &newConfigSnapshot, const AttributeCollectionSpec::UP attrSpec = createAttributeSpec(newConfigSnapshot.getAttributesConfig(), serialNum); IReprocessingInitializer::UP initializer = - configurer.reconfigure(newConfigSnapshot, oldConfigSnapshot, *attrSpec, getUncommittedLidsTracker()); + configurer.reconfigure(newConfigSnapshot, oldConfigSnapshot, *attrSpec); if (initializer->hasReprocessors()) { tasks.push_back(IReprocessingTask::SP(createReprocessingTask(*initializer, newConfigSnapshot.getDocumentTypeRepoSP()).release())); diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp index e35e8c27113..a55267e3eb2 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp @@ -15,22 +15,21 @@ namespace proton { using ARIConfig = AttributeReprocessingInitializer::Config; void -FastAccessDocSubDBConfigurer::reconfigureFeedView(const FastAccessFeedView::SP &curr, - const Schema::SP &schema, - const std::shared_ptr<const DocumentTypeRepo> &repo, - IAttributeWriter::SP writer, - PendingLidTrackerBase & pendingLidsForCommit) +FastAccessDocSubDBConfigurer::reconfigureFeedView(FastAccessFeedView & curr, + Schema::SP schema, + std::shared_ptr<const DocumentTypeRepo> repo, + IAttributeWriter::SP writer) { _feedView.set(std::make_shared<FastAccessFeedView>( - StoreOnlyFeedView::Context(curr->getSummaryAdapter(), - schema, - curr->getDocumentMetaStore(), - curr->getGidToLidChangeHandler(), - repo, - curr->getWriteService()), - curr->getPersistentParams(), - pendingLidsForCommit, - FastAccessFeedView::Context(std::move(writer),curr->getDocIdLimit()))); + StoreOnlyFeedView::Context(curr.getSummaryAdapter(), + std::move(schema), + curr.getDocumentMetaStore(), + std::move(repo), + curr.getUncommittedLidTracker(), + curr.getGidToLidChangeHandler(), + curr.getWriteService()), + curr.getPersistentParams(), + FastAccessFeedView::Context(std::move(writer),curr.getDocIdLimit()))); } FastAccessDocSubDBConfigurer::FastAccessDocSubDBConfigurer(FeedViewVarHolder &feedView, @@ -47,13 +46,11 @@ FastAccessDocSubDBConfigurer::~FastAccessDocSubDBConfigurer() = default; IReprocessingInitializer::UP FastAccessDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig, const DocumentDBConfig &oldConfig, - const AttributeCollectionSpec &attrSpec, - PendingLidTrackerBase & pendingLidsForCommit) + const AttributeCollectionSpec &attrSpec) { FastAccessFeedView::SP oldView = _feedView.get(); IAttributeWriter::SP writer = _factory->create(oldView->getAttributeWriter(), attrSpec); - reconfigureFeedView(oldView, newConfig.getSchemaSP(), newConfig.getDocumentTypeRepoSP(), - writer, pendingLidsForCommit); + reconfigureFeedView(*oldView, newConfig.getSchemaSP(), newConfig.getDocumentTypeRepoSP(), writer); const document::DocumentType *newDocType = newConfig.getDocumentType(); const document::DocumentType *oldDocType = oldConfig.getDocumentType(); diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h index 659067ce67d..0321ee1335c 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h @@ -22,11 +22,10 @@ private: IAttributeWriterFactory::UP _factory; vespalib::string _subDbName; - void reconfigureFeedView(const FastAccessFeedView::SP &curr, - const search::index::Schema::SP &schema, - const std::shared_ptr<const document::DocumentTypeRepo> &repo, - IAttributeWriter::SP attrWriter, - PendingLidTrackerBase & pendingLidsForCommit); + void reconfigureFeedView(FastAccessFeedView & curr, + search::index::Schema::SP schema, + std::shared_ptr<const document::DocumentTypeRepo> repo, + IAttributeWriter::SP attrWriter); public: FastAccessDocSubDBConfigurer(FeedViewVarHolder &feedView, @@ -36,8 +35,7 @@ public: IReprocessingInitializer::UP reconfigure(const DocumentDBConfig &newConfig, const DocumentDBConfig &oldConfig, - const AttributeCollectionSpec &attrSpec, - PendingLidTrackerBase & pendingLidsForCommit); + const AttributeCollectionSpec &attrSpec); }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.cpp index 7fd3e194214..c8fa5c1e6c4 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.cpp @@ -61,9 +61,8 @@ FastAccessFeedView::heartBeatAttributes(SerialNum serialNum) _attributeWriter->heartBeat(serialNum); } -FastAccessFeedView::FastAccessFeedView(const StoreOnlyFeedView::Context &storeOnlyCtx, const PersistentParams ¶ms, - PendingLidTrackerBase & pendingLidsForCommit, const Context &ctx) - : Parent(storeOnlyCtx, params, pendingLidsForCommit), +FastAccessFeedView::FastAccessFeedView(StoreOnlyFeedView::Context storeOnlyCtx, const PersistentParams ¶ms, const Context &ctx) + : Parent(std::move(storeOnlyCtx), params), _attributeWriter(ctx._attrWriter), _docIdLimit(ctx._docIdLimit) {} diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.h index ff34b0c32c2..5956368b3dd 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.h +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.h @@ -51,8 +51,7 @@ protected: void internalForceCommit(SerialNum serialNum, OnForceCommitDoneType onCommitDone) override; public: - FastAccessFeedView(const StoreOnlyFeedView::Context &storeOnlyCtx, const PersistentParams ¶ms, - PendingLidTrackerBase & pendingLidsForCommit, const Context &ctx); + FastAccessFeedView(StoreOnlyFeedView::Context storeOnlyCtx, const PersistentParams ¶ms, const Context &ctx); ~FastAccessFeedView(); virtual const IAttributeWriter::SP &getAttributeWriter() const { 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 91bde4572ed..1e5c558af0b 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 @@ -27,20 +27,19 @@ typedef AttributeReprocessingInitializer::Config ARIConfig; void SearchableDocSubDBConfigurer::reconfigureFeedView(IAttributeWriter::SP attrWriter, - const Schema::SP &schema, - const std::shared_ptr<const DocumentTypeRepo> &repo, - PendingLidTrackerBase & pendingLidsForCommit) + Schema::SP schema, + std::shared_ptr<const DocumentTypeRepo> repo) { SearchableFeedView::SP curr = _feedView.get(); _feedView.set(std::make_shared<SearchableFeedView>( StoreOnlyFeedView::Context(curr->getSummaryAdapter(), - schema, + std::move(schema), curr->getDocumentMetaStore(), + std::move(repo), + curr->getUncommittedLidTracker(), curr->getGidToLidChangeHandler(), - repo, curr->getWriteService()), curr->getPersistentParams(), - pendingLidsForCommit, FastAccessFeedView::Context(std::move(attrWriter), curr->getDocIdLimit()), SearchableFeedView::Context(curr->getIndexWriter()))); } @@ -138,12 +137,11 @@ SearchableDocSubDBConfigurer:: reconfigure(const DocumentDBConfig &newConfig, const DocumentDBConfig &oldConfig, const ReconfigParams ¶ms, - IDocumentDBReferenceResolver &resolver, - PendingLidTrackerBase & pendingLidsForCommit) + IDocumentDBReferenceResolver &resolver) { assert(!params.shouldAttributeManagerChange()); AttributeCollectionSpec attrSpec(AttributeCollectionSpec::AttributeList(), 0, 0); - reconfigure(newConfig, oldConfig, attrSpec, params, resolver, pendingLidsForCommit); + reconfigure(newConfig, oldConfig, attrSpec, params, resolver); } namespace { @@ -175,8 +173,7 @@ SearchableDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig, const DocumentDBConfig &oldConfig, const AttributeCollectionSpec &attrSpec, const ReconfigParams ¶ms, - IDocumentDBReferenceResolver &resolver, - PendingLidTrackerBase & pendingLidsForCommit) + IDocumentDBReferenceResolver &resolver) { bool shouldMatchViewChange = false; bool shouldSearchViewChange = false; @@ -242,8 +239,7 @@ SearchableDocSubDBConfigurer::reconfigure(const DocumentDBConfig &newConfig, if (shouldFeedViewChange) { reconfigureFeedView(std::move(attrWriter), newConfig.getSchemaSP(), - newConfig.getDocumentTypeRepoSP(), - pendingLidsForCommit); + newConfig.getDocumentTypeRepoSP()); } return initializer; } 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 f2df6aff37e..d460bb6506f 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 @@ -46,9 +46,8 @@ private: uint32_t _distributionKey; void reconfigureFeedView(IAttributeWriter::SP attrWriter, - const search::index::Schema::SP &schema, - const std::shared_ptr<const document::DocumentTypeRepo> &repo, - PendingLidTrackerBase & pendingLidsForCommit); + search::index::Schema::SP schema, + std::shared_ptr<const document::DocumentTypeRepo> repo); void reconfigureMatchView(const searchcorespi::IndexSearchable::SP &indexSearchable); @@ -82,16 +81,14 @@ public: void reconfigure(const DocumentDBConfig &newConfig, const DocumentDBConfig &oldConfig, const ReconfigParams ¶ms, - IDocumentDBReferenceResolver &resolver, - PendingLidTrackerBase & pendingLidsForCommit); + IDocumentDBReferenceResolver &resolver); IReprocessingInitializer::UP reconfigure(const DocumentDBConfig &newConfig, const DocumentDBConfig &oldConfig, const AttributeCollectionSpec &attrSpec, const ReconfigParams ¶ms, - IDocumentDBReferenceResolver &resolver, - PendingLidTrackerBase & pendingLidsForCommit); + IDocumentDBReferenceResolver &resolver); }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp index cc3dc88c386..7cfad4f1ac1 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp @@ -30,10 +30,9 @@ SearchableFeedView::Context::Context(const IIndexWriter::SP &indexWriter) SearchableFeedView::Context::~Context() = default; -SearchableFeedView::SearchableFeedView(const StoreOnlyFeedView::Context &storeOnlyCtx, const PersistentParams ¶ms, - PendingLidTrackerBase & pendingLidsForCommit, +SearchableFeedView::SearchableFeedView(StoreOnlyFeedView::Context storeOnlyCtx, const PersistentParams ¶ms, const FastAccessFeedView::Context &fastUpdateCtx, Context ctx) - : Parent(storeOnlyCtx, params, pendingLidsForCommit, fastUpdateCtx), + : Parent(std::move(storeOnlyCtx), params, fastUpdateCtx), _indexWriter(ctx._indexWriter), _hasIndexedFields(_schema->getNumIndexFields() > 0) { } diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h index f796965f608..5eee23c60f2 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h @@ -54,8 +54,7 @@ private: void internalForceCommit(SerialNum serialNum, OnForceCommitDoneType onCommitDone) override; public: - SearchableFeedView(const StoreOnlyFeedView::Context &storeOnlyCtx, const PersistentParams ¶ms, - PendingLidTrackerBase & pendingLidsForCommit, + SearchableFeedView(StoreOnlyFeedView::Context storeOnlyCtx, const PersistentParams ¶ms, const FastAccessFeedView::Context &fastUpdateCtx, Context ctx); ~SearchableFeedView() override; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp index 9413ca0bb53..7f2b8fcaa63 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp @@ -155,7 +155,7 @@ SearchableDocSubDB::applyConfig(const DocumentDBConfig &newConfigSnapshot, const AttributeCollectionSpec::UP attrSpec = createAttributeSpec(newConfigSnapshot.getAttributesConfig(), serialNum); IReprocessingInitializer::UP initializer = - _configurer.reconfigure(newConfigSnapshot, oldConfigSnapshot, *attrSpec, params, resolver, getUncommittedLidsTracker()); + _configurer.reconfigure(newConfigSnapshot, oldConfigSnapshot, *attrSpec, params, resolver); if (initializer && initializer->hasReprocessors()) { tasks.emplace_back(createReprocessingTask(*initializer, newConfigSnapshot.getDocumentTypeRepoSP())); } @@ -164,7 +164,7 @@ SearchableDocSubDB::applyConfig(const DocumentDBConfig &newConfigSnapshot, const reconfigureAttributeMetrics(*newMgr, *oldMgr); } } else { - _configurer.reconfigure(newConfigSnapshot, oldConfigSnapshot, params, resolver, getUncommittedLidsTracker()); + _configurer.reconfigure(newConfigSnapshot, oldConfigSnapshot, params, resolver); } syncViews(); return tasks; @@ -229,7 +229,6 @@ SearchableDocSubDB::initFeedView(IAttributeWriter::SP attrWriter, assert(_writeService.master().isCurrentThread()); auto feedView = std::make_shared<SearchableFeedView>(getStoreOnlyFeedViewContext(configSnapshot), getFeedViewPersistentParams(), - getUncommittedLidsTracker(), FastAccessFeedView::Context(std::move(attrWriter), _docIdLimit), SearchableFeedView::Context(getIndexWriter())); diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp index f8dc41a5c92..908daf02206 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp @@ -117,6 +117,7 @@ StoreOnlyDocSubDB::StoreOnlyDocSubDB(const Config &cfg, const Context &ctx) _tlsSyncer(ctx._writeService.master(), ctx._getSerialNum, ctx._tlSyncer), _dmsFlushTarget(), _dmsShrinkTarget(), + _pendingLidsForCommit(std::make_shared<PendingLidTracker>()), _subDbId(cfg._subDbId), _subDbType(cfg._subDbType), _fileHeaderContext(*this, ctx._fileHeaderContext, _docTypeName, _baseDir), @@ -337,8 +338,8 @@ StoreOnlyFeedView::Context StoreOnlyDocSubDB::getStoreOnlyFeedViewContext(const DocumentDBConfig &configSnapshot) { return StoreOnlyFeedView::Context(getSummaryAdapter(), configSnapshot.getSchemaSP(), _metaStoreCtx, - *_gidToLidChangeHandler, configSnapshot.getDocumentTypeRepoSP(), - _writeService); + configSnapshot.getDocumentTypeRepoSP(), _pendingLidsForCommit, + *_gidToLidChangeHandler, _writeService); } StoreOnlyFeedView::PersistentParams @@ -353,7 +354,7 @@ void StoreOnlyDocSubDB::initViews(const DocumentDBConfig &configSnapshot, const SessionManager::SP &sessionManager) { assert(_writeService.master().isCurrentThread()); - _iSearchView.set(ISearchHandler::SP(new EmptySearchView)); + _iSearchView.set(std::make_shared<EmptySearchView>()); { std::lock_guard<std::mutex> guard(_configMutex); initFeedView(configSnapshot); @@ -390,8 +391,7 @@ StoreOnlyDocSubDB::initFeedView(const DocumentDBConfig &configSnapshot) { assert(_writeService.master().isCurrentThread()); auto feedView = std::make_shared<StoreOnlyFeedView>(getStoreOnlyFeedViewContext(configSnapshot), - getFeedViewPersistentParams(), - getUncommittedLidsTracker()); + getFeedViewPersistentParams()); // XXX: Not exception safe. _iFeedView.set(std::move(feedView)); diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h index c44499d9a70..1cdd22fcc41 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h @@ -156,7 +156,7 @@ private: TlsSyncer _tlsSyncer; DocumentMetaStoreFlushTarget::SP _dmsFlushTarget; std::shared_ptr<ShrinkLidSpaceFlushTarget> _dmsShrinkTarget; - PendingLidTracker _pendingLidsForCommit; + std::shared_ptr<PendingLidTrackerBase> _pendingLidsForCommit; IFlushTargetList getFlushTargets() override; protected: @@ -234,7 +234,7 @@ public: void close() override; std::shared_ptr<IDocumentDBReference> getDocumentDBReference() override; void tearDownReferences(IDocumentDBReferenceResolver &resolver) override; - PendingLidTrackerBase & getUncommittedLidsTracker() override { return _pendingLidsForCommit; } + PendingLidTrackerBase & getUncommittedLidsTracker() override { return *_pendingLidsForCommit; } }; } diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp index e1f8fba47a4..3146c0a37d7 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp @@ -211,17 +211,17 @@ moveMetaData(documentmetastore::IStore &meta_store, const DocumentId & doc_id, c } // namespace -StoreOnlyFeedView::StoreOnlyFeedView(const Context &ctx, const PersistentParams ¶ms, PendingLidTrackerBase & pendingLidsForCommit) +StoreOnlyFeedView::StoreOnlyFeedView(Context ctx, const PersistentParams ¶ms) : IFeedView(), FeedDebugger(), - _summaryAdapter(ctx._summaryAdapter), - _documentMetaStoreContext(ctx._documentMetaStoreContext), + _summaryAdapter(std::move(ctx._summaryAdapter)), + _documentMetaStoreContext(std::move(ctx._documentMetaStoreContext)), _repo(ctx._repo), _docType(nullptr), _lidReuseDelayer(ctx._writeService, _documentMetaStoreContext->get()), _pendingLidsForDocStore(), - _pendingLidsForCommit(pendingLidsForCommit), - _schema(ctx._schema), + _pendingLidsForCommit(std::move(ctx._pendingLidsForCommit)), + _schema(std::move(ctx._schema)), _writeService(ctx._writeService), _params(params), _metaStore(_documentMetaStoreContext->get()), @@ -231,6 +231,8 @@ StoreOnlyFeedView::StoreOnlyFeedView(const Context &ctx, const PersistentParams } StoreOnlyFeedView::~StoreOnlyFeedView() = default; +StoreOnlyFeedView::Context::Context(Context &&) noexcept = default; +StoreOnlyFeedView::Context::~Context() = default; void StoreOnlyFeedView::sync() @@ -242,7 +244,7 @@ void StoreOnlyFeedView::forceCommit(SerialNum serialNum, DoneCallback onDone) { internalForceCommit(serialNum, std::make_shared<ForceCommitContext>(_writeService.master(), _metaStore, - _pendingLidsForCommit.produceSnapshot(), + _pendingLidsForCommit->produceSnapshot(), std::move(onDone))); } @@ -262,7 +264,7 @@ StoreOnlyFeedView::internalForceCommit(SerialNum serialNum, OnForceCommitDoneTyp IPendingLidTracker::Token StoreOnlyFeedView::get_pending_lid_token(const DocumentOperation &op) { - return (op.getValidDbdId(_params._subDbId) ? _pendingLidsForCommit.produce(op.getLid()) : IPendingLidTracker::Token()); + return (op.getValidDbdId(_params._subDbId) ? _pendingLidsForCommit->produce(op.getLid()) : IPendingLidTracker::Token()); } void @@ -322,7 +324,7 @@ StoreOnlyFeedView::internalPut(FeedToken token, const PutOperation &putOp) } if (docAlreadyExists && putOp.changedDbdId()) { assert(!putOp.getValidDbdId(_params._subDbId)); - internalRemove(std::move(token), _pendingLidsForCommit.produce(putOp.getPrevLid()), serialNum, + internalRemove(std::move(token), _pendingLidsForCommit->produce(putOp.getPrevLid()), serialNum, std::move(pendingNotifyRemoveDone), putOp.getPrevLid(), IDestructorCallback::SP()); } } @@ -592,7 +594,7 @@ StoreOnlyFeedView::internalRemove(FeedToken token, const RemoveOperationWithDocI if (rmOp.getValidPrevDbdId(_params._subDbId)) { if (rmOp.changedDbdId()) { assert(!rmOp.getValidDbdId(_params._subDbId)); - internalRemove(std::move(token), _pendingLidsForCommit.produce(rmOp.getPrevLid()), serialNum, + internalRemove(std::move(token), _pendingLidsForCommit->produce(rmOp.getPrevLid()), serialNum, std::move(pendingNotifyRemoveDone), rmOp.getPrevLid(), IDestructorCallback::SP()); } } @@ -606,12 +608,12 @@ StoreOnlyFeedView::internalRemove(FeedToken token, const RemoveOperationWithGid const SerialNum serialNum = rmOp.getSerialNum(); DocumentId dummy; PendingNotifyRemoveDone pendingNotifyRemoveDone = adjustMetaStore(rmOp, rmOp.getGlobalId(), dummy); - auto uncommitted = _pendingLidsForCommit.produce(rmOp.getLid()); + auto uncommitted = _pendingLidsForCommit->produce(rmOp.getLid()); if (rmOp.getValidPrevDbdId(_params._subDbId)) { if (rmOp.changedDbdId()) { assert(!rmOp.getValidDbdId(_params._subDbId)); - internalRemove(std::move(token), _pendingLidsForCommit.produce(rmOp.getPrevLid()), serialNum, std::move(pendingNotifyRemoveDone), + internalRemove(std::move(token), _pendingLidsForCommit->produce(rmOp.getPrevLid()), serialNum, std::move(pendingNotifyRemoveDone), rmOp.getPrevLid(), IDestructorCallback::SP()); } } @@ -778,7 +780,7 @@ StoreOnlyFeedView::handleMove(const MoveOperation &moveOp, IDestructorCallback:: if (moveOp.getValidDbdId(_params._subDbId)) { const document::GlobalId &gid = docId.getGlobalId(); std::shared_ptr<PutDoneContext> onWriteDone = - createPutDoneContext(FeedToken(), _pendingLidsForCommit.produce(moveOp.getLid()), + createPutDoneContext(FeedToken(), _pendingLidsForCommit->produce(moveOp.getLid()), _gidToLidChangeHandler, doc, gid, moveOp.getLid(), serialNum, moveOp.changedDbdId() && useDocumentMetaStore(serialNum), doneCtx); putSummary(serialNum, moveOp.getLid(), doc, onWriteDone); @@ -786,7 +788,7 @@ StoreOnlyFeedView::handleMove(const MoveOperation &moveOp, IDestructorCallback:: putIndexedFields(serialNum, moveOp.getLid(), doc, onWriteDone); } if (docAlreadyExists && moveOp.changedDbdId()) { - internalRemove(FeedToken(), _pendingLidsForCommit.produce(moveOp.getPrevLid()), serialNum, std::move(pendingNotifyRemoveDone), moveOp.getPrevLid(), doneCtx); + internalRemove(FeedToken(), _pendingLidsForCommit->produce(moveOp.getPrevLid()), serialNum, std::move(pendingNotifyRemoveDone), moveOp.getPrevLid(), doneCtx); } } @@ -825,7 +827,7 @@ StoreOnlyFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op) if (useDocumentMetaStore(serialNum)) { getDocumentMetaStore()->get().compactLidSpace(op.getLidLimit()); auto commitContext(std::make_shared<ForceCommitContext>(_writeService.master(), _metaStore, - _pendingLidsForCommit.produceSnapshot(), + _pendingLidsForCommit->produceSnapshot(), DoneCallback())); commitContext->holdUnblockShrinkLidSpace(); internalForceCommit(serialNum, commitContext); diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h index f762f7273b0..3ce2955cce8 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h @@ -73,26 +73,31 @@ public: struct Context { - const ISummaryAdapter::SP &_summaryAdapter; - const search::index::Schema::SP &_schema; - const IDocumentMetaStoreContext::SP &_documentMetaStoreContext; - IGidToLidChangeHandler &_gidToLidChangeHandler; - const std::shared_ptr<const document::DocumentTypeRepo> &_repo; - searchcorespi::index::IThreadingService &_writeService; - - Context(const ISummaryAdapter::SP &summaryAdapter, - const search::index::Schema::SP &schema, - const IDocumentMetaStoreContext::SP &documentMetaStoreContext, + ISummaryAdapter::SP _summaryAdapter; + search::index::Schema::SP _schema; + IDocumentMetaStoreContext::SP _documentMetaStoreContext; + std::shared_ptr<const document::DocumentTypeRepo> _repo; + std::shared_ptr<PendingLidTrackerBase> _pendingLidsForCommit; + IGidToLidChangeHandler &_gidToLidChangeHandler; + searchcorespi::index::IThreadingService &_writeService; + + Context(ISummaryAdapter::SP summaryAdapter, + search::index::Schema::SP schema, + IDocumentMetaStoreContext::SP documentMetaStoreContext, + std::shared_ptr<const document::DocumentTypeRepo> repo, + std::shared_ptr<PendingLidTrackerBase> pendingLidsForCommit, IGidToLidChangeHandler &gidToLidChangeHandler, - const std::shared_ptr<const document::DocumentTypeRepo> &repo, searchcorespi::index::IThreadingService &writeService) - : _summaryAdapter(summaryAdapter), - _schema(schema), - _documentMetaStoreContext(documentMetaStoreContext), + : _summaryAdapter(std::move(summaryAdapter)), + _schema(std::move(schema)), + _documentMetaStoreContext(std::move(documentMetaStoreContext)), + _repo(std::move(repo)), + _pendingLidsForCommit(std::move(pendingLidsForCommit)), _gidToLidChangeHandler(gidToLidChangeHandler), - _repo(repo), _writeService(writeService) {} + Context(Context &&) noexcept; + ~Context(); }; struct PersistentParams @@ -139,7 +144,7 @@ private: const document::DocumentType *_docType; LidReuseDelayer _lidReuseDelayer; PendingLidTracker _pendingLidsForDocStore; - PendingLidTrackerBase &_pendingLidsForCommit; + std::shared_ptr<PendingLidTrackerBase> _pendingLidsForCommit; protected: const search::index::Schema::SP _schema; @@ -207,7 +212,7 @@ protected: virtual void removeIndexedFields(SerialNum serialNum, const LidVector &lidsToRemove, OnWriteDoneType onWriteDone); virtual void internalForceCommit(SerialNum serialNum, OnForceCommitDoneType onCommitDone); public: - StoreOnlyFeedView(const Context &ctx, const PersistentParams ¶ms, PendingLidTrackerBase & pendingLidsForCommit); + StoreOnlyFeedView(Context ctx, const PersistentParams ¶ms); ~StoreOnlyFeedView() override; const ISummaryAdapter::SP &getSummaryAdapter() const { return _summaryAdapter; } @@ -244,6 +249,7 @@ public: */ void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &pruneOp) override; void handleCompactLidSpace(const CompactLidSpaceOperation &op) override; + std::shared_ptr<PendingLidTrackerBase> getUncommittedLidTracker() { return _pendingLidsForCommit; } }; } |