diff options
author | Geir Storli <geirstorli@yahoo.no> | 2017-09-06 17:40:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-06 17:40:20 +0200 |
commit | 92526ea24add9baecf8e41b3c99fc3adf7b89e49 (patch) | |
tree | 39d7112c13176d67f7e55aaa51d7dee6030e7aad | |
parent | a7c528c42b0b050878f41f57f9cd9b7f96da0bbb (diff) | |
parent | 4c6a0f839b0d4c64cb2e1f4629ef832d1e275c44 (diff) |
Merge pull request #3352 from vespa-engine/toregge/use-gid-to-lid-change-handler-interface-directly-limited-edition-1
Use gid to lid change handler interface directly (retry)
20 files changed, 151 insertions, 138 deletions
diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index f0a91a101eb..d76117df4c2 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -24,6 +24,7 @@ #include <vespa/searchcore/proton/test/documentdb_config_builder.h> #include <vespa/searchcore/proton/test/mock_summary_adapter.h> #include <vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h> +#include <vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/transactionlog/nosyncproxy.h> #include <vespa/vespalib/io/fileutil.h> @@ -95,6 +96,7 @@ struct ViewSet search::transactionlog::NoSyncProxy _noTlSyncer; ISummaryManager::SP _summaryMgr; IDocumentMetaStoreContext::SP _dmsc; + std::shared_ptr<IGidToLidChangeHandler> _gidToLidChangeHandler; std::unique_ptr<documentmetastore::ILidReuseDelayer> _lidReuseDelayer; CommitTimeTracker _commitTimeTracker; VarHolder<SearchView::SP> searchView; @@ -123,6 +125,7 @@ ViewSet::ViewSet() _noTlSyncer(), _summaryMgr(), _dmsc(), + _gidToLidChangeHandler(), _lidReuseDelayer(), _commitTimeTracker(TimeStamp()), searchView(), @@ -211,7 +214,7 @@ Fixture::initViewSet(ViewSet &views) IIndexWriter::SP indexWriter(new IndexWriter(indexMgr)); AttributeWriter::SP attrWriter(new AttributeWriter(attrMgr)); ISummaryAdapter::SP summaryAdapter(new SummaryAdapter(summaryMgr)); - std::shared_ptr<IGidToLidChangeHandler> gidToLidChangeHandler(std::make_shared<MockGidToLidChangeHandler>()); + views._gidToLidChangeHandler = std::make_shared<MockGidToLidChangeHandler>(); Schema::SP schema(new Schema()); views._summaryMgr = summaryMgr; views._dmsc = metaStore; @@ -236,6 +239,7 @@ Fixture::initViewSet(ViewSet &views) new SearchableFeedView(StoreOnlyFeedView::Context(summaryAdapter, schema, views.searchView.get()->getDocumentMetaStore(), + *views._gidToLidChangeHandler, views.repo, views._writeService, *views._lidReuseDelayer, @@ -248,7 +252,7 @@ Fixture::initViewSet(ViewSet &views) 0u /* subDbId */, SubDbType::READY), FastAccessFeedView::Context(attrWriter, views._docIdLimit), - SearchableFeedView::Context(indexWriter, gidToLidChangeHandler)))); + SearchableFeedView::Context(indexWriter)))); } @@ -263,6 +267,7 @@ struct MyFastAccessFeedView HwInfo _hwInfo; IDocumentMetaStoreContext::SP _dmsc; + std::shared_ptr<IGidToLidChangeHandler> _gidToLidChangeHandler; std::unique_ptr<documentmetastore::ILidReuseDelayer> _lidReuseDelayer; CommitTimeTracker _commitTimeTracker; VarHolder<FastAccessFeedView::SP> _feedView; @@ -274,6 +279,7 @@ struct MyFastAccessFeedView _writeService(writeService), _hwInfo(), _dmsc(), + _gidToLidChangeHandler(std::make_shared<DummyGidToLidChangeHandler>()), _lidReuseDelayer(), _commitTimeTracker(TimeStamp()), _feedView() @@ -293,7 +299,7 @@ struct MyFastAccessFeedView new documentmetastore::LidReuseDelayer(_writeService, docMetaCtx->get())); DocumentTypeRepo::SP repo = createRepo(); - StoreOnlyFeedView::Context storeOnlyCtx(summaryAdapter, schema, docMetaCtx, repo, _writeService, *_lidReuseDelayer, _commitTimeTracker); + StoreOnlyFeedView::Context storeOnlyCtx(summaryAdapter, schema, docMetaCtx, *_gidToLidChangeHandler, repo, _writeService, *_lidReuseDelayer, _commitTimeTracker); StoreOnlyFeedView::PersistentParams params(1, 1, DocTypeName(DOC_TYPE), _metrics, 0, SubDbType::NOTREADY); AttributeManager::SP mgr(new AttributeManager(BASE_DIR, "test.subdb", TuneFileAttributes(), diff --git a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp index 2ed60f3c078..8af365d6327 100644 --- a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp @@ -755,13 +755,14 @@ struct SearchableFeedViewFixture : public FixtureBase fv(StoreOnlyFeedView::Context(sa, sc._schema, _dmsc, + *_gidToLidChangeHandler, sc.getRepo(), _writeService, _lidReuseDelayer, _commitTimeTracker), pc.getParams(), FastAccessFeedView::Context(aw, _docIdLimit), - SearchableFeedView::Context(iw, _gidToLidChangeHandler)) + SearchableFeedView::Context(iw)) { runInMaster([&]() { _lidReuseDelayer.setHasIndexedOrAttributeFields(true); }); } @@ -776,6 +777,7 @@ struct FastAccessFeedViewFixture : public FixtureBase fv(StoreOnlyFeedView::Context(sa, sc._schema, _dmsc, + *_gidToLidChangeHandler, sc.getRepo(), _writeService, _lidReuseDelayer, diff --git a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp index 15bd55441d4..1ec201fdbd2 100644 --- a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp @@ -12,6 +12,7 @@ #include <vespa/searchcore/proton/server/putdonecontext.h> #include <vespa/searchcore/proton/server/removedonecontext.h> #include <vespa/searchcore/proton/server/storeonlyfeedview.h> +#include <vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.h> #include <vespa/searchcore/proton/test/mock_summary_adapter.h> #include <vespa/searchcore/proton/test/thread_utils.h> #include <vespa/searchlib/common/idestructorcallback.h> @@ -67,7 +68,17 @@ DocumentTypeRepo::SP myGetDocumentTypeRepo() { return repo; } -struct MyMinimalFeedView : public StoreOnlyFeedView { +struct MyMinimalFeedViewBase +{ + std::shared_ptr<IGidToLidChangeHandler> gidToLidChangeHandler; + + MyMinimalFeedViewBase() + : gidToLidChangeHandler(std::make_shared<DummyGidToLidChangeHandler>()) + { + } +}; + +struct MyMinimalFeedView : public MyMinimalFeedViewBase, public StoreOnlyFeedView { using UP = std::unique_ptr<MyMinimalFeedView>; int removeMultiAttributesCount; @@ -83,10 +94,12 @@ struct MyMinimalFeedView : public StoreOnlyFeedView { CommitTimeTracker &commitTimeTracker, const PersistentParams ¶ms, int &outstandingMoveOps_) : + MyMinimalFeedViewBase(), StoreOnlyFeedView(StoreOnlyFeedView::Context(summaryAdapter, search::index::Schema::SP(), DocumentMetaStoreContext::SP( new DocumentMetaStoreContext(metaStore)), + *gidToLidChangeHandler, myGetDocumentTypeRepo(), writeService, lidReuseDelayer, diff --git a/searchcore/src/vespa/searchcore/proton/reference/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/reference/CMakeLists.txt index ca55b44c13d..fe2ca7a7a88 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/reference/CMakeLists.txt @@ -4,6 +4,7 @@ vespa_add_library(searchcore_reference STATIC document_db_reference.cpp document_db_reference_registry.cpp document_db_reference_resolver.cpp + dummy_gid_to_lid_change_handler.cpp gid_to_lid_change_handler.cpp gid_to_lid_change_listener.cpp gid_to_lid_change_registrator.cpp diff --git a/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.cpp b/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.cpp new file mode 100644 index 00000000000..c3c516a51dc --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.cpp @@ -0,0 +1,43 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "dummy_gid_to_lid_change_handler.h" + +namespace proton { + +DummyGidToLidChangeHandler::DummyGidToLidChangeHandler() + : IGidToLidChangeHandler() + +{ +} + +DummyGidToLidChangeHandler::~DummyGidToLidChangeHandler() +{ +} + +void +DummyGidToLidChangeHandler::notifyPut(GlobalId, uint32_t, SerialNum) +{ +} + +void +DummyGidToLidChangeHandler::notifyRemove(GlobalId, SerialNum) +{ +} + +void +DummyGidToLidChangeHandler::notifyRemoveDone(GlobalId, SerialNum) +{ +} + +void +DummyGidToLidChangeHandler::addListener(std::unique_ptr<IGidToLidChangeListener>) +{ +} + +void +DummyGidToLidChangeHandler::removeListeners(const vespalib::string &, + const std::set<vespalib::string> &) +{ +} + +} // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.h b/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.h new file mode 100644 index 00000000000..24773924aaa --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.h @@ -0,0 +1,35 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include "i_gid_to_lid_change_handler.h" +#include <vector> +#include <mutex> +#include <vespa/vespalib/stllike/hash_map.h> +#include <vespa/document/base/globalid.h> + +namespace searchcorespi { namespace index { class IThreadService; } } + +namespace proton { + +/* + * Dummy class for registering listeners that get notification when + * gid to lid mapping changes. + */ +class DummyGidToLidChangeHandler : public IGidToLidChangeHandler +{ + bool _closed; + +public: + DummyGidToLidChangeHandler(); + virtual ~DummyGidToLidChangeHandler(); + + virtual void notifyPut(GlobalId gid, uint32_t lid, SerialNum serialNum) override; + virtual void notifyRemove(GlobalId gid, SerialNum serialNum) override; + virtual void notifyRemoveDone(GlobalId gid, SerialNum serialNum) override; + virtual void addListener(std::unique_ptr<IGidToLidChangeListener> listener) override; + virtual void removeListeners(const vespalib::string &docTypeName, + const std::set<vespalib::string> &keepNames) override; +}; + +} // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.h b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.h index 736a34aba76..840cb61cc2a 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.h +++ b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.h @@ -33,9 +33,6 @@ public: GidToLidChangeHandler(); virtual ~GidToLidChangeHandler(); - /** - * Notify gid to lid mapping change. - */ virtual void notifyPut(GlobalId gid, uint32_t lid, SerialNum serialNum) override; virtual void notifyRemove(GlobalId gid, SerialNum serialNum) override; virtual void notifyRemoveDone(GlobalId gid, SerialNum serialNum) override; @@ -45,16 +42,7 @@ public: */ void close(); - /* - * Add listener unless a listener with matching docTypeName and - * name already exists. - */ virtual void addListener(std::unique_ptr<IGidToLidChangeListener> listener) override; - - /** - * Remove listeners with matching docTypeName unless name is present in - * keepNames. - */ virtual void removeListeners(const vespalib::string &docTypeName, const std::set<vespalib::string> &keepNames) override; }; diff --git a/searchcore/src/vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h b/searchcore/src/vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h index a3b1db59abd..53ade83ff32 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h +++ b/searchcore/src/vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h @@ -25,10 +25,21 @@ public: virtual ~IGidToLidChangeHandler() { } + /* + * Add listener unless a listener with matching docTypeName and + * name already exists. + */ virtual void addListener(std::unique_ptr<IGidToLidChangeListener> listener) = 0; + /** + * Remove listeners with matching docTypeName unless name is present in + * keepNames. + */ virtual void removeListeners(const vespalib::string &docTypeName, const std::set<vespalib::string> &keepNames) = 0; + /** + * Notify gid to lid mapping change. + */ virtual void notifyPut(GlobalId gid, uint32_t lid, SerialNum serialNum) = 0; virtual void notifyRemove(GlobalId gid, SerialNum serialNum) = 0; virtual void notifyRemoveDone(GlobalId gid, SerialNum serialNum) = 0; 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 94663273414..2b9a37fac0b 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 @@ -24,6 +24,7 @@ FastAccessDocSubDBConfigurer::reconfigureFeedView(const FastAccessFeedView::SP & StoreOnlyFeedView::Context(curr->getSummaryAdapter(), schema, curr->getDocumentMetaStore(), + curr->getGidToLidChangeHandler(), repo, curr->getWriteService(), curr->getLidReuseDelayer(), 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 1127f73a778..571e64e104c 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 @@ -47,12 +47,13 @@ SearchableDocSubDBConfigurer::reconfigureFeedView(const IIndexWriter::SP &indexW StoreOnlyFeedView::Context(summaryAdapter, schema, searchView->getDocumentMetaStore(), + curr->getGidToLidChangeHandler(), repo, curr->getWriteService(), curr->getLidReuseDelayer(), curr->getCommitTimeTracker()), curr->getPersistentParams(), FastAccessFeedView::Context(attrWriter, curr->getDocIdLimit()), - SearchableFeedView::Context(indexWriter, curr->getGidToLidChangeHandler())))); + SearchableFeedView::Context(indexWriter)))); } void 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 913956c509f..14556c86c18 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp @@ -7,7 +7,6 @@ #include <vespa/searchcore/proton/common/feedtoken.h> #include <vespa/searchcore/proton/metrics/feed_metrics.h> #include <vespa/searchcore/proton/documentmetastore/ilidreusedelayer.h> -#include <vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h> #include <vespa/vespalib/text/stringtokenizer.h> #include <vespa/vespalib/util/closuretask.h> #include <vespa/vespalib/util/exceptions.h> @@ -37,10 +36,8 @@ bool shouldTrace(StoreOnlyFeedView::OnOperationDoneType onWriteDone, uint32_t tr } -SearchableFeedView::Context::Context(const IIndexWriter::SP &indexWriter, - const std::shared_ptr<IGidToLidChangeHandler> &gidToLidChangeHandler) - : _indexWriter(indexWriter), - _gidToLidChangeHandler(gidToLidChangeHandler) +SearchableFeedView::Context::Context(const IIndexWriter::SP &indexWriter) + : _indexWriter(indexWriter) {} @@ -52,8 +49,7 @@ SearchableFeedView::SearchableFeedView(const StoreOnlyFeedView::Context &storeOn Context ctx) : Parent(storeOnlyCtx, params, fastUpdateCtx), _indexWriter(ctx._indexWriter), - _hasIndexedFields(_schema->getNumIndexFields() > 0), - _gidToLidChangeHandler(ctx._gidToLidChangeHandler) + _hasIndexedFields(_schema->getNumIndexFields() > 0) { } SearchableFeedView::~SearchableFeedView() {} @@ -261,22 +257,4 @@ SearchableFeedView::forceCommit(SerialNum serialNum, OnForceCommitDoneType onCom _writeService.index().execute(makeLambdaTask([=]() { performIndexForceCommit(serialNum, onCommitDone); })); } -void -SearchableFeedView::notifyPutGidToLidChange(const document::GlobalId &gid, uint32_t lid, SerialNum serialNum) -{ - _gidToLidChangeHandler->notifyPut(gid, lid, serialNum); -} - -void -SearchableFeedView::notifyRemoveGidToLidChange(const document::GlobalId &gid, SerialNum serialNum) -{ - _gidToLidChangeHandler->notifyRemove(gid, serialNum); -} - -void -SearchableFeedView::notifyRemoveDoneGidToLidChange(const document::GlobalId &gid, SerialNum serialNum) -{ - _gidToLidChangeHandler->notifyRemoveDone(gid, serialNum); -} - } // namespace proton 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 4b536d0adde..81d81a6cc27 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h @@ -8,8 +8,6 @@ namespace proton { -class IGidToLidChangeHandler; - /** * The feed view used by the searchable sub database. * @@ -25,17 +23,14 @@ public: struct Context { const IIndexWriter::SP &_indexWriter; - const std::shared_ptr<IGidToLidChangeHandler> &_gidToLidChangeHandler; - Context(const IIndexWriter::SP &indexWriter, - const std::shared_ptr<IGidToLidChangeHandler> &gidToLidChangeHandler); + Context(const IIndexWriter::SP &indexWriter); ~Context(); }; private: const IIndexWriter::SP _indexWriter; const bool _hasIndexedFields; - const std::shared_ptr<IGidToLidChangeHandler> _gidToLidChangeHandler; bool hasIndexedFields() const { return _hasIndexedFields; } @@ -86,17 +81,12 @@ private: void performIndexForceCommit(SerialNum serialNum, OnForceCommitDoneType onCommitDone); void forceCommit(SerialNum serialNum, OnForceCommitDoneType onCommitDone) override; - virtual void notifyPutGidToLidChange(const document::GlobalId &gid, uint32_t lid, SerialNum serialNum) override; - virtual void notifyRemoveGidToLidChange(const document::GlobalId &gid, SerialNum serialNum) override; - virtual void notifyRemoveDoneGidToLidChange(const document::GlobalId &gid, SerialNum serialNum) override; - public: SearchableFeedView(const StoreOnlyFeedView::Context &storeOnlyCtx, const PersistentParams ¶ms, const FastAccessFeedView::Context &fastUpdateCtx, Context ctx); virtual ~SearchableFeedView(); const IIndexWriter::SP &getIndexWriter() const { return _indexWriter; } - const std::shared_ptr<IGidToLidChangeHandler> &getGidToLidChangeHandler() const { return _gidToLidChangeHandler; } void sync() override; }; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp index e9e0120dac1..f88fb07ab29 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp @@ -49,8 +49,10 @@ SearchableDocSubDB::SearchableDocSubDB(const Config &cfg, const Context &ctx) getSubDbName(), ctx._fastUpdCtx._storeOnlyCtx._owner.getDistributionKey()), _numSearcherThreads(cfg._numSearcherThreads), _warmupExecutor(ctx._warmupExecutor), - _gidToLidChangeHandler(std::make_shared<GidToLidChangeHandler>()) -{ } + _realGidToLidChangeHandler(std::make_shared<GidToLidChangeHandler>()) +{ + _gidToLidChangeHandler = _realGidToLidChangeHandler; +} SearchableDocSubDB::~SearchableDocSubDB() { @@ -244,7 +246,7 @@ SearchableDocSubDB::initFeedView(const IAttributeWriter::SP &attrWriter, SearchableFeedView::UP feedView(new SearchableFeedView(getStoreOnlyFeedViewContext(configSnapshot), getFeedViewPersistentParams(), FastAccessFeedView::Context(attrWriter, _docIdLimit), - SearchableFeedView::Context(getIndexWriter(), _gidToLidChangeHandler))); + SearchableFeedView::Context(getIndexWriter()))); // XXX: Not exception safe. _rFeedView.set(SearchableFeedView::SP(feedView.release())); @@ -351,7 +353,7 @@ SearchableDocSubDB::updateLidReuseDelayer(const LidReuseDelayerConfig &config) void SearchableDocSubDB::close() { - _gidToLidChangeHandler->close(); + _realGidToLidChangeHandler->close(); Parent::close(); } diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h index fa3ded56c97..91ce868937b 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h @@ -83,7 +83,7 @@ private: SearchableDocSubDBConfigurer _configurer; const size_t _numSearcherThreads; vespalib::ThreadExecutor &_warmupExecutor; - std::shared_ptr<GidToLidChangeHandler> _gidToLidChangeHandler; + std::shared_ptr<GidToLidChangeHandler> _realGidToLidChangeHandler; // Note: lifetime of indexManager must be handled by caller. std::shared_ptr<initializer::InitializerTask> diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp index b3f98b2a8ac..5fbae951536 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp @@ -19,6 +19,7 @@ #include <vespa/searchcore/proton/index/index_writer.h> #include <vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h> #include <vespa/searchcore/proton/metrics/metricswireservice.h> +#include <vespa/searchcore/proton/reference/dummy_gid_to_lid_change_handler.h> #include <vespa/searchlib/attribute/configconverter.h> #include <vespa/searchlib/docstore/document_store_visitor_progress.h> #include <vespa/searchlib/util/fileheadertk.h> @@ -135,7 +136,8 @@ StoreOnlyDocSubDB::StoreOnlyDocSubDB(const Config &cfg, const Context &ctx) _subDbType(cfg._subDbType), _fileHeaderContext(*this, ctx._fileHeaderContext, _docTypeName, _baseDir), _lidReuseDelayer(), - _commitTimeTracker(TimeStamp::Seconds(3600.0)) + _commitTimeTracker(TimeStamp::Seconds(3600.0)), + _gidToLidChangeHandler(std::make_shared<DummyGidToLidChangeHandler>()) { vespalib::mkdir(_baseDir, false); // Assume parent is created. } @@ -387,6 +389,7 @@ StoreOnlyDocSubDB::getStoreOnlyFeedViewContext(const DocumentDBConfig &configSna return StoreOnlyFeedView::Context(getSummaryAdapter(), configSnapshot.getSchemaSP(), _metaStoreCtx, + *_gidToLidChangeHandler, configSnapshot.getDocumentTypeRepoSP(), _writeService, *_lidReuseDelayer, _commitTimeTracker); diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h index b9e23e2436c..ed540053de3 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h @@ -176,6 +176,7 @@ protected: StoreOnlySubDBFileHeaderContext _fileHeaderContext; std::unique_ptr<documentmetastore::ILidReuseDelayer> _lidReuseDelayer; CommitTimeTracker _commitTimeTracker; + std::shared_ptr<IGidToLidChangeHandler> _gidToLidChangeHandler; std::shared_ptr<initializer::InitializerTask> createSummaryManagerInitializer(const ProtonConfig::Summary protonSummaryCfg, diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp index 3e7e3d6ddfa..62e01db28e0 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.cpp @@ -12,6 +12,7 @@ #include <vespa/searchcore/proton/common/feedtoken.h> #include <vespa/searchcore/proton/documentmetastore/ilidreusedelayer.h> #include <vespa/searchcore/proton/metrics/feed_metrics.h> +#include <vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h> #include <vespa/searchlib/common/scheduletaskcallback.h> #include <vespa/vespalib/util/exceptions.h> @@ -202,7 +203,8 @@ StoreOnlyFeedView::StoreOnlyFeedView(const Context &ctx, const PersistentParams _schema(ctx._schema), _writeService(ctx._writeService), _params(params), - _metaStore(_documentMetaStoreContext->get()) + _metaStore(_documentMetaStoreContext->get()), + _gidToLidChangeHandler(ctx._gidToLidChangeHandler) { _docType = _repo->getDocumentType(_params._docTypeName.getName()); } @@ -611,17 +613,17 @@ StoreOnlyFeedView::adjustMetaStore(const DocumentOperation &op, const DocumentId op.getLid() != op.getPrevLid()) { moveMetaData(_metaStore, docId, op); - notifyPutGidToLidChange(docId.getGlobalId(), op.getLid(), serialNum); + _gidToLidChangeHandler.notifyPut(docId.getGlobalId(), op.getLid(), serialNum); } else { putMetaData(_metaStore, docId, op, _params._subDbType == SubDbType::REMOVED); if (op.getDbDocumentId() != op.getPrevDbDocumentId()) { - notifyPutGidToLidChange(docId.getGlobalId(), op.getLid(), serialNum); + _gidToLidChangeHandler.notifyPut(docId.getGlobalId(), op.getLid(), serialNum); } } } else if (op.getValidPrevDbdId(_params._subDbId)) { removeMetaData(_metaStore, docId, op, _params._subDbType == SubDbType::REMOVED); - notifyRemoveGidToLidChange(docId.getGlobalId(), serialNum); - notifyRemoveDoneGidToLidChange(docId.getGlobalId(), serialNum); + _gidToLidChangeHandler.notifyRemove(docId.getGlobalId(), serialNum); + _gidToLidChangeHandler.notifyRemoveDone(docId.getGlobalId(), serialNum); } _metaStore.commit(serialNum, serialNum); } @@ -652,8 +654,8 @@ StoreOnlyFeedView::removeDocuments(const RemoveDocumentsOperation &op, bool remo std::vector<document::GlobalId> gidsToRemove(getGidsToRemove(_metaStore, lidsToRemove)); _metaStore.removeBatch(lidsToRemove, ctx->getDocIdLimit()); for (const auto &gid : gidsToRemove) { - notifyRemoveGidToLidChange(gid, serialNum); - notifyRemoveDoneGidToLidChange(gid, serialNum); + _gidToLidChangeHandler.notifyRemove(gid, serialNum); + _gidToLidChangeHandler.notifyRemoveDone(gid, serialNum); } _metaStore.commit(serialNum, serialNum); explicitReuseLids = _lidReuseDelayer.delayReuse(lidsToRemove); @@ -807,13 +809,4 @@ StoreOnlyFeedView::getDocumentMetaStorePtr() const return &_documentMetaStoreContext->get(); } -void -StoreOnlyFeedView::notifyPutGidToLidChange(const document::GlobalId &, uint32_t, SerialNum) {} - -void -StoreOnlyFeedView::notifyRemoveGidToLidChange(const document::GlobalId &, SerialNum) {} - -void -StoreOnlyFeedView::notifyRemoveDoneGidToLidChange(const document::GlobalId &, SerialNum) {} - } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h index ec3003fb5d6..1302ef7b632 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlyfeedview.h @@ -31,6 +31,7 @@ class OperationDoneContext; class PutDoneContext; class RemoveDoneContext; class CommitTimeTracker; +class IGidToLidChangeHandler; namespace documentmetastore { class ILidReuseDelayer; } @@ -68,6 +69,7 @@ public: const ISummaryAdapter::SP &_summaryAdapter; const search::index::Schema::SP &_schema; const IDocumentMetaStoreContext::SP &_documentMetaStoreContext; + IGidToLidChangeHandler &_gidToLidChangeHandler; const document::DocumentTypeRepo::SP &_repo; searchcorespi::index::IThreadingService &_writeService; documentmetastore::ILidReuseDelayer &_lidReuseDelayer; @@ -76,6 +78,7 @@ public: Context(const ISummaryAdapter::SP &summaryAdapter, const search::index::Schema::SP &schema, const IDocumentMetaStoreContext::SP &documentMetaStoreContext, + IGidToLidChangeHandler &gidToLidChangeHandler, const document::DocumentTypeRepo::SP &repo, searchcorespi::index::IThreadingService &writeService, documentmetastore::ILidReuseDelayer &lidReuseDelayer, @@ -83,6 +86,7 @@ public: : _summaryAdapter(summaryAdapter), _schema(schema), _documentMetaStoreContext(documentMetaStoreContext), + _gidToLidChangeHandler(gidToLidChangeHandler), _repo(repo), _writeService(writeService), _lidReuseDelayer(lidReuseDelayer), @@ -143,6 +147,7 @@ protected: searchcorespi::index::IThreadingService &_writeService; PersistentParams _params; IDocumentMetaStore &_metaStore; + IGidToLidChangeHandler &_gidToLidChangeHandler; private: searchcorespi::index::IThreadService & summaryExecutor() { @@ -165,7 +170,7 @@ private: void internalPut(FeedTokenUP token, const PutOperation &putOp); void internalUpdate(FeedTokenUP token, const UpdateOperation &updOp); - bool lookupDocId(const document::DocumentId &gid, Lid & lid) const; + bool lookupDocId(const document::DocumentId &docId, Lid & lid) const; void internalRemove(FeedTokenUP token, const RemoveOperation &rmOp); // Removes documents from meta store and document store. @@ -179,10 +184,6 @@ private: // Ack token early if visibility delay is nonzero void considerEarlyAck(FeedTokenUP &token, FeedOperation::Type opType); - virtual void notifyPutGidToLidChange(const document::GlobalId &gid, uint32_t lid, SerialNum serialNum); - virtual void notifyRemoveGidToLidChange(const document::GlobalId &gid, SerialNum serialNum); - virtual void notifyRemoveDoneGidToLidChange(const document::GlobalId &gid, SerialNum serialNum); - void makeUpdatedDocument(SerialNum serialNum, Lid lid, DocumentUpdate::SP upd, OnOperationDoneType onWriteDone,PromisedDoc promisedDoc, PromisedStream promisedStream); @@ -229,6 +230,7 @@ public: searchcorespi::index::IThreadingService &getWriteService() { return _writeService; } documentmetastore::ILidReuseDelayer &getLidReuseDelayer() { return _lidReuseDelayer; } CommitTimeTracker &getCommitTimeTracker() { return _commitTimeTracker; } + IGidToLidChangeHandler &getGidToLidChangeHandler() const { return _gidToLidChangeHandler; } /** * Implements IFeedView. diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.cpp b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.cpp index 270f4d51788..036f482b2e8 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.cpp @@ -147,47 +147,5 @@ long ImportedAttributeVector::onSerializeForDescendingSort(DocId doc, _reference_attribute->getReferencedLid(doc), serTo, available, bc); } -namespace { - -class ImportedAttributeGuard : public AttributeGuard { -public: - ImportedAttributeGuard(const AttributeVectorSP& target_attr, - const AttributeVectorSP& reference_attr) - : AttributeGuard(), - _target_attr_guard(target_attr), - _reference_attr_guard(reference_attr) - { - } - -private: - AttributeGuard _target_attr_guard; - AttributeGuard _reference_attr_guard; -}; - -class ImportedAttributeEnumGuard : public AttributeEnumGuard { -public: - ImportedAttributeEnumGuard(const AttributeVectorSP& target_attr, - const AttributeVectorSP& reference_attr) - : AttributeEnumGuard(AttributeVectorSP()), - _target_attr_enum_guard(target_attr), - _reference_attr_guard(reference_attr) - { - } - -private: - AttributeEnumGuard _target_attr_enum_guard; - AttributeGuard _reference_attr_guard; -}; - -} - -std::unique_ptr<AttributeGuard> ImportedAttributeVector::acquireGuard() const { - return std::make_unique<ImportedAttributeGuard>(_target_attribute, _reference_attribute); -} - -std::unique_ptr<AttributeEnumGuard> ImportedAttributeVector::acquireEnumGuard() const { - return std::make_unique<ImportedAttributeEnumGuard>(_target_attribute, _reference_attribute); -} - } } diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h index 686818c1093..bddd0fa9093 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h +++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector.h @@ -66,21 +66,6 @@ public: return _target_attribute; } - /** - * Acquire an opaque composite guard that covers both the target attribute and - * the reference attribute. Note that these are not directly accessible via the - * returned guard object itself; it does not expose a valid pointer (i.e. get() will - * return nullptr). - */ - std::unique_ptr<AttributeGuard> acquireGuard() const; - /** - * Acquires a composite guard similar to acquireGuard(), but the target attribute is - * covered by an AttributeEnumGuard instead of a regular AttributeGuard. - * - * The reference attribute is _not_ covered by an enum guard. - */ - std::unique_ptr<AttributeEnumGuard> acquireEnumGuard() const; - /* * Create an imported attribute with a snapshot of lid to lid mapping. */ |