From 80e5f0a300d251573dfa774f4e594899e324baef Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 3 Dec 2018 21:39:31 +0100 Subject: - Decouple index config from ProtonConfig. - Decouple grow config from Protonconfig. No semantic changes, just refactoring. --- .../documentdb/configurer/configurer_test.cpp | 19 +++--- .../document_subdbs/document_subdbs_test.cpp | 12 ++-- .../src/tests/proton/index/fusionrunner_test.cpp | 1 + .../src/tests/proton/index/indexmanager_test.cpp | 22 +++---- .../attribute_collection_spec_factory.cpp | 7 +- .../searchcore/proton/bucketdb/bucketdbhandler.cpp | 19 ++---- .../searchcore/proton/bucketdb/bucketdbhandler.h | 33 +++------- .../searchcore/proton/bucketdb/ibucketdbhandler.h | 37 +++-------- .../proton/bucketdb/ibucketdbhandlerinitializer.h | 21 ++---- .../proton/index/index_manager_initializer.cpp | 27 ++------ .../proton/index/index_manager_initializer.h | 13 ++-- .../vespa/searchcore/proton/index/indexmanager.cpp | 53 +++++---------- .../vespa/searchcore/proton/index/indexmanager.h | 73 +++++++++++---------- .../vespa/searchcore/proton/server/configstore.h | 12 ++-- .../vespa/searchcore/proton/server/documentdb.cpp | 39 ++++++++--- .../vespa/searchcore/proton/server/documentdb.h | 17 +++-- .../proton/server/documentsubdbcollection.cpp | 75 ++++++++-------------- .../proton/server/documentsubdbcollection.h | 27 ++++++-- .../proton/server/fast_access_doc_subdb.cpp | 24 +++---- .../proton/server/fast_access_doc_subdb.h | 2 +- .../searchcore/proton/server/idocumentsubdb.h | 12 ++-- .../proton/server/searchabledocsubdb.cpp | 45 +++++-------- .../searchcore/proton/server/searchabledocsubdb.h | 9 +-- .../searchcore/proton/server/storeonlydocsubdb.cpp | 15 ++--- .../searchcore/proton/server/storeonlydocsubdb.h | 4 +- .../proton/server/threading_service_config.cpp | 8 +-- .../proton/server/threading_service_config.h | 4 +- .../searchcore/proton/test/dummy_document_sub_db.h | 3 +- 28 files changed, 263 insertions(+), 370 deletions(-) (limited to 'searchcore') diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index 15ab8f90ac9..87853bb414d 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -181,31 +181,32 @@ Fixture::Fixture() _configurer.reset(new Configurer(_views._summaryMgr, _views.searchView, _views.feedView, _queryLimiter, _constantValueRepo, _clock, "test", 0)); } -Fixture::~Fixture() {} +Fixture::~Fixture() = default; void Fixture::initViewSet(ViewSet &views) { - Matchers::SP matchers(new Matchers(_clock, _queryLimiter, _constantValueRepo)); - auto indexMgr = make_shared(BASE_DIR, searchcorespi::index::WarmupConfig(), 2, 0, Schema(), 1, + using IndexManager = proton::index::IndexManager; + using IndexConfig = proton::index::IndexConfig; + auto matchers = std::make_shared(_clock, _queryLimiter, _constantValueRepo); + auto indexMgr = make_shared(BASE_DIR, IndexConfig(searchcorespi::index::WarmupConfig(), 2, 0), Schema(), 1, views._reconfigurer, views._writeService, _summaryExecutor, TuneFileIndexManager(), TuneFileAttributes(), views._fileHeaderContext); auto attrMgr = make_shared(BASE_DIR, "test.subdb", TuneFileAttributes(), views._fileHeaderContext, views._writeService.attributeFieldWriter(),views._hwInfo); - ProtonConfig protonCfg; auto summaryMgr = make_shared (_summaryExecutor, search::LogDocumentStore::Config(), GrowStrategy(), BASE_DIR, views._docTypeName, TuneFileSummary(), views._fileHeaderContext,views._noTlSyncer, search::IBucketizer::SP()); - auto sesMgr = make_shared(protonCfg.grouping.sessionmanager.maxentries); + auto sesMgr = make_shared(100); auto metaStore = make_shared(make_shared()); - IIndexWriter::SP indexWriter(new IndexWriter(indexMgr)); - AttributeWriter::SP attrWriter(new AttributeWriter(attrMgr)); - ISummaryAdapter::SP summaryAdapter(new SummaryAdapter(summaryMgr)); + auto indexWriter = std::make_shared(indexMgr); + auto attrWriter = std::make_shared(attrMgr); + auto summaryAdapter = std::make_shared(summaryMgr); views._gidToLidChangeHandler = make_shared(); Schema::SP schema(new Schema()); views._summaryMgr = summaryMgr; views._dmsc = metaStore; - views._lidReuseDelayer.reset(new documentmetastore::LidReuseDelayer(views._writeService, metaStore->get())); + views._lidReuseDelayer = std::make_unique(views._writeService, metaStore->get()); IndexSearchable::SP indexSearchable; MatchView::SP matchView(new MatchView(matchers, indexSearchable, attrMgr, sesMgr, metaStore, views._docIdLimit)); views.searchView.set(make_shared diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp index 760f7457d33..45c9ae71bc9 100644 --- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp +++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp @@ -58,6 +58,7 @@ using storage::spi::Timestamp; using vespa::config::search::core::ProtonConfig; using vespa::config::content::core::BucketspacesConfig; using vespalib::mkdir; +using proton::index::IndexConfig; typedef StoreOnlyDocSubDB::Config StoreOnlyConfig; typedef StoreOnlyDocSubDB::Context StoreOnlyContext; @@ -75,8 +76,7 @@ const SerialNum CFG_SERIAL = 5; struct ConfigDir1 { static vespalib::string dir() { return TEST_PATH("cfg1"); } }; struct ConfigDir2 { static vespalib::string dir() { return TEST_PATH("cfg2"); } }; struct ConfigDir3 { static vespalib::string dir() { return TEST_PATH("cfg3"); } }; -struct ConfigDir4 { static vespalib::string dir() { return TEST_PATH("cfg4") - ; } }; +struct ConfigDir4 { static vespalib::string dir() { return TEST_PATH("cfg4"); } }; struct MySubDBOwner : public IDocumentSubDBOwner { @@ -166,7 +166,7 @@ MyStoreOnlyContext::MyStoreOnlyContext(IThreadingService &writeService, ThreadSt bucketDBHandlerInitializer, _metrics, _configMutex, _hwInfo) { } -MyStoreOnlyContext::~MyStoreOnlyContext() {} +MyStoreOnlyContext::~MyStoreOnlyContext() = default; template struct MyFastAccessConfig @@ -208,7 +208,7 @@ MyFastAccessContext::MyFastAccessContext(IThreadingService &writeService, Thread _wireService(), _ctx(_storeOnlyCtx._ctx, _attributeMetricsCollection, NULL, _wireService) {} -MyFastAccessContext::~MyFastAccessContext() {} +MyFastAccessContext::~MyFastAccessContext() = default; struct MySearchableConfig { @@ -335,9 +335,7 @@ struct FixtureBase } void init() { DocumentSubDbInitializer::SP task = - _subDb.createInitializer(*_snapshot->_cfg, - Traits::configSerial(), - ProtonConfig::Index()); + _subDb.createInitializer(*_snapshot->_cfg, Traits::configSerial(), IndexConfig()); vespalib::ThreadStackExecutor executor(1, 1024 * 1024); initializer::TaskRunner taskRunner(executor); taskRunner.runTask(task); diff --git a/searchcore/src/tests/proton/index/fusionrunner_test.cpp b/searchcore/src/tests/proton/index/fusionrunner_test.cpp index 429452df2ec..650b263ff75 100644 --- a/searchcore/src/tests/proton/index/fusionrunner_test.cpp +++ b/searchcore/src/tests/proton/index/fusionrunner_test.cpp @@ -19,6 +19,7 @@ using document::Document; using document::FieldValue; using proton::ExecutorThreadingService; +using proton::index::IndexManager; using search::FixedSourceSelector; using search::TuneFileAttributes; using search::TuneFileIndexManager; diff --git a/searchcore/src/tests/proton/index/indexmanager_test.cpp b/searchcore/src/tests/proton/index/indexmanager_test.cpp index d88199e6ae8..c025bd257a2 100644 --- a/searchcore/src/tests/proton/index/indexmanager_test.cpp +++ b/searchcore/src/tests/proton/index/indexmanager_test.cpp @@ -50,6 +50,8 @@ using std::set; using std::string; using vespalib::BlockingThreadStackExecutor; using vespalib::ThreadStackExecutor; +using proton::index::IndexManager; +using proton::index::IndexConfig; using namespace proton; using namespace searchcorespi; @@ -170,27 +172,21 @@ Document::UP Fixture::addDocument(uint32_t id) { } void Fixture::resetIndexManager() { - _index_manager.reset(0); - _index_manager.reset( - new IndexManager(index_dir, searchcorespi::index::WarmupConfig(), 2, 0, getSchema(), 1, + _index_manager.reset(); + _index_manager = std::make_unique(index_dir, IndexConfig(), getSchema(), 1, _reconfigurer, _writeService, _writeService.getMasterExecutor(), - TuneFileIndexManager(), TuneFileAttributes(), - _fileHeaderContext)); + TuneFileIndexManager(), TuneFileAttributes(),_fileHeaderContext); } -void Fixture::assertStats(uint32_t expNumDiskIndexes, - uint32_t expNumMemoryIndexes, - SerialNum expLastDiskIndexSerialNum, - SerialNum expLastMemoryIndexSerialNum) +void Fixture::assertStats(uint32_t expNumDiskIndexes, uint32_t expNumMemoryIndexes, + SerialNum expLastDiskIndexSerialNum, SerialNum expLastMemoryIndexSerialNum) { searchcorespi::IndexManagerStats stats(*_index_manager); SerialNum lastDiskIndexSerialNum = 0; SerialNum lastMemoryIndexSerialNum = 0; - const std::vector & - diskIndexes(stats.getDiskIndexes()); - const std::vector & - memoryIndexes(stats.getMemoryIndexes()); + const std::vector & diskIndexes(stats.getDiskIndexes()); + const std::vector & memoryIndexes(stats.getMemoryIndexes()); if (!diskIndexes.empty()) { lastDiskIndexSerialNum = diskIndexes.back().getSerialNum(); } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.cpp index 2290fa318cc..23701bfdd5d 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec_factory.cpp @@ -27,8 +27,7 @@ AttributeCollectionSpecFactory::create(const AttributesConfig &attrCfg, // Amortize memory spike cost over N docs const size_t skew = _growNumDocs/(attrCfg.attribute.size()+1); GrowStrategy grow = _growStrategy; - grow.setDocsInitialCapacity(std::max(grow.getDocsInitialCapacity(), - docIdLimit)); + grow.setDocsInitialCapacity(std::max(grow.getDocsInitialCapacity(),docIdLimit)); for (const auto &attr : attrCfg.attribute) { search::attribute::Config cfg = ConfigConverter::convert(attr); if (_fastAccessOnly && !cfg.fastAccess()) { @@ -38,9 +37,7 @@ AttributeCollectionSpecFactory::create(const AttributesConfig &attrCfg, cfg.setGrowStrategy(grow); attrs.push_back(AttributeSpec(attr.name, cfg)); } - return AttributeCollectionSpec::UP(new AttributeCollectionSpec(attrs, - docIdLimit, - serialNum)); + return std::make_unique(attrs, docIdLimit, serialNum); } } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.cpp b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.cpp index f8fe7227f03..63f94dd4c71 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.cpp +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.cpp @@ -15,22 +15,17 @@ BucketDBHandler::BucketDBHandler(BucketDBOwner &bucketDB) { } -BucketDBHandler::~BucketDBHandler() -{ -} +BucketDBHandler::~BucketDBHandler() = default; void -BucketDBHandler::addDocumentMetaStore(IDocumentMetaStore *dms, - search::SerialNum flushedSerialNum) +BucketDBHandler::addDocumentMetaStore(IDocumentMetaStore *dms, search::SerialNum flushedSerialNum) { _dmsv.push_back(MetaStoreDesc(dms, flushedSerialNum)); } void -BucketDBHandler::handleSplit(search::SerialNum serialNum, - const BucketId &source, - const BucketId &target1, - const BucketId &target2) +BucketDBHandler::handleSplit(search::SerialNum serialNum, const BucketId &source, + const BucketId &target1, const BucketId &target2) { // Called by writer thread assert(source.valid()); @@ -63,10 +58,8 @@ BucketDBHandler::handleSplit(search::SerialNum serialNum, void -BucketDBHandler::handleJoin(search::SerialNum serialNum, - const BucketId &source1, - const BucketId &source2, - const BucketId &target) +BucketDBHandler::handleJoin(search::SerialNum serialNum, const BucketId &source1, + const BucketId &source2, const BucketId &target) { // Called by writer thread JoinBucketsSession session(_bucketDB, _bucketCreateNotifier, source1, source2, target); diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.h b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.h index 6ab6b8d8e36..1d1e304224d 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.h +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.h @@ -35,33 +35,16 @@ private: public: BucketDBHandler(BucketDBOwner &bucketDB); - ~BucketDBHandler(); - void - setBucketDB(BucketDBOwner &bucketDB); - - virtual void - addDocumentMetaStore(IDocumentMetaStore *dms, - search::SerialNum flushedSerialNum) override; - - virtual void - handleSplit(search::SerialNum serialNum, - const BucketId &source, - const BucketId &target1, - const BucketId &target2) override; - - virtual void - handleJoin(search::SerialNum serialNum, - const BucketId &source1, - const BucketId &source2, - const BucketId &target) override; - - virtual void - handleCreateBucket(const BucketId &bucketId) override; - - virtual void - handleDeleteBucket(const BucketId &bucketId) override; + void setBucketDB(BucketDBOwner &bucketDB); + void addDocumentMetaStore(IDocumentMetaStore *dms, search::SerialNum flushedSerialNum) override; + void handleSplit(search::SerialNum serialNum, const BucketId &source, + const BucketId &target1, const BucketId &target2) override; + void handleJoin(search::SerialNum serialNum, const BucketId &source1, + const BucketId &source2, const BucketId &target) override; + void handleCreateBucket(const BucketId &bucketId) override; + void handleDeleteBucket(const BucketId &bucketId) override; IBucketCreateNotifier &getBucketCreateNotifier() { return _bucketCreateNotifier; } }; diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/ibucketdbhandler.h b/searchcore/src/vespa/searchcore/proton/bucketdb/ibucketdbhandler.h index 5f6e69d538d..7d979b8069c 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/ibucketdbhandler.h +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/ibucketdbhandler.h @@ -5,13 +5,9 @@ #include #include -namespace proton -{ - -class IDocumentMetaStore; +namespace proton { class IDocumentMetaStore; } -namespace bucketdb -{ +namespace proton::bucketdb { /** * The IBucketDBHandler class handles operations on a bucket db. @@ -21,31 +17,18 @@ class IBucketDBHandler public: typedef document::BucketId BucketId; - IBucketDBHandler() - { - } + IBucketDBHandler() { } - virtual ~IBucketDBHandler() - { - } + virtual ~IBucketDBHandler() { } - virtual void - handleSplit(search::SerialNum serialNum, - const BucketId &source, const BucketId &target1, - const BucketId &target2) = 0; + virtual void handleSplit(search::SerialNum serialNum, const BucketId &source, + const BucketId &target1, const BucketId &target2) = 0; - virtual void - handleJoin(search::SerialNum serialNum, - const BucketId &source1, const BucketId &source2, - const BucketId &target) = 0; + virtual void handleJoin(search::SerialNum serialNum, const BucketId &source1, + const BucketId &source2, const BucketId &target) = 0; - virtual void - handleCreateBucket(const BucketId &bucketId) = 0; - - virtual void - handleDeleteBucket(const BucketId &bucketId) = 0; + virtual void handleCreateBucket(const BucketId &bucketId) = 0; + virtual void handleDeleteBucket(const BucketId &bucketId) = 0; }; } - -} diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/ibucketdbhandlerinitializer.h b/searchcore/src/vespa/searchcore/proton/bucketdb/ibucketdbhandlerinitializer.h index b0ef388334f..981f174e9c9 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/ibucketdbhandlerinitializer.h +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/ibucketdbhandlerinitializer.h @@ -2,11 +2,7 @@ #pragma once -namespace proton -{ - -namespace bucketdb -{ +namespace proton::bucketdb { /** * The IBucketDBHandlerInitiaizer class handles initialization of a @@ -15,19 +11,10 @@ namespace bucketdb class IBucketDBHandlerInitializer { public: - IBucketDBHandlerInitializer() - { - } + IBucketDBHandlerInitializer() { } + virtual ~IBucketDBHandlerInitializer() {} - virtual ~IBucketDBHandlerInitializer() - { - } - - virtual void - addDocumentMetaStore(IDocumentMetaStore *dms, - search::SerialNum flushedSerialNum) = 0; + virtual void addDocumentMetaStore(IDocumentMetaStore *dms, search::SerialNum flushedSerialNum) = 0; }; } - -} diff --git a/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.cpp b/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.cpp index ad233a66d1f..9c680ec7768 100644 --- a/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.cpp @@ -10,9 +10,7 @@ namespace proton { IndexManagerInitializer:: IndexManagerInitializer(const vespalib::string &baseDir, - const searchcorespi::index::WarmupConfig & warmupCfg, - size_t maxFlushed, - size_t cacheSize, + const index::IndexConfig & indexCfg, const search::index::Schema &schema, search::SerialNum serialNum, searchcorespi::IIndexManager::Reconfigurer & reconfigurer, @@ -23,9 +21,7 @@ IndexManagerInitializer(const vespalib::string &baseDir, const search::common::FileHeaderContext & fileHeaderContext, std::shared_ptr indexManager) : _baseDir(baseDir), - _warmupCfg(warmupCfg), - _maxFlushed(maxFlushed), - _cacheSize(cacheSize), + _indexConfig(indexCfg), _schema(schema), _serialNum(serialNum), _reconfigurer(reconfigurer), @@ -42,23 +38,12 @@ IndexManagerInitializer(const vespalib::string &baseDir, void IndexManagerInitializer::run() { - LOG(debug, "About to create proton::IndexManager with %u index field(s)", - _schema.getNumIndexFields()); + LOG(debug, "About to create proton::IndexManager with %u index field(s)", _schema.getNumIndexFields()); vespalib::mkdir(_baseDir, false); vespalib::File::sync(vespalib::dirname(_baseDir)); - *_indexManager = std::make_shared - (_baseDir, - _warmupCfg, - _maxFlushed, - _cacheSize, - _schema, - _serialNum, - _reconfigurer, - _threadingService, - _warmupExecutor, - _tuneFileIndexManager, - _tuneFileAttributes, - _fileHeaderContext); + *_indexManager = std::make_shared + (_baseDir, _indexConfig, _schema, _serialNum, _reconfigurer, _threadingService, + _warmupExecutor, _tuneFileIndexManager, _tuneFileAttributes, _fileHeaderContext); } diff --git a/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.h b/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.h index 84ad030585a..1a14c8d2ea3 100644 --- a/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.h +++ b/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.h @@ -5,8 +5,7 @@ #include "indexmanager.h" #include -namespace proton -{ +namespace proton { /* @@ -16,9 +15,7 @@ namespace proton class IndexManagerInitializer : public initializer::InitializerTask { const vespalib::string _baseDir; - const searchcorespi::index::WarmupConfig _warmupCfg; - size_t _maxFlushed; - size_t _cacheSize; + const index::IndexConfig _indexConfig; const search::index::Schema _schema; search::SerialNum _serialNum; searchcorespi::IIndexManager::Reconfigurer &_reconfigurer; @@ -31,9 +28,7 @@ class IndexManagerInitializer : public initializer::InitializerTask public: // Note: lifetime of indexManager must be handled by caller. IndexManagerInitializer(const vespalib::string &baseDir, - const searchcorespi::index::WarmupConfig & warmupCfg, - size_t maxFlushed, - size_t cacheSize, + const index::IndexConfig & indexCfg, const search::index::Schema &schema, search::SerialNum serialNum, searchcorespi::IIndexManager::Reconfigurer & reconfigurer, @@ -43,7 +38,7 @@ public: const search::TuneFileAttributes & tuneFileAttributes, const search::common::FileHeaderContext & fileHeaderContext, std::shared_ptr indexManager); - virtual void run() override; + void run() override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/index/indexmanager.cpp b/searchcore/src/vespa/searchcore/proton/index/indexmanager.cpp index 96127907191..82e32b0c26b 100644 --- a/searchcore/src/vespa/searchcore/proton/index/indexmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/index/indexmanager.cpp @@ -22,14 +22,12 @@ using searchcorespi::index::IndexMaintainerContext; using searchcorespi::index::IMemoryIndex; using searchcorespi::index::IThreadingService; -namespace proton { +namespace proton::index { IndexManager::MaintainerOperations::MaintainerOperations(const FileHeaderContext &fileHeaderContext, const TuneFileIndexManager &tuneFileIndexManager, size_t cacheSize, - searchcorespi::index:: - IThreadingService & - threadingService) + IThreadingService &threadingService) : _cacheSize(cacheSize), _fileHeaderContext(fileHeaderContext), _tuneFileIndexing(tuneFileIndexManager._indexing), @@ -39,27 +37,23 @@ IndexManager::MaintainerOperations::MaintainerOperations(const FileHeaderContext } IMemoryIndex::SP -IndexManager::MaintainerOperations::createMemoryIndex(const Schema &schema, - SerialNum serialNum) +IndexManager::MaintainerOperations::createMemoryIndex(const Schema &schema, SerialNum serialNum) { - return IMemoryIndex::SP(new MemoryIndexWrapper(schema, - _fileHeaderContext, - _tuneFileIndexing, - _threadingService, - serialNum)); + return std::make_shared(schema, _fileHeaderContext, _tuneFileIndexing, + _threadingService, serialNum); } IDiskIndex::SP IndexManager::MaintainerOperations::loadDiskIndex(const vespalib::string &indexDir) { - return IDiskIndex::SP(new DiskIndexWrapper(indexDir, _tuneFileSearch, _cacheSize)); + return std::make_shared(indexDir, _tuneFileSearch, _cacheSize); } IDiskIndex::SP IndexManager::MaintainerOperations::reloadDiskIndex(const IDiskIndex &oldIndex) { - return IDiskIndex::SP(new DiskIndexWrapper(dynamic_cast(oldIndex), - _tuneFileSearch, _cacheSize)); + return std::make_shared(dynamic_cast(oldIndex), + _tuneFileSearch, _cacheSize); } bool @@ -69,19 +63,15 @@ IndexManager::MaintainerOperations::runFusion(const Schema &schema, const SelectorArray &selectorArray, SerialNum serialNum) { - SerialNumFileHeaderContext fileHeaderContext(_fileHeaderContext, - serialNum); + SerialNumFileHeaderContext fileHeaderContext(_fileHeaderContext, serialNum); const bool dynamic_k_doc_pos_occ_format = false; - return Fusion::merge(schema, outputDir, sources, selectorArray, - dynamic_k_doc_pos_occ_format, + return Fusion::merge(schema, outputDir, sources, selectorArray, dynamic_k_doc_pos_occ_format, _tuneFileIndexing, fileHeaderContext); } IndexManager::IndexManager(const vespalib::string &baseDir, - const WarmupConfig & warmup, - const size_t maxFlushed, - const size_t cacheSize, + const IndexConfig & indexConfig, const Schema &schema, SerialNum serialNum, Reconfigurer &reconfigurer, @@ -89,26 +79,15 @@ IndexManager::IndexManager(const vespalib::string &baseDir, vespalib::ThreadExecutor & warmupExecutor, const search::TuneFileIndexManager &tuneFileIndexManager, const search::TuneFileAttributes &tuneFileAttributes, - const search::common::FileHeaderContext &fileHeaderContext) : - _operations(fileHeaderContext, tuneFileIndexManager, cacheSize, - threadingService), - _maintainer(IndexMaintainerConfig(baseDir, - warmup, - maxFlushed, - schema, - serialNum, - tuneFileAttributes), - IndexMaintainerContext(threadingService, - reconfigurer, - fileHeaderContext, - warmupExecutor), + const FileHeaderContext &fileHeaderContext) : + _operations(fileHeaderContext, tuneFileIndexManager, indexConfig.cacheSize, threadingService), + _maintainer(IndexMaintainerConfig(baseDir, indexConfig.warmup, indexConfig.maxFlushed, schema, serialNum, tuneFileAttributes), + IndexMaintainerContext(threadingService, reconfigurer, fileHeaderContext, warmupExecutor), _operations) { } -IndexManager::~IndexManager() -{ -} +IndexManager::~IndexManager() = default; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/index/indexmanager.h b/searchcore/src/vespa/searchcore/proton/index/indexmanager.h index 1607c19611a..15872583135 100644 --- a/searchcore/src/vespa/searchcore/proton/index/indexmanager.h +++ b/searchcore/src/vespa/searchcore/proton/index/indexmanager.h @@ -5,8 +5,23 @@ #include #include #include - -namespace proton { +#include + +namespace proton::index { + +struct IndexConfig { + using WarmupConfig = searchcorespi::index::WarmupConfig; + IndexConfig() : IndexConfig(WarmupConfig(), 2, 0) { } + IndexConfig(WarmupConfig warmup_, size_t maxFlushed_, size_t cacheSize_) + : warmup(warmup_), + maxFlushed(maxFlushed_), + cacheSize(cacheSize_) + { } + + const WarmupConfig warmup; + const size_t maxFlushed; + const size_t cacheSize; +}; /** * The IndexManager provides a holistic view of a set of disk and @@ -19,6 +34,8 @@ class IndexManager : public searchcorespi::IIndexManager public: class MaintainerOperations : public searchcorespi::index::IIndexMaintainerOperations { private: + using IDiskIndex = searchcorespi::index::IDiskIndex; + using IMemoryIndex = searchcorespi::index::IMemoryIndex; const size_t _cacheSize; const search::common::FileHeaderContext &_fileHeaderContext; const search::TuneFileIndexing _tuneFileIndexing; @@ -29,21 +46,15 @@ public: MaintainerOperations(const search::common::FileHeaderContext &fileHeaderContext, const search::TuneFileIndexManager &tuneFileIndexManager, size_t cacheSize, - searchcorespi::index::IThreadingService & - threadingService); - - virtual searchcorespi::index::IMemoryIndex::SP - createMemoryIndex(const search::index::Schema &schema, - SerialNum serialNum) override; - virtual searchcorespi::index::IDiskIndex::SP - loadDiskIndex(const vespalib::string &indexDir) override; - virtual searchcorespi::index::IDiskIndex::SP - reloadDiskIndex(const searchcorespi::index::IDiskIndex &oldIndex) override; - virtual bool runFusion(const search::index::Schema &schema, - const vespalib::string &outputDir, - const std::vector &sources, - const search::diskindex::SelectorArray &docIdSelector, - search::SerialNum lastSerialNum) override; + searchcorespi::index::IThreadingService &threadingService); + + IMemoryIndex::SP createMemoryIndex(const Schema &schema, SerialNum serialNum) override; + IDiskIndex::SP loadDiskIndex(const vespalib::string &indexDir) override; + IDiskIndex::SP reloadDiskIndex(const IDiskIndex &oldIndex) override; + bool runFusion(const Schema &schema, const vespalib::string &outputDir, + const std::vector &sources, + const SelectorArray &docIdSelector, + search::SerialNum lastSerialNum) override; }; private: @@ -54,9 +65,7 @@ public: IndexManager(const IndexManager &) = delete; IndexManager & operator = (const IndexManager &) = delete; IndexManager(const vespalib::string &baseDir, - const searchcorespi::index::WarmupConfig & warmup, - size_t maxFlushed, - size_t cacheSize, + const IndexConfig & indexConfig, const Schema &schema, SerialNum serialNum, Reconfigurer &reconfigurer, @@ -74,48 +83,46 @@ public: /** * Implements searchcorespi::IIndexManager **/ - virtual void putDocument(uint32_t lid, const Document &doc, - SerialNum serialNum) override { + void putDocument(uint32_t lid, const Document &doc, SerialNum serialNum) override { _maintainer.putDocument(lid, doc, serialNum); } - virtual void removeDocument(uint32_t lid, SerialNum serialNum) override { + void removeDocument(uint32_t lid, SerialNum serialNum) override { _maintainer.removeDocument(lid, serialNum); } - virtual void commit(SerialNum serialNum, - OnWriteDoneType onWriteDone) override { + void commit(SerialNum serialNum, OnWriteDoneType onWriteDone) override { _maintainer.commit(serialNum, onWriteDone); } - virtual void heartBeat(SerialNum serialNum) override { + void heartBeat(SerialNum serialNum) override { _maintainer.heartBeat(serialNum); } - virtual SerialNum getCurrentSerialNum() const override { + SerialNum getCurrentSerialNum() const override { return _maintainer.getCurrentSerialNum(); } - virtual SerialNum getFlushedSerialNum() const override { + SerialNum getFlushedSerialNum() const override { return _maintainer.getFlushedSerialNum(); } - virtual searchcorespi::IndexSearchable::SP getSearchable() const override { + searchcorespi::IndexSearchable::SP getSearchable() const override { return _maintainer.getSearchable(); } - virtual search::SearchableStats getSearchableStats() const override { + search::SearchableStats getSearchableStats() const override { return _maintainer.getSearchableStats(); } - virtual searchcorespi::IFlushTarget::List getFlushTargets() override { + searchcorespi::IFlushTarget::List getFlushTargets() override { return _maintainer.getFlushTargets(); } - virtual void setSchema(const Schema &schema, SerialNum serialNum) override { + void setSchema(const Schema &schema, SerialNum serialNum) override { _maintainer.setSchema(schema, serialNum); } - virtual void setMaxFlushed(uint32_t maxFlushed) override { + void setMaxFlushed(uint32_t maxFlushed) override { _maintainer.setMaxFlushed(maxFlushed); } }; diff --git a/searchcore/src/vespa/searchcore/proton/server/configstore.h b/searchcore/src/vespa/searchcore/proton/server/configstore.h index e9944719902..1a3ba423b49 100644 --- a/searchcore/src/vespa/searchcore/proton/server/configstore.h +++ b/searchcore/src/vespa/searchcore/proton/server/configstore.h @@ -5,14 +5,16 @@ #include "documentdbconfig.h" #include "feedconfigstore.h" #include -#include +namespace vespa::config::search::core::internal { + class InternalProtonType; +} namespace proton { struct ConfigStore : FeedConfigStore { typedef std::unique_ptr UP; typedef search::SerialNum SerialNum; - using ProtonConfig = vespa::config::search::core::ProtonConfig; + using ProtonConfig = const vespa::config::search::core::internal::InternalProtonType; using ProtonConfigSP = std::shared_ptr; /** @@ -22,11 +24,9 @@ struct ConfigStore : FeedConfigStore { * @param loadedSnapshot the shared pointer in which to store the * resulting config snapshot. */ - virtual void loadConfig(const DocumentDBConfig ¤tSnapshot, - SerialNum serialNum, + virtual void loadConfig(const DocumentDBConfig ¤tSnapshot, SerialNum serialNum, DocumentDBConfig::SP &loadedSnapshot) = 0; - virtual void saveConfig(const DocumentDBConfig &snapshot, - SerialNum serialNum) = 0; + virtual void saveConfig(const DocumentDBConfig &snapshot, SerialNum serialNum) = 0; virtual void removeInvalid() = 0; /** diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 94ff5b43a3a..7b19b7201e2 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -36,6 +36,8 @@ #include #include +#include + LOG_SETUP(".proton.server.documentdb"); using vespa::config::search::AttributesConfig; @@ -53,6 +55,7 @@ using namespace search::fef; using namespace search::index; using namespace search::transactionlog; using searchcorespi::index::IThreadService; +using searchcorespi::index::WarmupConfig; using search::TuneFileDocumentDB; using storage::spi::Timestamp; using search::common::FileHeaderContext; @@ -65,6 +68,28 @@ namespace proton { namespace { constexpr uint32_t indexing_thread_stack_size = 128 * 1024; + +GrowStrategy +makeGrowStrategy(uint32_t docsInitialCapacity, const ProtonConfig::Grow &growCfg) +{ + return GrowStrategy(docsInitialCapacity, growCfg.factor, growCfg.add, growCfg.multivalueallocfactor); +} + +DocumentSubDBCollection::Config +makeSubDBConfig(const ProtonConfig & protonCfg) { + const ProtonConfig::Grow & growCfg = protonCfg.grow; + const ProtonConfig::Distribution & distCfg = protonCfg.distribution; + GrowStrategy searchableGrowth = makeGrowStrategy(growCfg.initial * distCfg.searchablecopies, growCfg); + GrowStrategy removedGrowth = makeGrowStrategy(std::max(1024l, growCfg.initial/100), growCfg); + GrowStrategy notReadyGrowth = makeGrowStrategy(growCfg.initial * (distCfg.redundancy - distCfg.searchablecopies), growCfg); + return DocumentSubDBCollection::Config(searchableGrowth, notReadyGrowth, removedGrowth, growCfg.numdocs, protonCfg.numsearcherthreads); +} + +index::IndexConfig +makeIndexConfig(const ProtonConfig::Index & cfg) { + return index::IndexConfig(WarmupConfig(cfg.warmup.time, cfg.warmup.unpack), cfg.maxflushed, cfg.cache.size); +} + } template @@ -116,7 +141,7 @@ DocumentDB::DocumentDB(const vespalib::string &baseDir, _initGate(), _clusterStateHandler(_writeService.master()), _bucketHandler(_writeService.master()), - _protonIndexCfg(protonCfg.index), + _indexCfg(makeIndexConfig(protonCfg.index)), _config_store(std::move(config_store)), _sessionManager(new matching::SessionManager(protonCfg.grouping.sessionmanager.maxentries)), _metricsWireService(metricsWireService), @@ -131,18 +156,13 @@ DocumentDB::DocumentDB(const vespalib::string &baseDir, _feedHandler(_writeService, tlsSpec, docTypeName, _state, *this, _writeFilter, *this, tlsDirectWriter), _subDBs(*this, *this, _feedHandler, _docTypeName, _writeService, warmupExecutor, sharedExecutor, fileHeaderContext, metricsWireService, getMetricsCollection(), - queryLimiter, clock, _configMutex, _baseDir, protonCfg, hwInfo), + queryLimiter, clock, _configMutex, _baseDir, makeSubDBConfig(protonCfg), hwInfo), _maintenanceController(_writeService.master(), sharedExecutor, _docTypeName), _visibility(_feedHandler, _writeService, _feedView), _lidSpaceCompactionHandlers(), _jobTrackers(), _calc(), - _metricsUpdater(_subDBs, - _writeService, - _jobTrackers, - *_sessionManager, - _writeFilter, - _state) + _metricsUpdater(_subDBs, _writeService, _jobTrackers, *_sessionManager, _writeFilter, _state) { assert(configSnapshot); @@ -250,8 +270,7 @@ DocumentDB::initManagers() // Called by executor thread DocumentDBConfig::SP configSnapshot(_initConfigSnapshot); _initConfigSnapshot.reset(); - InitializerTask::SP rootTask = - _subDBs.createInitializer(*configSnapshot, _initConfigSerialNum, _protonIndexCfg); + InitializerTask::SP rootTask = _subDBs.createInitializer(*configSnapshot, _initConfigSerialNum, _indexCfg); InitializeThreads initializeThreads = _initializeThreads; _initializeThreads.reset(); std::shared_ptr taskRunner(std::make_shared(*initializeThreads)); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h index fb23b113f3b..f9b4e5ad1f6 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,8 @@ namespace search { namespace transactionlog { class TransLogClient; } } +namespace vespa::config::search::core::internal { class InternalProtonType; } + namespace proton { class IDocumentDBOwner; class MetricsWireService; @@ -85,7 +88,7 @@ private: using InitializeThreads = std::shared_ptr; using IFlushTargetList = std::vector>; using StatusReportUP = std::unique_ptr; - using ProtonConfig = vespa::config::search::core::ProtonConfig; + using ProtonConfig = const vespa::config::search::core::internal::InternalProtonType; DocTypeName _docTypeName; document::BucketSpace _bucketSpace; @@ -117,7 +120,7 @@ private: ClusterStateHandler _clusterStateHandler; BucketHandler _bucketHandler; - ProtonConfig::Index _protonIndexCfg; + index::IndexConfig _indexCfg; ConfigStore::UP _config_store; std::shared_ptr _sessionManager; // TODO: This should not have to be a shared pointer. MetricsWireService &_metricsWireService; @@ -188,13 +191,13 @@ private: /** * Implements IFeedHandlerOwner */ - virtual void onTransactionLogReplayDone() override __attribute__((noinline)); - virtual void onPerformPrune(SerialNum flushedSerial) override; + void onTransactionLogReplayDone() override __attribute__((noinline)); + void onPerformPrune(SerialNum flushedSerial) override; /** * Implements IFeedHandlerOwner **/ - virtual bool getAllowPrune() const override; + bool getAllowPrune() const override; void startTransactionLogReplay(); @@ -202,7 +205,7 @@ private: /** * Implements IClusterStateChangedHandler */ - virtual void notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc) override; + void notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc) override; void notifyAllBucketsChanged(); /* @@ -265,7 +268,7 @@ public: * Frees any allocated resources. This will also stop the internal thread * and wait for it to finish. All pending tasks are deleted. */ - ~DocumentDB(); + ~DocumentDB() override; /** * Starts initialization of the document db in the init & executor threads, diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp index b67d09480ec..78f49599322 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp @@ -18,17 +18,14 @@ using searchcorespi::IFlushTarget; namespace proton { -namespace { - -GrowStrategy -makeGrowStrategy(uint32_t docsInitialCapacity, - const DocumentSubDBCollection::ProtonConfig::Grow &growCfg) -{ - return GrowStrategy(docsInitialCapacity, growCfg.factor, - growCfg.add, growCfg.multivalueallocfactor); -} - -} +DocumentSubDBCollection::Config::Config(GrowStrategy ready, GrowStrategy notReady, GrowStrategy removed, + size_t fixedAttributeTotalSkew, size_t numSearchThreads) + : _readyGrowth(ready), + _notReadyGrowth(notReady), + _removedGrowth(removed), + _fixedAttributeTotalSkew(fixedAttributeTotalSkew), + _numSearchThreads(numSearchThreads) +{ } DocumentSubDBCollection::DocumentSubDBCollection( IDocumentSubDBOwner &owner, @@ -45,7 +42,7 @@ DocumentSubDBCollection::DocumentSubDBCollection( const vespalib::Clock &clock, std::mutex &configMutex, const vespalib::string &baseDir, - const ProtonConfig &protonCfg, + const Config & cfg, const HwInfo &hwInfo) : _subDBs(), _owner(owner), @@ -58,41 +55,25 @@ DocumentSubDBCollection::DocumentSubDBCollection( _bucketDB(), _bucketDBHandler() { - const ProtonConfig::Grow & growCfg = protonCfg.grow; - const ProtonConfig::Distribution & distCfg = protonCfg.distribution; _bucketDB = std::make_shared(); - _bucketDBHandler.reset(new bucketdb::BucketDBHandler(*_bucketDB)); - GrowStrategy searchableGrowth = makeGrowStrategy(growCfg.initial * distCfg.searchablecopies, growCfg); - GrowStrategy removedGrowth = makeGrowStrategy(std::max(1024l, growCfg.initial/100), growCfg); - GrowStrategy notReadyGrowth = makeGrowStrategy(growCfg.initial * (distCfg.redundancy - distCfg.searchablecopies), growCfg); - size_t attributeGrowNumDocs(growCfg.numdocs); - size_t numSearcherThreads = protonCfg.numsearcherthreads; - - StoreOnlyDocSubDB::Context context(owner, - tlSyncer, - getSerialNum, - fileHeaderContext, - writeService, - sharedExecutor, - _bucketDB, - *_bucketDBHandler, - metrics, - configMutex, - hwInfo); + _bucketDBHandler = std::make_unique(*_bucketDB); + + StoreOnlyDocSubDB::Context context(owner, tlSyncer, getSerialNum, fileHeaderContext, writeService, + sharedExecutor, _bucketDB, *_bucketDBHandler, metrics, configMutex, hwInfo); _subDBs.push_back (new SearchableDocSubDB (SearchableDocSubDB::Config(FastAccessDocSubDB::Config (StoreOnlyDocSubDB::Config(docTypeName, "0.ready", baseDir, - searchableGrowth, - attributeGrowNumDocs, + cfg.getReadyGrowth(), + cfg.getFixedAttributeTotalSkew(), _readySubDbId, SubDbType::READY), true, true, false), - numSearcherThreads), + cfg.getNumSearchThreads()), SearchableDocSubDB::Context(FastAccessDocSubDB::Context (context, AttributeMetricsCollection(metrics.getTaggedMetrics().ready.attributes, @@ -106,8 +87,8 @@ DocumentSubDBCollection::DocumentSubDBCollection( (new StoreOnlyDocSubDB(StoreOnlyDocSubDB::Config(docTypeName, "1.removed", baseDir, - removedGrowth, - attributeGrowNumDocs, + cfg.getRemovedGrowth(), + cfg.getFixedAttributeTotalSkew(), _remSubDbId, SubDbType::REMOVED), context)); @@ -116,8 +97,8 @@ DocumentSubDBCollection::DocumentSubDBCollection( (StoreOnlyDocSubDB::Config(docTypeName, "2.notready", baseDir, - notReadyGrowth, - attributeGrowNumDocs, + cfg.getNotReadyGrowth(), + cfg.getFixedAttributeTotalSkew(), _notReadySubDbId, SubDbType::NOTREADY), true, @@ -126,7 +107,7 @@ DocumentSubDBCollection::DocumentSubDBCollection( FastAccessDocSubDB::Context(context, AttributeMetricsCollection(metrics.getTaggedMetrics().notReady.attributes, metrics.getLegacyMetrics().notReady.attributes), - NULL, + nullptr, metricsWireService))); } @@ -153,8 +134,7 @@ DocumentSubDBCollection::createRetrievers() namespace { IDocumentRetriever::SP -wrapRetriever(const IDocumentRetriever::SP &retriever, - ICommitable &commit) +wrapRetriever(const IDocumentRetriever::SP &retriever, ICommitable &commit) { return std::make_shared(retriever, commit); } @@ -162,8 +142,7 @@ wrapRetriever(const IDocumentRetriever::SP &retriever, } -void DocumentSubDBCollection::maintenanceSync(MaintenanceController &mc, - ICommitable &commit) { +void DocumentSubDBCollection::maintenanceSync(MaintenanceController &mc, ICommitable &commit) { RetrieversSP retrievers = getRetrievers(); MaintenanceDocumentSubDB readySubDB( getReadySubDB()->getDocumentMetaStoreContext().getSP(), @@ -183,7 +162,7 @@ void DocumentSubDBCollection::maintenanceSync(MaintenanceController &mc, initializer::InitializerTask::SP DocumentSubDBCollection::createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, - const ProtonConfig::Index & indexCfg) + const index::IndexConfig & indexCfg) { DocumentSubDbCollectionInitializer::SP task = std::make_shared(); for (auto subDb : _subDBs) { @@ -287,11 +266,11 @@ DocumentSubDBCollection::getFeedView() views.push_back(subDb->getFeedView()); } IFeedView::SP newFeedView; - assert(views.size() >= 1); + assert( ! views.empty()); if (views.size() > 1) { - return IFeedView::SP(new CombiningFeedView(views, _owner.getBucketSpace(), _calc)); + return std::make_shared(views, _owner.getBucketSpace(), _calc); } else { - assert(views.front() != NULL); + assert(views.front() != nullptr); return views.front(); } } diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h index ebc418497dc..c4ddd6d0e72 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include @@ -39,7 +39,6 @@ struct IBucketStateCalculator; class IDocumentSubDBOwner; class IDocumentSubDB; class IDocumentRetriever; -class IRreprocessingTask; class ReconfigParams; namespace matching { @@ -49,12 +48,30 @@ namespace matching { namespace initializer { class InitializerTask; } +namespace index { class IndexConfig; } + class DocumentSubDBCollection { public: using SubDBVector = std::vector; using const_iterator = SubDBVector::const_iterator; using SerialNum = search::SerialNum; - using ProtonConfig = vespa::config::search::core::ProtonConfig; + class Config { + public: + using GrowStrategy = search::GrowStrategy; + Config(GrowStrategy ready, GrowStrategy notReady, GrowStrategy removed, + size_t fixedAttributeTotalSkew, size_t numSearchThreads); + GrowStrategy getReadyGrowth() const { return _readyGrowth; } + GrowStrategy getNotReadyGrowth() const { return _notReadyGrowth; } + GrowStrategy getRemovedGrowth() const { return _removedGrowth; } + size_t getNumSearchThreads() const { return _numSearchThreads; } + size_t getFixedAttributeTotalSkew() const { return _fixedAttributeTotalSkew; } + private: + const GrowStrategy _readyGrowth; + const GrowStrategy _notReadyGrowth; + const GrowStrategy _removedGrowth; + const size_t _fixedAttributeTotalSkew; + const size_t _numSearchThreads; + }; private: using IFeedViewSP = std::shared_ptr; @@ -90,7 +107,7 @@ public: const vespalib::Clock &clock, std::mutex &configMutex, const vespalib::string &baseDir, - const vespa::config::search::core::ProtonConfig &protonCfg, + const Config & cfg, const HwInfo &hwInfo); ~DocumentSubDBCollection(); @@ -125,7 +142,7 @@ public: std::shared_ptr createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, - const vespa::config::search::core::ProtonConfig::Index & indexCfg); + const index::IndexConfig & indexCfg); void initViews(const DocumentDBConfig &configSnapshot, const SessionManagerSP &sessionManager); void clearViews(); 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 acb097c16aa..bf83c889f27 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 @@ -103,8 +103,7 @@ FastAccessDocSubDB::setupAttributeManager(AttributeManager::SP attrMgrResult) AttributeCollectionSpec::UP -FastAccessDocSubDB::createAttributeSpec(const AttributesConfig &attrCfg, - SerialNum serialNum) const +FastAccessDocSubDB::createAttributeSpec(const AttributesConfig &attrCfg, SerialNum serialNum) const { uint32_t docIdLimit(_dms->getCommittedDocIdLimit()); AttributeCollectionSpecFactory factory(_attributeGrow, @@ -113,16 +112,15 @@ FastAccessDocSubDB::createAttributeSpec(const AttributesConfig &attrCfg, } void -FastAccessDocSubDB::initFeedView(const IAttributeWriter::SP &writer, - const DocumentDBConfig &configSnapshot) +FastAccessDocSubDB::initFeedView(const IAttributeWriter::SP &writer, const DocumentDBConfig &configSnapshot) { // Called by executor thread - FastAccessFeedView::UP feedView(new FastAccessFeedView( + auto feedView = std::make_shared( getStoreOnlyFeedViewContext(configSnapshot), getFeedViewPersistentParams(), - FastAccessFeedView::Context(writer, _docIdLimit))); + FastAccessFeedView::Context(writer, _docIdLimit)); - _fastAccessFeedView.set(FastAccessFeedView::SP(feedView.release())); + _fastAccessFeedView.set(feedView); _iFeedView.set(_fastAccessFeedView.get()); } @@ -211,11 +209,11 @@ FastAccessDocSubDB::FastAccessDocSubDB(const Config &cfg, const Context &ctx) _docIdLimit(0) { } -FastAccessDocSubDB::~FastAccessDocSubDB() { } +FastAccessDocSubDB::~FastAccessDocSubDB() = default; DocumentSubDbInitializer::UP FastAccessDocSubDB::createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, - const vespa::config::search::core::ProtonConfig::Index &indexCfg) const + const IndexConfig &indexCfg) const { auto result = Parent::createInitializer(configSnapshot, configSerialNum, indexCfg); auto attrMgrInitTask = createAttributeManagerInitializer(configSnapshot, configSerialNum, @@ -299,7 +297,7 @@ FastAccessDocSubDB::getDocumentRetriever() { FastAccessFeedView::SP feedView = _fastAccessFeedView.get(); proton::IAttributeManager::SP attrMgr = extractAttributeManager(feedView); - return IDocumentRetriever::UP(new FastAccessDocumentRetriever(feedView, attrMgr)); + return std::make_unique(feedView, attrMgr); } void @@ -311,8 +309,7 @@ FastAccessDocSubDB::onReplayDone() uint32_t docIdLimit = _metaStoreCtx->get().getCommittedDocIdLimit(); assert(docIdLimit > 0); IFeedView::SP feedView = _iFeedView.get(); - IAttributeWriter::SP attrWriter = - static_cast(*feedView).getAttributeWriter(); + IAttributeWriter::SP attrWriter = static_cast(*feedView).getAttributeWriter(); attrWriter->onReplayDone(docIdLimit); } @@ -321,8 +318,7 @@ void FastAccessDocSubDB::onReprocessDone(SerialNum serialNum) { IFeedView::SP feedView = _iFeedView.get(); - IAttributeWriter::SP attrWriter = - static_cast(*feedView).getAttributeWriter(); + IAttributeWriter::SP attrWriter = static_cast(*feedView).getAttributeWriter(); attrWriter->forceCommit(serialNum, std::shared_ptr()); _writeService.attributeFieldWriter().sync(); _writeService.summary().sync(); diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h index de2d82aed39..7c7ee3fab56 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h @@ -102,7 +102,7 @@ public: std::unique_ptr createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, - const ProtonConfig::Index &indexCfg) const override; + const IndexConfig &indexCfg) const override; void setup(const DocumentSubDbInitializerResult &initResult) override; void initViews(const DocumentDBConfig &configSnapshot, const SessionManagerSP &sessionManager) override; diff --git a/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h b/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h index 736edcf3c5e..15ea112b7a3 100644 --- a/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h @@ -1,11 +1,11 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include #include #include #include #include +#include namespace search::index { class Schema; } @@ -15,6 +15,10 @@ namespace searchcorespi { class IFlushTarget; class IIndexManager; } +namespace proton::index { + class IndexConfig; +} + namespace proton { namespace matching { class SessionManager; } @@ -23,10 +27,8 @@ class DocumentDBConfig; class DocumentSubDbInitializer; class DocumentSubDbInitializerResult; class FeedHandler; -class FileConfigManager; class IAttributeManager; class IBucketStateCalculator; -class IDcoumentRetriever; class IDocumentDBReferenceResolver; class IDocumentDBReference; class IDocumentMetaStoreContext; @@ -54,8 +56,8 @@ public: using SerialNum = search::SerialNum; using Schema = search::index::Schema; using SchemaSP = std::shared_ptr; - using ProtonConfig = vespa::config::search::core::ProtonConfig; using IFlushTargetList = std::vector>; + using IndexConfig = index::IndexConfig; public: IDocumentSubDB() { } virtual ~IDocumentSubDB() { } @@ -64,7 +66,7 @@ public: virtual std::unique_ptr createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, - const ProtonConfig::Index &indexCfg) const = 0; + const IndexConfig &indexCfg) const = 0; // Called by master thread virtual void setup(const DocumentSubDbInitializerResult &initResult) = 0; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp index bb2242d5596..91394e429a4 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp @@ -19,9 +19,7 @@ #include #include -using vespa::config::search::AttributesConfig; using vespa::config::search::RankProfilesConfig; -using vespa::config::search::core::ProtonConfig; using proton::matching::MatchingStats; using proton::matching::SessionManager; using search::AttributeGuard; @@ -90,41 +88,29 @@ SearchableDocSubDB::getNewestFlushedSerial() initializer::InitializerTask::SP SearchableDocSubDB:: -createIndexManagerInitializer(const DocumentDBConfig &configSnapshot, - SerialNum configSerialNum, - const ProtonConfig::Index &indexCfg, +createIndexManagerInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, + const IndexConfig &indexCfg, std::shared_ptr indexManager) const { Schema::SP schema(configSnapshot.getSchemaSP()); vespalib::string vespaIndexDir(_baseDir + "/index"); // Note: const_cast for reconfigurer role return std::make_shared - (vespaIndexDir, - searchcorespi::index::WarmupConfig(indexCfg.warmup.time, indexCfg.warmup.unpack), - indexCfg.maxflushed, - indexCfg.cache.size, - *schema, - configSerialNum, - const_cast(*this), - _writeService, - _warmupExecutor, - configSnapshot.getTuneFileDocumentDBSP()->_index, - configSnapshot.getTuneFileDocumentDBSP()->_attr, - _fileHeaderContext, - indexManager); + (vespaIndexDir, indexCfg, *schema, configSerialNum, const_cast(*this), + _writeService, _warmupExecutor, configSnapshot.getTuneFileDocumentDBSP()->_index, + configSnapshot.getTuneFileDocumentDBSP()->_attr, _fileHeaderContext, indexManager); } void SearchableDocSubDB::setupIndexManager(searchcorespi::IIndexManager::SP indexManager) { _indexMgr = indexManager; - _indexWriter.reset(new IndexWriter(_indexMgr)); + _indexWriter = std::make_shared(_indexMgr); } DocumentSubDbInitializer::UP SearchableDocSubDB:: -createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, - const ProtonConfig::Index &indexCfg) const +createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, const IndexConfig &indexCfg) const { auto result = Parent::createInitializer(configSnapshot, configSerialNum, indexCfg); auto indexTask = createIndexManagerInitializer(configSnapshot, configSerialNum, indexCfg, @@ -220,19 +206,18 @@ SearchableDocSubDB::initViews(const DocumentDBConfig &configSnapshot, const Sess const IIndexManager::SP &indexMgr = getIndexManager(); _constantValueRepo.reconfigure(configSnapshot.getRankingConstants()); Matchers::SP matchers(_configurer.createMatchers(schema, configSnapshot.getRankProfilesConfig()).release()); - MatchView::SP matchView(new MatchView(matchers, indexMgr->getSearchable(), attrMgr, - sessionManager, _metaStoreCtx, _docIdLimit)); - _rSearchView.set(SearchView::SP( - new SearchView( + auto matchView = std::make_shared(matchers, indexMgr->getSearchable(), attrMgr, + sessionManager, _metaStoreCtx, _docIdLimit); + _rSearchView.set(std::make_shared( getSummaryManager()->createSummarySetup( configSnapshot.getSummaryConfig(), configSnapshot.getSummarymapConfig(), configSnapshot.getJuniperrcConfig(), configSnapshot.getDocumentTypeRepoSP(), matchView->getAttributeManager()), - matchView))); + matchView)); - IAttributeWriter::SP attrWriter(new AttributeWriter(attrMgr)); + auto attrWriter = std::make_shared(attrMgr); { std::lock_guard guard(_configMutex); initFeedView(attrWriter, configSnapshot); @@ -247,13 +232,13 @@ SearchableDocSubDB::initFeedView(const IAttributeWriter::SP &attrWriter, const DocumentDBConfig &configSnapshot) { assert(_writeService.master().isCurrentThread()); - SearchableFeedView::UP feedView(new SearchableFeedView(getStoreOnlyFeedViewContext(configSnapshot), + auto feedView = std::make_shared(getStoreOnlyFeedViewContext(configSnapshot), getFeedViewPersistentParams(), FastAccessFeedView::Context(attrWriter, _docIdLimit), - SearchableFeedView::Context(getIndexWriter()))); + SearchableFeedView::Context(getIndexWriter())); // XXX: Not exception safe. - _rFeedView.set(SearchableFeedView::SP(feedView.release())); + _rFeedView.set(feedView); syncViews(); } diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h index 0852e028c25..b43b697112e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h @@ -10,7 +10,6 @@ #include "summaryadapter.h" #include #include -#include #include #include #include @@ -25,7 +24,6 @@ namespace proton { class DocumentDBConfig; -class DocumentDBMetrics; class IDocumentDBReferenceResolver; class MetricsWireService; class GidToLidChangeHandler; @@ -90,9 +88,8 @@ private: // Note: lifetime of indexManager must be handled by caller. std::shared_ptr - createIndexManagerInitializer(const DocumentDBConfig &configSnapshot, - SerialNum configSerialNum, - const vespa::config::search::core::ProtonConfig::Index &indexCfg, + createIndexManagerInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, + const IndexConfig &indexCfg, std::shared_ptr indexManager) const; void setupIndexManager(searchcorespi::IIndexManager::SP indexManager); @@ -116,7 +113,7 @@ public: std::unique_ptr createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, - const vespa::config::search::core::ProtonConfig::Index &indexCfg) const override; + const IndexConfig &indexCfg) const override; void setup(const DocumentSubDbInitializerResult &initResult) override; void initViews(const DocumentDBConfig &configSnapshot, const SessionManagerSP &sessionManager) override; diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp index 02afaddd830..b222aab1397 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp @@ -30,8 +30,6 @@ #include LOG_SETUP(".proton.server.storeonlydocsubdb"); -using vespa::config::search::AttributesConfig; -using vespa::config::search::core::ProtonConfig; using search::GrowStrategy; using search::AttributeGuard; using search::AttributeVector; @@ -46,8 +44,6 @@ using proton::matching::MatchingStats; using proton::matching::SessionManager; using vespalib::GenericHeader; using search::common::FileHeaderContext; -using vespalib::makeTask; -using vespalib::makeClosure; using proton::documentmetastore::LidReuseDelayer; using fastos::TimeStamp; using proton::initializer::InitializerTask; @@ -79,7 +75,7 @@ StoreOnlyDocSubDB::Config::~Config() = default; StoreOnlyDocSubDB::Context::Context(IDocumentSubDBOwner &owner, search::transactionlog::SyncProxy &tlSyncer, const IGetSerialNum &getSerialNum, - const search::common::FileHeaderContext &fileHeaderContext, + const FileHeaderContext &fileHeaderContext, searchcorespi::index::IThreadingService &writeService, vespalib::ThreadStackExecutorBase &sharedExecutor, std::shared_ptr bucketDB, @@ -299,11 +295,8 @@ StoreOnlyDocSubDB::setupDocumentMetaStore(DocumentMetaStoreInitializerResult::SP } DocumentSubDbInitializer::UP -StoreOnlyDocSubDB::createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, - const ProtonConfig::Index &indexCfg) const +StoreOnlyDocSubDB::createInitializer(const DocumentDBConfig &configSnapshot, SerialNum , const IndexConfig &) const { - (void) configSerialNum; - (void) indexCfg; auto result = std::make_unique(const_cast(*this), _writeService.master()); auto dmsInitTask = createDocumentMetaStoreInitializer(configSnapshot.getTuneFileDocumentDBSP()->_attr, @@ -513,10 +506,10 @@ StoreOnlyDocSubDB::getDocumentDBReference() StoreOnlySubDBFileHeaderContext:: StoreOnlySubDBFileHeaderContext(StoreOnlyDocSubDB &owner, - const search::common::FileHeaderContext & parentFileHeaderContext, + const FileHeaderContext & parentFileHeaderContext, const DocTypeName &docTypeName, const vespalib::string &baseDir) - : search::common::FileHeaderContext(), + : FileHeaderContext(), _owner(owner), _parentFileHeaderContext(parentFileHeaderContext), _docTypeName(docTypeName), diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h index a54525377a9..db9cbf7415a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h @@ -207,7 +207,7 @@ public: std::unique_ptr createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, - const ProtonConfig::Index &indexCfg) const override; + const IndexConfig & indexCfg) const override; void setup(const DocumentSubDbInitializerResult &initResult) override; void initViews(const DocumentDBConfig &configSnapshot, const std::shared_ptr &sessionManager) override; @@ -215,7 +215,7 @@ public: IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, const ReconfigParams ¶ms, IDocumentDBReferenceResolver &resolver) override; - virtual void setBucketStateCalculator(const std::shared_ptr &calc) override; + void setBucketStateCalculator(const std::shared_ptr &calc) override; ISearchHandler::SP getSearchView() const override { return _iSearchView.get(); } IFeedView::SP getFeedView() const override { return _iFeedView.get(); } diff --git a/searchcore/src/vespa/searchcore/proton/server/threading_service_config.cpp b/searchcore/src/vespa/searchcore/proton/server/threading_service_config.cpp index 6422df9cbd2..cd1608feadb 100644 --- a/searchcore/src/vespa/searchcore/proton/server/threading_service_config.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/threading_service_config.cpp @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "threading_service_config.h" -#include +#include #include namespace proton { @@ -20,8 +20,7 @@ ThreadingServiceConfig::ThreadingServiceConfig(uint32_t indexingThreads_, namespace { uint32_t -calculateIndexingThreads(const ProtonConfig &cfg, - const HwInfo::Cpu &cpuInfo) +calculateIndexingThreads(const ProtonConfig &cfg, const HwInfo::Cpu &cpuInfo) { double scaledCores = cpuInfo.cores() * cfg.feeding.concurrency; uint32_t indexingThreads = std::max((uint32_t)std::ceil(scaledCores / 3), (uint32_t)cfg.indexing.threads); @@ -31,8 +30,7 @@ calculateIndexingThreads(const ProtonConfig &cfg, } ThreadingServiceConfig -ThreadingServiceConfig::make(const ProtonConfig &cfg, - const HwInfo::Cpu &cpuInfo) +ThreadingServiceConfig::make(const ProtonConfig &cfg, const HwInfo::Cpu &cpuInfo) { uint32_t indexingThreads = calculateIndexingThreads(cfg, cpuInfo); return ThreadingServiceConfig(indexingThreads, diff --git a/searchcore/src/vespa/searchcore/proton/server/threading_service_config.h b/searchcore/src/vespa/searchcore/proton/server/threading_service_config.h index 67ab4171e80..03c0c4d1842 100644 --- a/searchcore/src/vespa/searchcore/proton/server/threading_service_config.h +++ b/searchcore/src/vespa/searchcore/proton/server/threading_service_config.h @@ -1,10 +1,10 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include #include #include +namespace vespa::config::search::core::internal { class InternalProtonType; } namespace proton { /** @@ -12,7 +12,7 @@ namespace proton { */ class ThreadingServiceConfig { public: - using ProtonConfig = vespa::config::search::core::ProtonConfig; + using ProtonConfig = const vespa::config::search::core::internal::InternalProtonType; private: uint32_t _indexingThreads; diff --git a/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h b/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h index c2595a85fb7..69e784a8215 100644 --- a/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h +++ b/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h @@ -43,8 +43,7 @@ struct DummyDocumentSubDb : public IDocumentSubDB uint32_t getSubDbId() const override { return _subDbId; } vespalib::string getName() const override { return "dummysubdb"; } DocumentSubDbInitializer::UP - createInitializer(const DocumentDBConfig &, SerialNum, - const vespa::config::search::core::ProtonConfig::Index &) const override { + createInitializer(const DocumentDBConfig &, SerialNum,const index::IndexConfig &) const override { return std::make_unique (const_cast(*this), _writeService->master()); } -- cgit v1.2.3 From 2d98e2c25166a344350f94c07ee7ef97fe0b6601 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Tue, 4 Dec 2018 00:27:46 +0100 Subject: NULL -> nullptr and use bool operator on smart pointers. --- .../vespa/searchcore/proton/server/documentdb.cpp | 39 ++++++++++------------ 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'searchcore') diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 7b19b7201e2..0f6f4fdda11 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -129,7 +129,7 @@ DocumentDB::DocumentDB(const vespalib::string &baseDir, _writeService(_writeServiceConfig.indexingThreads(), indexing_thread_stack_size, _writeServiceConfig.defaultTaskLimit()), - _initializeThreads(initializeThreads), + _initializeThreads(std::move(initializeThreads)), _initConfigSnapshot(), _initConfigSerialNum(0u), _pendingConfigSnapshot(configSnapshot), @@ -189,8 +189,7 @@ DocumentDB::DocumentDB(const vespalib::string &baseDir, // Forward changes of cluster state to bucket handler _clusterStateHandler.addClusterStateChangedHandler(&_bucketHandler); for (auto subDb : _subDBs) { - _lidSpaceCompactionHandlers.push_back(ILidSpaceCompactionHandler::UP - (new LidSpaceCompactionHandler(*subDb, _docTypeName.getName()))); + _lidSpaceCompactionHandlers.push_back(std::make_unique(*subDb, _docTypeName.getName())); } _writeFilter.setConfig(loaded_config->getMaintenanceConfigSP()->getAttributeUsageFilterConfig()); fastos::TimeStamp visibilityDelay = loaded_config->getMaintenanceConfigSP()->getVisibilityDelay(); @@ -252,10 +251,9 @@ public: _taskRunner(std::move(taskRunner)), _configSnapshot(std::move(configSnapshot)), _self(self) - { - } + {} - ~InitDoneTask(); + ~InitDoneTask() override; void run() override { _self.initFinish(std::move(_configSnapshot)); @@ -288,7 +286,7 @@ DocumentDB::initFinish(DocumentDBConfig::SP configSnapshot) _syncFeedViewEnabled = true; syncFeedView(); // Check that feed view has been activated. - assert(_feedView.get().get() != NULL); + assert(_feedView.get()); setActiveConfig(configSnapshot, _initConfigSerialNum, configSnapshot->getGeneration()); startTransactionLogReplay(); } @@ -554,7 +552,7 @@ DocumentDB::close() AttributeMetricsCollection ready(metrics.ready.attributes, legacyMetrics.ready.attributes); AttributeMetricsCollection notReady(metrics.notReady.attributes, legacyMetrics.notReady.attributes); _metricsWireService.cleanAttributes(ready, &legacyMetrics.attributes); - _metricsWireService.cleanAttributes(notReady, NULL); + _metricsWireService.cleanAttributes(notReady, nullptr); _writeService.sync(); masterExecute([this] () { closeSubDBs(); } ); _writeService.sync(); @@ -712,8 +710,7 @@ DocumentDB::startTransactionLogReplay() BucketGuard::UP DocumentDB::lockBucket(const document::BucketId &bucket) { - BucketGuard::UP guard(std::make_unique(bucket, _maintenanceController)); - return std::move(guard); + return std::make_unique(bucket, _maintenanceController); } std::shared_ptr > @@ -725,7 +722,7 @@ DocumentDB::getDocumentRetrievers(IDocumentRetriever::ReadConsistency consistenc std::shared_ptr > wrappedList = std::make_shared>(); wrappedList->reserve(list->size()); for (const IDocumentRetriever::SP & retriever : *list) { - wrappedList->emplace_back(new CommitAndWaitDocumentRetriever(retriever, _visibility)); + wrappedList->push_back(std::make_shared(retriever, _visibility)); } return wrappedList; } else { @@ -868,10 +865,9 @@ DocumentDB::replayConfig(search::SerialNum serialNum) { // Called by executor thread during transaction log replay. DocumentDBConfig::SP configSnapshot = getActiveConfig(); - if (configSnapshot.get() == NULL) { - LOG(warning, - "DocumentDB(%s): Missing old config when replaying config, serialNum=%" PRIu64, - _docTypeName.toString().c_str(), serialNum); + if ( ! configSnapshot) { + LOG(warning, "DocumentDB(%s): Missing old config when replaying config, serialNum=%" PRIu64, + _docTypeName.toString().c_str(), serialNum); return; } // Load config to replay @@ -881,9 +877,8 @@ DocumentDB::replayConfig(search::SerialNum serialNum) // Ignore configs that are not relevant during replay of transaction log configSnapshot = DocumentDBConfig::makeReplayConfig(configSnapshot); applyConfig(configSnapshot, serialNum); - LOG(info, - "DocumentDB(%s): Replayed config with serialNum=%" PRIu64, - _docTypeName.toString().c_str(), serialNum); + LOG(info, "DocumentDB(%s): Replayed config with serialNum=%" PRIu64, + _docTypeName.toString().c_str(), serialNum); } int64_t DocumentDB::getActiveGeneration() const { @@ -956,7 +951,7 @@ DocumentDB::performStartMaintenance() lock_guard guard(_configMutex); if (_state.getClosed()) return; - assert(_activeConfigSnapshot.get() != NULL); + assert(_activeConfigSnapshot); maintenanceConfig = _activeConfigSnapshot->getMaintenanceConfigSP(); } if (_maintenanceController.getStopping()) { @@ -977,7 +972,7 @@ DocumentDB::forwardMaintenanceConfig() { // Called by executor thread DocumentDBConfig::SP activeConfig = getActiveConfig(); - assert(activeConfig.get() != NULL); + assert(activeConfig); DocumentDBMaintenanceConfig::SP maintenanceConfig(activeConfig->getMaintenanceConfigSP()); if (!_state.getClosed()) { @@ -996,10 +991,10 @@ DocumentDB::notifyClusterStateChanged(const IBucketStateCalculator::SP &newCalc) _calc = newCalc; // Save for maintenance job injection // Forward changes of cluster state to feed view IFeedView::SP feedView(_feedView.get()); - if (feedView.get() != NULL) { + if (feedView) { // Try downcast to avoid polluting API CombiningFeedView *cfv = dynamic_cast(feedView.get()); - if (cfv != NULL) + if (cfv != nullptr) cfv->setCalculator(newCalc); } _subDBs.setBucketStateCalculator(newCalc); -- cgit v1.2.3