diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-09-09 20:54:24 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-09-09 20:54:24 +0000 |
commit | 1d3740fda0b4bcbe4d36176aa6188e153d57c3dc (patch) | |
tree | db0d89256fbd81fd6e17eb8062a67f45657056ac | |
parent | efb6c92cfe6e03c15a8cabf8b27962409e8bad46 (diff) |
Unify og getNumActiveDocs and hide some implementations.
27 files changed, 98 insertions, 83 deletions
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 a9a75a1fc7a..45ec3824c11 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 @@ -2,6 +2,7 @@ #include <vespa/searchcore/proton/attribute/imported_attributes_repo.h> #include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchcore/proton/common/hw_info.h> #include <vespa/searchcore/proton/feedoperation/operations.h> #include <vespa/searchcore/proton/initializer/task_runner.h> diff --git a/searchcore/src/tests/proton/documentdb/documentbucketmover/bucketmover_common.cpp b/searchcore/src/tests/proton/documentdb/documentbucketmover/bucketmover_common.cpp index 42e85f2909f..1d8585666b8 100644 --- a/searchcore/src/tests/proton/documentdb/documentbucketmover/bucketmover_common.cpp +++ b/searchcore/src/tests/proton/documentdb/documentbucketmover/bucketmover_common.cpp @@ -2,6 +2,7 @@ #include "bucketmover_common.h" #include <vespa/searchcore/proton/documentmetastore/documentmetastore.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/vespalib/testkit/test_macros.h> using vespalib::IDestructorCallback; @@ -58,8 +59,7 @@ void MySubDb::insertDocs(const UserDocuments &docs_) { for (const auto & entry : docs_) { const auto & bucketDocs = entry.second; - for (size_t i = 0; i < bucketDocs.getDocs().size(); ++i) { - const auto & testDoc = bucketDocs.getDocs()[i]; + for (const auto & testDoc : bucketDocs.getDocs()) { _metaStore.put(testDoc.getGid(), testDoc.getBucket(), testDoc.getTimestamp(), testDoc.getDocSize(), testDoc.getLid(), 0u); _realRetriever->_docs.push_back(testDoc.getDoc()); diff --git a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp index 2db34e45140..84ce40589a3 100644 --- a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp @@ -4,6 +4,7 @@ #include <vespa/searchcore/proton/server/bucketmovejob.h> #include <vespa/searchcore/proton/server/executor_thread_service.h> #include <vespa/searchcore/proton/server/document_db_maintenance_config.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/persistence/dummyimpl/dummy_bucket_executor.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/util/lambdatask.h> diff --git a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentmover_test.cpp b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentmover_test.cpp index 8d0d11295cd..b65beb5d231 100644 --- a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentmover_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentmover_test.cpp @@ -3,6 +3,7 @@ #include "bucketmover_common.h" #include <vespa/searchcore/proton/server/documentbucketmover.h> #include <vespa/searchcore/proton/common/pendinglidtracker.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/vespalib/gtest/gtest.h> #include <vespa/log/log.h> @@ -18,7 +19,7 @@ struct MySubDbTwoBuckets : public MySubDb std::shared_ptr<bucketdb::BucketDBOwner> bucketDB, uint32_t subDbId, SubDbType subDbType) - : MySubDb(builder.getRepo(), bucketDB, subDbId, subDbType) + : MySubDb(builder.getRepo(), std::move(bucketDB), subDbId, subDbType) { builder.createDocs(1, 1, 6); builder.createDocs(2, 6, 9); diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index f9518cb1b5e..e89d5eef078 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -12,6 +12,7 @@ #include <vespa/eval/eval/tensor_spec.h> #include <vespa/eval/eval/value.h> #include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchcore/proton/test/bucketfactory.h> #include <vespa/searchcore/proton/common/feedtoken.h> #include <vespa/searchcore/proton/feedoperation/moveoperation.h> diff --git a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp index f5ac3cd8c13..c62226ad363 100644 --- a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp +++ b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp @@ -4,6 +4,7 @@ #include <vespa/persistence/spi/bucket_limits.h> #include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> #include <vespa/searchcore/proton/bucketdb/checksumaggregators.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchcore/proton/bucketdb/i_bucket_create_listener.h> #include <vespa/searchcore/proton/common/hw_info.h> #include <vespa/searchcore/proton/documentmetastore/documentmetastore.h> diff --git a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp index 07fd4ac6fc3..48ff1dac93a 100644 --- a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp +++ b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp @@ -65,17 +65,17 @@ struct DBConfigFixture { return schema; } - RankingConstants::SP buildRankingConstants() + static RankingConstants::SP buildRankingConstants() { return std::make_shared<RankingConstants>(); } - RankingExpressions::SP buildRankingExpressions() + static RankingExpressions::SP buildRankingExpressions() { return std::make_shared<RankingExpressions>(); } - OnnxModels::SP buildOnnxModels() + static OnnxModels::SP buildOnnxModels() { return std::make_shared<OnnxModels>(); } @@ -96,8 +96,8 @@ struct DBConfigFixture { std::make_shared<AttributesConfig>(_attributesBuilder), std::make_shared<SummaryConfig>(_summaryBuilder), std::make_shared<JuniperrcConfig>(_juniperrcBuilder), - documentTypes, - repo, + std::move(documentTypes), + std::move(repo), std::make_shared<ImportedFieldsConfig>(_importedFieldsBuilder), std::make_shared<TuneFileDocumentDB>(), buildSchema(), @@ -121,7 +121,7 @@ struct ConfigFixture { int64_t _generation; std::shared_ptr<ProtonConfigSnapshot> _cachedConfigSnapshot; - ConfigFixture(const std::string & id) + explicit ConfigFixture(const std::string & id) : _configId(id), _protonBuilder(), _documenttypesBuilder(), @@ -135,7 +135,7 @@ struct ConfigFixture { addDocType("_alwaysthere_", "default"); } - ~ConfigFixture() { } + ~ConfigFixture(); DBConfigFixture *addDocType(const std::string & name, const std::string& bucket_space) { DocumenttypesConfigBuilder::Documenttype dt; @@ -191,13 +191,13 @@ struct ConfigFixture { } BootstrapConfig::SP getBootstrapConfig(int64_t generation) const { - return BootstrapConfig::SP(new BootstrapConfig(generation, - BootstrapConfig::DocumenttypesConfigSP(new DocumenttypesConfig(_documenttypesBuilder)), - std::shared_ptr<const DocumentTypeRepo>(new DocumentTypeRepo(_documenttypesBuilder)), - BootstrapConfig::ProtonConfigSP(new ProtonConfig(_protonBuilder)), - std::make_shared<FiledistributorrpcConfig>(), - std::make_shared<BucketspacesConfig>(_bucketspacesBuilder), - std::make_shared<TuneFileDocumentDB>(), HwInfo())); + return std::make_shared<BootstrapConfig>(generation, + std::make_shared<DocumenttypesConfig>(_documenttypesBuilder), + std::make_shared<DocumentTypeRepo>(_documenttypesBuilder), + std::make_shared<ProtonConfig>(_protonBuilder), + std::make_shared<FiledistributorrpcConfig>(), + std::make_shared<BucketspacesConfig>(_bucketspacesBuilder), + std::make_shared<TuneFileDocumentDB>(), HwInfo()); } std::shared_ptr<ProtonConfigSnapshot> getConfigSnapshot() @@ -226,6 +226,8 @@ struct ConfigFixture { }; +ConfigFixture::~ConfigFixture() = default; + struct MyProtonConfigurerOwner; struct MyDocumentDBConfigOwner : public DocumentDBConfigOwner @@ -242,9 +244,9 @@ struct MyDocumentDBConfigOwner : public DocumentDBConfigOwner _owner(owner) { } - ~MyDocumentDBConfigOwner() { } + ~MyDocumentDBConfigOwner() override; - void reconfigure(const DocumentDBConfig::SP & config) override; + void reconfigure(DocumentDBConfig::SP config) override; document::BucketSpace getBucketSpace() const override { return _bucket_space; } }; @@ -256,13 +258,16 @@ struct MyLog : _log() { } + ~MyLog(); - void appendLog(vespalib::string logEntry) + void appendLog(const vespalib::string & logEntry) { _log.emplace_back(logEntry); } }; +MyLog::~MyLog() = default; + struct MyProtonConfigurerOwner : public IProtonConfigurerOwner, public MyLog { @@ -276,7 +281,7 @@ struct MyProtonConfigurerOwner : public IProtonConfigurerOwner, _dbs() { } - ~MyProtonConfigurerOwner() { } + ~MyProtonConfigurerOwner() override; std::shared_ptr<DocumentDBConfigOwner> addDocumentDB(const DocTypeName &docTypeName, document::BucketSpace bucketSpace, @@ -294,7 +299,7 @@ struct MyProtonConfigurerOwner : public IProtonConfigurerOwner, _dbs.insert(std::make_pair(docTypeName, db)); std::ostringstream os; os << "add db " << docTypeName.getName() << " " << documentDBConfig->getGeneration(); - _log.push_back(os.str()); + _log.emplace_back(os.str()); return db; } void removeDocumentDB(const DocTypeName &docTypeName) override { @@ -302,34 +307,37 @@ struct MyProtonConfigurerOwner : public IProtonConfigurerOwner, _dbs.erase(docTypeName); std::ostringstream os; os << "remove db " << docTypeName.getName(); - _log.push_back(os.str()); + _log.emplace_back(os.str()); } void applyConfig(const std::shared_ptr<BootstrapConfig> &bootstrapConfig) override { std::ostringstream os; os << "apply config " << bootstrapConfig->getGeneration(); - _log.push_back(os.str()); + _log.emplace_back(os.str()); } - void reconfigureDocumentDB(const vespalib::string &name, const DocumentDBConfig::SP &config) + void reconfigureDocumentDB(const vespalib::string &name, const DocumentDBConfig & config) { std::ostringstream os; - os << "reconf db " << name << " " << config->getGeneration(); - _log.push_back(os.str()); + os << "reconf db " << name << " " << config.getGeneration(); + _log.emplace_back(os.str()); } void sync() { _executor.sync(); } }; +MyProtonConfigurerOwner::~MyProtonConfigurerOwner() = default; +MyDocumentDBConfigOwner::~MyDocumentDBConfigOwner() = default; + void -MyDocumentDBConfigOwner::reconfigure(const DocumentDBConfig::SP & config) +MyDocumentDBConfigOwner::reconfigure(DocumentDBConfig::SP config) { - _owner.reconfigureDocumentDB(_name, config); + _owner.reconfigureDocumentDB(_name, *config); } struct MyProtonDiskLayout : public IProtonDiskLayout { MyLog &_log; - MyProtonDiskLayout(MyLog &myLog) + explicit MyProtonDiskLayout(MyLog &myLog) : _log(myLog) { } diff --git a/searchcore/src/tests/proton/server/feedstates_test.cpp b/searchcore/src/tests/proton/server/feedstates_test.cpp index e01d90f5eed..faffb8fe1de 100644 --- a/searchcore/src/tests/proton/server/feedstates_test.cpp +++ b/searchcore/src/tests/proton/server/feedstates_test.cpp @@ -10,13 +10,14 @@ #include <vespa/searchcore/proton/server/memoryconfigstore.h> #include <vespa/searchcore/proton/server/replay_throttling_policy.h> #include <vespa/searchcore/proton/feedoperation/removeoperation.h> +#include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchcore/proton/test/dummy_feed_view.h> #include <vespa/searchlib/common/serialnum.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/util/foreground_thread_executor.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/buffer.h> -#include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> #include <vespa/log/log.h> LOG_SETUP("feedstates_test"); @@ -56,7 +57,7 @@ struct MyReplayConfig : IReplayConfig { struct MyIncSerialNum : IIncSerialNum { SerialNum _serial_num; - MyIncSerialNum(SerialNum serial_num) + explicit MyIncSerialNum(SerialNum serial_num) : _serial_num(serial_num) { } diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.cpp b/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.cpp index 9d28d88ba4a..74c30e5340a 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.cpp +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.cpp @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "bucket_db_explorer.h" - #include <vespa/vespalib/data/slime/cursor.h> #include <vespa/vespalib/stllike/asciistream.h> diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.h b/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.h index 71448e6fad1..922ca9f1ad2 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.h +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_explorer.h @@ -16,7 +16,7 @@ private: bucketdb::Guard _bucketDb; public: - BucketDBExplorer(bucketdb::Guard bucketDb); + explicit BucketDBExplorer(bucketdb::Guard bucketDb); ~BucketDBExplorer() override; void get_state(const vespalib::slime::Inserter &inserter, bool full) const override; diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_owner.h b/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_owner.h index fbdde710277..fbb31967c5a 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_owner.h +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucket_db_owner.h @@ -34,7 +34,7 @@ public: Guard takeGuard() { return Guard(&_bucketDB, _mutex); } - size_t getActiveDocs() const { return _bucketDB.getNumActiveDocs(); } + size_t getNumActiveDocs() const { return _bucketDB.getNumActiveDocs(); } private: BucketDB _bucketDB; std::mutex _mutex; diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h index 286c1e3aa45..2672a98f5a0 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h @@ -39,6 +39,8 @@ private: } public: BucketDB(); + BucketDB(const BucketDB &) = delete; + BucketDB & operator=(const BucketDB &) = delete; ~BucketDB(); const BucketState & add(const GlobalId &gid, @@ -81,8 +83,6 @@ public: // Must be called if buckets state aquired with getBucketStatePtr has been modified. void restoreIntegrity(); bool validateIntegrity() const; - }; } - diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.h b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.h index 2a423eaa213..f4cd23ef712 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.h +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.h @@ -2,13 +2,14 @@ #pragma once -#include "bucket_db_owner.h" #include "ibucketdbhandler.h" #include "ibucketdbhandlerinitializer.h" #include "bucket_create_notifier.h" namespace proton::bucketdb { +class BucketDBOwner; + /** * The BucketDBHandler class handles operations on a bucket db. */ @@ -34,10 +35,9 @@ private: BucketCreateNotifier _bucketCreateNotifier; public: - BucketDBHandler(BucketDBOwner &bucketDB); - ~BucketDBHandler(); + explicit BucketDBHandler(BucketDBOwner &bucketDB); + ~BucketDBHandler() 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; diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp index efc41d2de03..bade54a2adc 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp @@ -19,7 +19,7 @@ DocumentMetaStoreInitializer:: DocumentMetaStoreInitializer(const vespalib::string baseDir, const vespalib::string &subDbName, const vespalib::string &docTypeName, - DocumentMetaStore::SP dms) + std::shared_ptr<DocumentMetaStore> dms) : _baseDir(baseDir), _subDbName(subDbName), _docTypeName(docTypeName), diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.h index 811c3087b3b..fe370489d7e 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.h @@ -2,12 +2,11 @@ #pragma once -#include "documentmetastore.h" -#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchcore/proton/initializer/initializer_task.h> #include <vespa/searchcommon/common/growstrategy.h> #include <vespa/vespalib/stllike/string.h> +namespace proton { class DocumentMetaStore; } namespace proton::documentmetastore { /* @@ -16,10 +15,10 @@ namespace proton::documentmetastore { */ class DocumentMetaStoreInitializer : public initializer::InitializerTask { - vespalib::string _baseDir; - vespalib::string _subDbName; - vespalib::string _docTypeName; - DocumentMetaStore::SP _dms; + vespalib::string _baseDir; + vespalib::string _subDbName; + vespalib::string _docTypeName; + std::shared_ptr<DocumentMetaStore> _dms; public: using SP = std::shared_ptr<DocumentMetaStoreInitializer>; @@ -28,7 +27,7 @@ public: DocumentMetaStoreInitializer(const vespalib::string baseDir, const vespalib::string &subDbName, const vespalib::string &docTypeName, - DocumentMetaStore::SP dms); + std::shared_ptr<DocumentMetaStore> dms); void run() override; }; diff --git a/searchcore/src/vespa/searchcore/proton/server/document_db_config_owner.h b/searchcore/src/vespa/searchcore/proton/server/document_db_config_owner.h index cfdcea24e4c..37741886def 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_db_config_owner.h +++ b/searchcore/src/vespa/searchcore/proton/server/document_db_config_owner.h @@ -18,7 +18,7 @@ class DocumentDBConfigOwner : public IDocumentDBConfigOwner std::shared_ptr<DocumentDBDirectoryHolder> _holder; public: DocumentDBConfigOwner(); - virtual ~DocumentDBConfigOwner(); + ~DocumentDBConfigOwner() override; std::shared_ptr<DocumentDBDirectoryHolder> getDocumentDBDirectoryHolder(); }; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 81edf9bd659..2ae7e38cf4a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -30,6 +30,7 @@ #include <vespa/searchcore/proton/persistenceengine/commit_and_wait_document_retriever.h> #include <vespa/searchcore/proton/reference/document_db_reference_resolver.h> #include <vespa/searchcore/proton/reference/i_document_db_reference_registry.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchlib/attribute/configconverter.h> #include <vespa/searchlib/engine/docsumreply.h> #include <vespa/searchlib/engine/searchreply.h> @@ -119,10 +120,10 @@ public: template<typename T> void -forceCommitAndWait(std::shared_ptr<IFeedView> feedView, SerialNum serialNum, T keepAlive) { +forceCommitAndWait(IFeedView & feedView, SerialNum serialNum, T keepAlive) { vespalib::Gate gate; using Keep = vespalib::KeepAlive<std::pair<T, std::shared_ptr<IDestructorCallback>>>; - feedView->forceCommit(CommitParam(serialNum), + feedView.forceCommit(CommitParam(serialNum), std::make_shared<Keep>(std::make_pair(std::move(keepAlive), std::make_shared<GateCallback>(gate)))); gate.await(); } @@ -157,7 +158,7 @@ DocumentDB::create(const vespalib::string &baseDir, new DocumentDB(baseDir, std::move(currentSnapshot), tlsSpec, queryLimiter, docTypeName, bucketSpace, protonCfg, owner, shared_service, tlsWriterFactory, metricsWireService, fileHeaderContext, std::move(attribute_interlock), - std::move(config_store), initializeThreads, hwInfo)); + std::move(config_store), std::move(initializeThreads), hwInfo)); } DocumentDB::DocumentDB(const vespalib::string &baseDir, DocumentDBConfig::SP configSnapshot, @@ -268,11 +269,11 @@ DocumentDB::registerReference() } void -DocumentDB::setActiveConfig(const DocumentDBConfig::SP &config, int64_t generation) { +DocumentDB::setActiveConfig(DocumentDBConfig::SP config, int64_t generation) { lock_guard guard(_configMutex); registerReference(); - _activeConfigSnapshot = config; assert(generation >= config->getGeneration()); + _activeConfigSnapshot = std::move(config); if (_activeConfigSnapshotGeneration < generation) { _activeConfigSnapshotGeneration = generation; } @@ -342,7 +343,8 @@ DocumentDB::initFinish(DocumentDBConfig::SP configSnapshot) syncFeedView(); // Check that feed view has been activated. assert(_feedView.get()); - setActiveConfig(configSnapshot, configSnapshot->getGeneration()); + int64_t generation = configSnapshot->getGeneration(); + setActiveConfig(std::move(configSnapshot), generation); startTransactionLogReplay(); } @@ -351,7 +353,7 @@ void DocumentDB::newConfigSnapshot(DocumentDBConfig::SP snapshot) { // Called by executor thread - _pendingConfigSnapshot.set(snapshot); + _pendingConfigSnapshot.set(std::move(snapshot)); { lock_guard guard(_configMutex); if ( ! _activeConfigSnapshot) { @@ -428,7 +430,7 @@ DocumentDB::applySubDBConfig(const DocumentDBConfig &newConfigSnapshot, auto oldRepo = _activeConfigSnapshot->getDocumentTypeRepoSP(); auto oldDocType = oldRepo->getDocumentType(_docTypeName.getName()); assert(oldDocType != nullptr); - auto newRepo = newConfigSnapshot.getDocumentTypeRepoSP(); + const auto & newRepo = newConfigSnapshot.getDocumentTypeRepoSP(); auto newDocType = newRepo->getDocumentType(_docTypeName.getName()); assert(newDocType != nullptr); DocumentDBReferenceResolver resolver(*registry, *newDocType, newConfigSnapshot.getImportedFieldsConfig(), *oldDocType, @@ -487,7 +489,7 @@ DocumentDB::applyConfig(DocumentDBConfig::SP configSnapshot, SerialNum serialNum } { bool elidedConfigSave = equalReplayConfig && tlsReplayDone; - forceCommitAndWait(_feedView.get(), elidedConfigSave ? serialNum : serialNum - 1, std::move(commit_result)); + forceCommitAndWait(*_feedView.get(), elidedConfigSave ? serialNum : serialNum - 1, std::move(commit_result)); } if (params.shouldMaintenanceControllerChange()) { _maintenanceController.killJobs(); @@ -623,7 +625,7 @@ std::pair<size_t, size_t> DocumentDB::getNumActiveDocs() const { if (_state.get_load_done()) { - return { _subDBs.getReadySubDB()->getNumActiveDocs(), _subDBs.getBucketDB().getActiveDocs() }; + return { _subDBs.getReadySubDB()->getNumActiveDocs(), _subDBs.getBucketDB().getNumActiveDocs() }; } else { return {0u, 0u}; } @@ -805,9 +807,9 @@ DocumentDB::setIndexSchema(const DocumentDBConfig &configSnapshot, SerialNum ser } void -DocumentDB::reconfigure(const DocumentDBConfig::SP & snapshot) +DocumentDB::reconfigure(DocumentDBConfig::SP snapshot) { - masterExecute([this, snapshot]() { newConfigSnapshot(snapshot); }); + masterExecute([this, snapshot=std::move(snapshot)]() mutable { newConfigSnapshot(std::move(snapshot)); }); // Wait for config to be applied, or for document db close std::unique_lock<std::mutex> guard(_configMutex); while ((_activeConfigSnapshotGeneration < snapshot->getGeneration()) && !_state.getClosed()) { @@ -1010,7 +1012,7 @@ DocumentDB::notifyClusterStateChanged(const std::shared_ptr<IBucketStateCalculat IFeedView::SP feedView(_feedView.get()); if (feedView) { // Try downcast to avoid polluting API - CombiningFeedView *cfv = dynamic_cast<CombiningFeedView *>(feedView.get()); + auto *cfv = dynamic_cast<CombiningFeedView *>(feedView.get()); if (cfv != nullptr) cfv->setCalculator(newCalc); } diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h index d05fef00f4b..9d7e98e0db4 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h @@ -126,7 +126,7 @@ private: DocumentDBMetricsUpdater _metricsUpdater; void registerReference(); - void setActiveConfig(const DocumentDBConfigSP &config, int64_t generation); + void setActiveConfig(DocumentDBConfigSP config, int64_t generation); DocumentDBConfigSP getActiveConfig() const; void internalInit(); void initManagers(); @@ -371,7 +371,7 @@ public: void replayConfig(SerialNum serialNum) override; const DocTypeName & getDocTypeName() const { return _docTypeName; } void newConfigSnapshot(DocumentDBConfigSP snapshot); - void reconfigure(const DocumentDBConfigSP & snapshot) override; + void reconfigure(DocumentDBConfigSP snapshot) override; int64_t getActiveGeneration() const; /* * Implements IDocumentSubDBOwner diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp index 1cd27783a39..945570c5b3b 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp @@ -8,6 +8,7 @@ #include "searchabledocsubdb.h" #include <vespa/searchcore/proton/persistenceengine/commit_and_wait_document_retriever.h> #include <vespa/searchcore/proton/metrics/documentdb_tagged_metrics.h> +#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/vespalib/util/lambdatask.h> #include <vespa/vespalib/util/threadstackexecutor.h> diff --git a/searchcore/src/vespa/searchcore/proton/server/i_document_db_config_owner.h b/searchcore/src/vespa/searchcore/proton/server/i_document_db_config_owner.h index 7e1dda917f8..c22b02c968e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/i_document_db_config_owner.h +++ b/searchcore/src/vespa/searchcore/proton/server/i_document_db_config_owner.h @@ -16,9 +16,9 @@ class DocumentDBConfig; class IDocumentDBConfigOwner { public: - virtual ~IDocumentDBConfigOwner() { } + virtual ~IDocumentDBConfigOwner() = default; virtual document::BucketSpace getBucketSpace() const = 0; - virtual void reconfigure(const std::shared_ptr<DocumentDBConfig> & config) = 0; + virtual void reconfigure(std::shared_ptr<DocumentDBConfig> config) = 0; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/i_proton_configurer_owner.h b/searchcore/src/vespa/searchcore/proton/server/i_proton_configurer_owner.h index 704b54dc566..432a5c30d03 100644 --- a/searchcore/src/vespa/searchcore/proton/server/i_proton_configurer_owner.h +++ b/searchcore/src/vespa/searchcore/proton/server/i_proton_configurer_owner.h @@ -18,7 +18,7 @@ class IProtonConfigurerOwner { public: using InitializeThreads = std::shared_ptr<vespalib::ThreadExecutor>; - virtual ~IProtonConfigurerOwner() { } + virtual ~IProtonConfigurerOwner() = default; virtual std::shared_ptr<DocumentDBConfigOwner> addDocumentDB(const DocTypeName &docTypeName, document::BucketSpace bucketSpace, const vespalib::string &configId, diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h index 08a1b17705f..4c4bf87ee8e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton.h @@ -24,7 +24,6 @@ #include <vespa/vespalib/net/http/json_get_handler.h> #include <vespa/vespalib/net/http/json_handler_repo.h> #include <vespa/vespalib/net/http/state_explorer.h> -#include <vespa/vespalib/util/varholder.h> #include <vespa/vespalib/util/cpu_usage.h> #include <mutex> #include <shared_mutex> diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp index 2c891927fa3..4877d8a7cfa 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp @@ -61,7 +61,7 @@ ProtonConfigurer::ProtonConfigurer(vespalib::ThreadExecutor &executor, class ProtonConfigurer::ReconfigureTask : public vespalib::Executor::Task { public: - ReconfigureTask(ProtonConfigurer & configurer) + explicit ReconfigureTask(ProtonConfigurer & configurer) : _configurer(configurer), _retainGuard(configurer._pendingReconfigureTasks) {} @@ -169,7 +169,7 @@ ProtonConfigurer::applyConfig(std::shared_ptr<ProtonConfigSnapshot> configSnapsh size_t gen = bootstrapConfig->getGeneration(); _componentConfig.addConfig({"proton", gen}); std::lock_guard<std::mutex> guard(_mutex); - _activeConfigSnapshot = configSnapshot; + _activeConfigSnapshot = std::move(configSnapshot); } void @@ -177,7 +177,7 @@ ProtonConfigurer::configureDocumentDB(const ProtonConfigSnapshot &configSnapshot const DocTypeName &docTypeName, document::BucketSpace bucketSpace, const vespalib::string &configId, - const InitializeThreads &initializeThreads) + InitializeThreads initializeThreads) { // called by proton executor thread const auto &bootstrapConfig = configSnapshot.getBootstrapConfig(); @@ -187,7 +187,7 @@ ProtonConfigurer::configureDocumentDB(const ProtonConfigSnapshot &configSnapshot const auto &documentDBConfig = cfgitr->second; auto dbitr(_documentDBs.find(docTypeName)); if (dbitr == _documentDBs.end()) { - auto newdb = _owner.addDocumentDB(docTypeName, bucketSpace, configId, bootstrapConfig, documentDBConfig, initializeThreads); + auto newdb = _owner.addDocumentDB(docTypeName, bucketSpace, configId, bootstrapConfig, documentDBConfig, std::move(initializeThreads)); if (newdb) { auto insres = _documentDBs.insert(std::make_pair(docTypeName, std::make_pair(newdb, newdb->getDocumentDBDirectoryHolder()))); assert(insres.second); @@ -251,7 +251,10 @@ ProtonConfigurer::applyInitialConfig(InitializeThreads initializeThreads) assert(!_executor.isCurrentThread()); std::promise<void> promise; auto future = promise.get_future(); - _executor.execute(makeLambdaTask([this, initializeThreads, &promise]() { applyConfig(getPendingConfigSnapshot(), initializeThreads, true); promise.set_value(); })); + _executor.execute(makeLambdaTask([this, executor=std::move(initializeThreads), &promise]() mutable { + applyConfig(getPendingConfigSnapshot(), std::move(executor), true); + promise.set_value(); + })); future.wait(); } diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h index 0ccf1b1a348..e9affb91d44 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h @@ -46,7 +46,7 @@ class ProtonConfigurer : public IProtonConfigurer InitializeThreads initializeThreads, bool initialConfig); void configureDocumentDB(const ProtonConfigSnapshot &configSnapshot, const DocTypeName &docTypeName, document::BucketSpace bucketSpace, - const vespalib::string &configId, const InitializeThreads &initializeThreads); + const vespalib::string &configId, InitializeThreads initializeThreads); void pruneDocumentDBs(const ProtonConfigSnapshot &configSnapshot); void pruneInitialDocumentDBDirs(const ProtonConfigSnapshot &configSnapshot); @@ -63,7 +63,7 @@ public: std::shared_ptr<ProtonConfigSnapshot> getActiveConfigSnapshot() const; - virtual void reconfigure(std::shared_ptr<ProtonConfigSnapshot> configSnapshot) override; + void reconfigure(std::shared_ptr<ProtonConfigSnapshot> configSnapshot) override; void applyInitialConfig(InitializeThreads initializeThreads); vespalib::SimpleComponentConfigProducer &getComponentConfig() { return _componentConfig; } diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h index 315587dd5ed..d264a625e96 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h @@ -19,7 +19,6 @@ #include <vespa/searchcore/proton/matching/ranking_assets_repo.h> #include <vespa/searchcorespi/index/iindexmanager.h> #include <vespa/vespalib/util/blockingthreadstackexecutor.h> -#include <vespa/vespalib/util/varholder.h> namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h index 178ed73aef5..cb1f1ed07bb 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h @@ -5,7 +5,6 @@ #include "storeonlyfeedview.h" #include "summaryadapter.h" #include "tlssyncer.h" -#include <vespa/searchcore/proton/bucketdb/bucket_db_owner.h> #include <vespa/searchcore/proton/common/doctypename.h> #include <vespa/searchcore/proton/common/subdbtype.h> #include <vespa/searchcore/proton/docsummary/summarymanager.h> @@ -48,7 +47,7 @@ public: _tlSyncer(tlSyncer) { } - virtual ~DocSubDB() { } + ~DocSubDB() override = default; void close() override { } }; @@ -68,7 +67,7 @@ public: StoreOnlySubDBFileHeaderContext(const search::common::FileHeaderContext & parentFileHeaderContext, const DocTypeName &docTypeName, const vespalib::string &baseDir); - ~StoreOnlySubDBFileHeaderContext(); + ~StoreOnlySubDBFileHeaderContext() override; void addTags(vespalib::GenericHeader &header, const vespalib::string &name) const override; }; diff --git a/vespalib/src/vespa/vespalib/util/varholder.h b/vespalib/src/vespa/vespalib/util/varholder.h index c9bd9f1641a..db8109fca70 100644 --- a/vespalib/src/vespa/vespalib/util/varholder.h +++ b/vespalib/src/vespa/vespalib/util/varholder.h @@ -18,12 +18,12 @@ public: VarHolder & operator = (const VarHolder &) = delete; ~VarHolder(); - void set(const T &v) { + void set(T v) { T old; { std::lock_guard guard(_lock); - old = _v; - _v = v; + old = std::move(_v); + _v = std::move(v); } } |