From 27821c298d6f61b025e400812cdd71871c1e3982 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 9 Mar 2017 13:35:46 +0100 Subject: Deinline destructorsi and use -Winline gcc option. --- build_settings.cmake | 2 +- .../src/tests/routablefactory/routablefactory.cpp | 7 +- .../src/apps/tests/persistenceconformance_test.cpp | 42 ++-- .../vespa-transactionlog-inspect.cpp | 143 ++++++++------ .../attribute_manager/attribute_manager_test.cpp | 86 ++++---- .../tests/proton/attribute/attributeflush_test.cpp | 38 ++-- .../documentdb/configurer/configurer_test.cpp | 123 +++++++----- .../document_subdbs/document_subdbs_test.cpp | 90 ++++----- .../documentbucketmover_test.cpp | 104 +++++----- .../tests/proton/documentdb/documentdb_test.cpp | 16 +- .../documentdb/feedhandler/feedhandler_test.cpp | 60 +++--- .../proton/documentdb/feedview/feedview_test.cpp | 219 ++++++++++----------- .../lid_space_compaction_test.cpp | 40 ++-- .../maintenancecontroller_test.cpp | 81 +++----- .../documentmetastore/documentmetastore_test.cpp | 146 +++++++------- .../src/tests/proton/matching/matching_test.cpp | 26 +-- .../src/tests/proton/server/feedstates_test.cpp | 58 +++--- .../proton/server/memoryflush/memoryflush_test.cpp | 9 +- .../proton/server/fast_access_feed_view.cpp | 9 +- .../proton/server/fast_access_feed_view.h | 1 + .../proton/server/searchable_feed_view.cpp | 25 +-- .../proton/server/searchable_feed_view.h | 2 +- .../vespa/searchcore/proton/server/searchview.cpp | 4 +- .../vespa/searchcore/proton/server/searchview.h | 3 + .../imported_attribute_vector_test.cpp | 21 +- .../attribute_searchable_adapter_test.cpp | 46 +++-- .../attribute/searchcontext/searchcontext.cpp | 50 +++-- .../src/tests/btree/btreeaggregation_test.cpp | 13 +- .../tests/diskindex/diskindex/diskindex_test.cpp | 10 +- .../diskindex/fieldwriter/fieldwriter_test.cpp | 31 +-- .../docstore/logdatastore/logdatastore_test.cpp | 60 +++--- .../ranking_expression/ranking_expression_test.cpp | 28 +-- .../fef/termfieldmodel/termfieldmodel_test.cpp | 10 +- searchlib/src/tests/grouping/grouping_test.cpp | 6 +- .../groupingengine/groupingengine_benchmark.cpp | 8 +- .../tests/groupingengine/groupingengine_test.cpp | 6 +- .../memoryindex/dictionary/dictionary_test.cpp | 27 +-- .../memoryindex/memoryindex/memoryindex_test.cpp | 26 +-- searchlib/src/tests/nearsearch/nearsearch_test.cpp | 29 +-- .../booleanmatchiteratorwrapper_test.cpp | 3 + .../parallel_weak_and/parallel_weak_and_test.cpp | 26 ++- .../queryeval/simple_phrase/simple_phrase_test.cpp | 26 +-- .../queryeval/sourceblender/sourceblender.cpp | 24 ++- .../queryeval/termwise_eval/termwise_eval_test.cpp | 3 + searchlib/src/tests/ranksetup/ranksetup_test.cpp | 32 +-- .../tests/transactionlogstress/translogstress.cpp | 45 +++-- .../tests/util/bufferwriter/bufferwriter_test.cpp | 16 +- .../src/vespa/searchlib/test/fakedata/fakeword.h | 140 ++++--------- .../src/tests/docsumformat/docsum-pack.cpp | 25 ++- .../slime_summary/slime_summary_test.cpp | 49 +++-- .../vespa/storage/tools/analyzedistribution.cpp | 89 ++++----- .../storage/tools/generatedistributionbits.cpp | 60 +++--- storage/src/vespa/storage/tools/getidealstate.cpp | 71 ++++--- storage/src/vespa/storage/tools/statfs.cpp | 31 +-- storage/src/vespa/storage/tools/throttlingsim.h | 14 +- storageserver/src/apps/storaged/storage.cpp | 3 + storageserver/src/tests/storageservertest.cpp | 42 ++-- .../vespa/storageserver/app/distributorprocess.cpp | 4 + .../vespa/storageserver/app/distributorprocess.h | 2 +- .../src/vespa/vespaclient/vdsstates/statesapp.cpp | 167 ++++++++-------- .../vespa/vespaclient/vesparoute/application.cpp | 9 +- .../src/vespa/vespaclient/vesparoute/application.h | 1 + vsm/src/tests/searcher/searcher.cpp | 30 +-- 63 files changed, 1396 insertions(+), 1221 deletions(-) diff --git a/build_settings.cmake b/build_settings.cmake index 8e97f1ba063..d5e82d8494a 100644 --- a/build_settings.cmake +++ b/build_settings.cmake @@ -20,7 +20,7 @@ set(AUTORUN_UNIT_TESTS FALSE CACHE BOOL "If TRUE, tests will be run immediately set(WARN_OPTS "-Wuninitialized -Werror -Wall -W -Wchar-subscripts -Wcomment -Wformat -Wparentheses -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings") # C and C++ compiler flags -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O3 ${WARN_OPTS} -fPIC -D_GLIBCXX_USE_CXX11_ABI=0 -DBOOST_DISABLE_ASSERTS -march=westmere -mtune=intel ${EXTRA_C_FLAGS}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O3 -Winline ${WARN_OPTS} -fPIC -D_GLIBCXX_USE_CXX11_ABI=0 -DBOOST_DISABLE_ASSERTS -march=westmere -mtune=intel ${EXTRA_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -Wnon-virtual-dtor -fvisibility-inlines-hidden -fdiagnostics-color=auto ${EXTRA_CXX_FLAGS}") # Linker flags diff --git a/documentapi/src/tests/routablefactory/routablefactory.cpp b/documentapi/src/tests/routablefactory/routablefactory.cpp index ba886f2f7d2..fff7d84a197 100644 --- a/documentapi/src/tests/routablefactory/routablefactory.cpp +++ b/documentapi/src/tests/routablefactory/routablefactory.cpp @@ -100,6 +100,7 @@ public: public: TestData(); + ~TestData(); bool start(); }; @@ -127,9 +128,9 @@ TestData::TestData() : mbus::RPCNetworkParams().setIdentity(mbus::Identity("dst")).setSlobrokConfig(_slobrok.config())), _dstSession(), _dstHandler() -{ - // empty -} +{ } + +TestData::~TestData() {} bool TestData::start() diff --git a/searchcore/src/apps/tests/persistenceconformance_test.cpp b/searchcore/src/apps/tests/persistenceconformance_test.cpp index b8fc3def866..c3721b0064b 100644 --- a/searchcore/src/apps/tests/persistenceconformance_test.cpp +++ b/searchcore/src/apps/tests/persistenceconformance_test.cpp @@ -84,12 +84,8 @@ private: public: ConfigFactory(const DocumentTypeRepo::SP &repo, const DocumenttypesConfigSP &typeCfg, - const SchemaConfigFactory::SP &schemaFactory) : - _repo(repo), - _typeCfg(typeCfg), - _schemaFactory(schemaFactory) - { - } + const SchemaConfigFactory::SP &schemaFactory); + ~ConfigFactory(); const DocumentTypeRepo::SP getTypeRepo() const { return _repo; } const DocumenttypesConfigSP getTypeCfg() const { return _typeCfg; } DocTypeVector getDocTypes() const { @@ -131,6 +127,15 @@ public: } }; + +ConfigFactory::ConfigFactory(const DocumentTypeRepo::SP &repo, const DocumenttypesConfigSP &typeCfg, + const SchemaConfigFactory::SP &schemaFactory) + : _repo(repo), + _typeCfg(typeCfg), + _schemaFactory(schemaFactory) +{} +ConfigFactory::~ConfigFactory() {} + class DocumentDBFactory : public DummyDBOwner { private: vespalib::string _baseDir; @@ -144,17 +149,8 @@ private: vespalib::ThreadStackExecutor _summaryExecutor; public: - DocumentDBFactory(const vespalib::string &baseDir, int tlsListenPort) : - _baseDir(baseDir), - _fileHeaderContext(), - _tls("tls", tlsListenPort, baseDir, _fileHeaderContext), - _tlsSpec(vespalib::make_string("tcp/localhost:%d", tlsListenPort)), - _queryLimiter(), - _clock(), - _metricsWireService(), - _summaryExecutor(8, 128 * 1024) - { - } + DocumentDBFactory(const vespalib::string &baseDir, int tlsListenPort); + ~DocumentDBFactory(); DocumentDB::SP create(const DocTypeName &docType, const ConfigFactory &factory) { DocumentDBConfig::SP snapshot = factory.create(docType); @@ -199,6 +195,18 @@ public: }; +DocumentDBFactory::DocumentDBFactory(const vespalib::string &baseDir, int tlsListenPort) + : _baseDir(baseDir), + _fileHeaderContext(), + _tls("tls", tlsListenPort, baseDir, _fileHeaderContext), + _tlsSpec(vespalib::make_string("tcp/localhost:%d", tlsListenPort)), + _queryLimiter(), + _clock(), + _metricsWireService(), + _summaryExecutor(8, 128 * 1024) +{} +DocumentDBFactory::~DocumentDBFactory() {} + class DocumentDBRepo { private: DocumentDBMap _docDbs; diff --git a/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp b/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp index b6c8ba24de4..6a984c7c9a1 100644 --- a/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp +++ b/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp @@ -137,14 +137,18 @@ struct DummyStreamHandler : public NewConfigOperation::IStreamHandler { struct DocTypeRepo { DocumenttypesConfigSP docTypeCfg; DocumentTypeRepo docTypeRepo; - DocTypeRepo(const std::string &configDir) - : docTypeCfg(config::ConfigGetter:: - getConfig("", config::DirSpec(configDir)).release()), - docTypeRepo(*docTypeCfg) - { - } + DocTypeRepo(const std::string &configDir); + ~DocTypeRepo(); }; +DocTypeRepo::DocTypeRepo(const std::string &configDir) + : docTypeCfg(config::ConfigGetter::getConfig("", config::DirSpec(configDir)).release()), + docTypeRepo(*docTypeCfg) +{ +} + +DocTypeRepo::~DocTypeRepo() {} + /** * Class the receives all concrete operations as part of a domain visit @@ -340,14 +344,8 @@ public: std::string tlsName; int listenPort; typedef std::unique_ptr UP; - BaseOptions(int argc, const char* const* argv) - : _opts(argc, argv) - { - _opts.addOption("tlsdir", tlsDir, "Tls directory"); - _opts.addOption("tlsname", tlsName, std::string("tls"), "Name of the tls"); - _opts.addOption("listenport", listenPort, 13701, "Tcp listen port"); - } - virtual ~BaseOptions() {} + BaseOptions(int argc, const char* const* argv); + virtual ~BaseOptions(); void usage() { _opts.writeSyntaxPage(std::cout); } virtual void parse() { _opts.parse(); } virtual std::string toString() const { @@ -357,6 +355,15 @@ public: virtual Utility::UP createUtility() const = 0; }; +BaseOptions::BaseOptions(int argc, const char* const* argv) + : _opts(argc, argv) +{ + _opts.addOption("tlsdir", tlsDir, "Tls directory"); + _opts.addOption("tlsname", tlsName, std::string("tls"), "Name of the tls"); + _opts.addOption("listenport", listenPort, 13701, "Tcp listen port"); +} +BaseOptions::~BaseOptions() {} + /** * Base class for a utility with tls server and tls client. */ @@ -439,15 +446,8 @@ struct DumpOperationsOptions : public BaseOptions SerialNum firstSerialNum; SerialNum lastSerialNum; std::string configDir; - DumpOperationsOptions(int argc, const char* const* argv) - : BaseOptions(argc, argv) - { - _opts.addOption("domain", domainName, "Name of the domain"); - _opts.addOption("first", firstSerialNum, "Serial number of first operation"); - _opts.addOption("last", lastSerialNum, "Serial number of last operation"); - _opts.addOption("configdir", configDir, "Config directory (with documenttypes.cfg)"); - _opts.setSyntaxMessage("Utility to dump a range of operations ([first,last]) in a tls domain"); - } + DumpOperationsOptions(int argc, const char* const* argv); + ~DumpOperationsOptions(); static std::string command() { return "dumpoperations"; } virtual std::string toString() const { return vespalib::make_string("%s, domain=%s, first=%" PRIu64 ", last=%" PRIu64 ", configdir=%s", @@ -458,6 +458,18 @@ struct DumpOperationsOptions : public BaseOptions virtual Utility::UP createUtility() const; }; +DumpOperationsOptions::DumpOperationsOptions(int argc, const char* const* argv) + : BaseOptions(argc, argv) +{ + _opts.addOption("domain", domainName, "Name of the domain"); + _opts.addOption("first", firstSerialNum, "Serial number of first operation"); + _opts.addOption("last", lastSerialNum, "Serial number of last operation"); + _opts.addOption("configdir", configDir, "Config directory (with documenttypes.cfg)"); + _opts.setSyntaxMessage("Utility to dump a range of operations ([first,last]) in a tls domain"); +} +DumpOperationsOptions::~DumpOperationsOptions() {} + + /** * Utility to dump a range of operations in a tls domain. */ @@ -513,13 +525,8 @@ struct DumpDocumentsOptions : public DumpOperationsOptions { std::string format; bool verbose; - DumpDocumentsOptions(int argc, const char* const* argv) - : DumpOperationsOptions(argc, argv) - { - _opts.addOption("format", format, std::string("xml"), "Format in which the document operations should be dumped ('xml' or 'text')"); - _opts.addOption("verbose", verbose, false, "Whether the document operations should be dumped verbosely"); - _opts.setSyntaxMessage("Utility to dump a range of document operations ([first,last]) in a tls domain"); - } + DumpDocumentsOptions(int argc, const char* const* argv); + ~DumpDocumentsOptions(); static std::string command() { return "dumpdocuments"; } virtual void parse() { DumpOperationsOptions::parse(); @@ -535,6 +542,16 @@ struct DumpDocumentsOptions : public DumpOperationsOptions virtual Utility::UP createUtility() const; }; +DumpDocumentsOptions::DumpDocumentsOptions(int argc, const char* const* argv) + : DumpOperationsOptions(argc, argv) +{ + _opts.addOption("format", format, std::string("xml"), "Format in which the document operations should be dumped ('xml' or 'text')"); + _opts.addOption("verbose", verbose, false, "Whether the document operations should be dumped verbosely"); + _opts.setSyntaxMessage("Utility to dump a range of document operations ([first,last]) in a tls domain"); +} +DumpDocumentsOptions::~DumpDocumentsOptions() {} + + /** * Utility to dump a range of document operations in a tls domain. */ @@ -596,38 +613,46 @@ private: } public: - int Main() { - _programName = _argv[0]; - if (_argc < 2) { - usage(); - return 1; - } - BaseOptions::UP opts; - if (strcmp(_argv[1], ListDomainsOptions::command().c_str()) == 0) { - combineFirstArgs(); - opts.reset(new ListDomainsOptions(_argc-1, _argv+1)); - } else if (strcmp(_argv[1], DumpOperationsOptions::command().c_str()) == 0) { - combineFirstArgs(); - opts.reset(new DumpOperationsOptions(_argc-1, _argv+1)); - } else if (strcmp(_argv[1], DumpDocumentsOptions::command().c_str()) == 0) { - combineFirstArgs(); - opts.reset(new DumpDocumentsOptions(_argc-1, _argv+1)); - } - if (opts.get() != NULL) { - try { - opts->parse(); - } catch (const vespalib::InvalidCommandLineArgumentsException &e) { - std::cerr << "Error parsing program options: " << e.getMessage() << std::endl; - usageHeader(); - opts->usage(); - return 1; - } - return opts->createUtility()->run(); - } + App(); + ~App(); + int Main(); +}; + +App::App() {} +App::~App() {} + +int +App::Main() { + _programName = _argv[0]; + if (_argc < 2) { usage(); return 1; } -}; + BaseOptions::UP opts; + if (strcmp(_argv[1], ListDomainsOptions::command().c_str()) == 0) { + combineFirstArgs(); + opts.reset(new ListDomainsOptions(_argc-1, _argv+1)); + } else if (strcmp(_argv[1], DumpOperationsOptions::command().c_str()) == 0) { + combineFirstArgs(); + opts.reset(new DumpOperationsOptions(_argc-1, _argv+1)); + } else if (strcmp(_argv[1], DumpDocumentsOptions::command().c_str()) == 0) { + combineFirstArgs(); + opts.reset(new DumpDocumentsOptions(_argc-1, _argv+1)); + } + if (opts.get() != NULL) { + try { + opts->parse(); + } catch (const vespalib::InvalidCommandLineArgumentsException &e) { + std::cerr << "Error parsing program options: " << e.getMessage() << std::endl; + usageHeader(); + opts->usage(); + return 1; + } + return opts->createUtility()->run(); + } + usage(); + return 1; +} int main(int argc, char **argv) diff --git a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp index 14d7112fd5d..afd2150a1bd 100644 --- a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp @@ -128,18 +128,21 @@ struct ImportedAttributesRepoBuilder { struct BaseFixture { test::DirectoryHandler _dirHandler; - DummyFileHeaderContext _fileHeaderContext; - ForegroundTaskExecutor _attributeFieldWriter; - HwInfo _hwInfo; - BaseFixture() - : _dirHandler(test_dir), - _fileHeaderContext(), - _attributeFieldWriter(), - _hwInfo() - { - } + DummyFileHeaderContext _fileHeaderContext; + ForegroundTaskExecutor _attributeFieldWriter; + HwInfo _hwInfo; + BaseFixture(); + ~BaseFixture(); }; +BaseFixture::BaseFixture() + : _dirHandler(test_dir), + _fileHeaderContext(), + _attributeFieldWriter(), + _hwInfo() +{ +} +BaseFixture::~BaseFixture() {} struct AttributeManagerFixture { @@ -147,15 +150,8 @@ struct AttributeManagerFixture proton::AttributeManager &_m; AttributeWriter _aw; ImportedAttributesRepoBuilder _builder; - AttributeManagerFixture(BaseFixture &bf) - : _msp(std::make_shared - (test_dir, "test.subdb", TuneFileAttributes(), bf._fileHeaderContext, - bf._attributeFieldWriter, bf._hwInfo)), - _m(*_msp), - _aw(_msp), - _builder() - { - } + AttributeManagerFixture(BaseFixture &bf); + ~AttributeManagerFixture(); AttributeVector::SP addAttribute(const vespalib::string &name) { return _m.addAttribute(name, INT32_SINGLE, createSerialNum); } @@ -167,6 +163,15 @@ struct AttributeManagerFixture } }; +AttributeManagerFixture::AttributeManagerFixture(BaseFixture &bf) + : _msp(std::make_shared(test_dir, "test.subdb", TuneFileAttributes(), + bf._fileHeaderContext, bf._attributeFieldWriter, bf._hwInfo)), + _m(*_msp), + _aw(_msp), + _builder() +{} +AttributeManagerFixture::~AttributeManagerFixture() {} + struct Fixture : public BaseFixture, public AttributeManagerFixture { Fixture() @@ -205,28 +210,31 @@ struct ParallelAttributeManager std::shared_ptr mgr; AttributeManagerInitializer::SP initializer; - ParallelAttributeManager(search::SerialNum configSerialNum, - AttributeManager::SP baseAttrMgr, - const AttributesConfig &attrCfg, - uint32_t docIdLimit) - : documentMetaStoreInitTask(std::make_shared()), - bucketDbOwner(std::make_shared()), - documentMetaStore(std::make_shared(bucketDbOwner)), - attributeGrow(), - attributeGrowNumDocs(1), - fastAccessAttributesOnly(false), - mgr(std::make_shared()), - initializer(std::make_shared - (configSerialNum, documentMetaStoreInitTask, documentMetaStore, baseAttrMgr, attrCfg, - attributeGrow, attributeGrowNumDocs, fastAccessAttributesOnly, mgr)) - { - documentMetaStore->setCommittedDocIdLimit(docIdLimit); - vespalib::ThreadStackExecutor executor(3, 128 * 1024); - initializer::TaskRunner taskRunner(executor); - taskRunner.runTask(initializer); - } + ParallelAttributeManager(search::SerialNum configSerialNum, AttributeManager::SP baseAttrMgr, + const AttributesConfig &attrCfg, uint32_t docIdLimit); + ~ParallelAttributeManager(); }; +ParallelAttributeManager::ParallelAttributeManager(search::SerialNum configSerialNum, AttributeManager::SP baseAttrMgr, + const AttributesConfig &attrCfg, uint32_t docIdLimit) + : documentMetaStoreInitTask(std::make_shared()), + bucketDbOwner(std::make_shared()), + documentMetaStore(std::make_shared(bucketDbOwner)), + attributeGrow(), + attributeGrowNumDocs(1), + fastAccessAttributesOnly(false), + mgr(std::make_shared()), + initializer(std::make_shared(configSerialNum, documentMetaStoreInitTask, + documentMetaStore, baseAttrMgr, attrCfg, + attributeGrow, attributeGrowNumDocs, + fastAccessAttributesOnly, mgr)) +{ + documentMetaStore->setCommittedDocIdLimit(docIdLimit); + vespalib::ThreadStackExecutor executor(3, 128 * 1024); + initializer::TaskRunner taskRunner(executor); + taskRunner.runTask(initializer); +} +ParallelAttributeManager::~ParallelAttributeManager() {} TEST_F("require that attributes are added", Fixture) { diff --git a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp index ecd80358f5b..91b05e4e026 100644 --- a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp +++ b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp @@ -229,40 +229,36 @@ const string test_dir = "flush"; struct BaseFixture { - test::DirectoryHandler _dirHandler; + test::DirectoryHandler _dirHandler; DummyFileHeaderContext _fileHeaderContext; ForegroundTaskExecutor _attributeFieldWriter; HwInfo _hwInfo; - BaseFixture() + BaseFixture(); + BaseFixture(const HwInfo &hwInfo); + ~BaseFixture(); +}; + +BaseFixture::BaseFixture() : _dirHandler(test_dir), _fileHeaderContext(), _attributeFieldWriter(), _hwInfo() - { - } - BaseFixture(const HwInfo &hwInfo) +{ } +BaseFixture::BaseFixture(const HwInfo &hwInfo) : _dirHandler(test_dir), _fileHeaderContext(), _attributeFieldWriter(), _hwInfo(hwInfo) - { - } -}; - +{} +BaseFixture::~BaseFixture() {} struct AttributeManagerFixture { AttributeManager::SP _msp; AttributeManager &_m; AttributeWriter _aw; - AttributeManagerFixture(BaseFixture &bf) - : _msp(std::make_shared - (test_dir, "test.subdb", TuneFileAttributes(), bf._fileHeaderContext, - bf._attributeFieldWriter, bf._hwInfo)), - _m(*_msp), - _aw(_msp) - { - } + AttributeManagerFixture(BaseFixture &bf); + ~AttributeManagerFixture(); AttributeVector::SP addAttribute(const vespalib::string &name) { return _m.addAttribute(name, getInt32Config(), createSerialNum); } @@ -273,6 +269,14 @@ struct AttributeManagerFixture } }; +AttributeManagerFixture::AttributeManagerFixture(BaseFixture &bf) + : _msp(std::make_shared(test_dir, "test.subdb", TuneFileAttributes(), + bf._fileHeaderContext, bf._attributeFieldWriter, bf._hwInfo)), + _m(*_msp), + _aw(_msp) +{} +AttributeManagerFixture::~AttributeManagerFixture() {} + struct Fixture : public BaseFixture, public AttributeManagerFixture { Fixture() diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index daa375e2a00..1e902621a4e 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -78,8 +78,11 @@ struct ViewPtrs { SearchView::SP sv; SearchableFeedView::SP fv; + ~ViewPtrs(); }; +ViewPtrs::~ViewPtrs() {} + struct ViewSet { IndexManagerDummyReconfigurer _reconfigurer; @@ -97,24 +100,8 @@ struct ViewSet VarHolder searchView; VarHolder feedView; HwInfo _hwInfo; - ViewSet() - : _reconfigurer(), - _fileHeaderContext(), - _writeService(), - serialNum(1), - repo(createRepo()), - _docTypeName(DOC_TYPE), - _docIdLimit(0u), - _noTlSyncer(), - _summaryMgr(), - _dmsc(), - _lidReuseDelayer(), - _commitTimeTracker(TimeStamp()), - searchView(), - feedView(), - _hwInfo() - { - } + ViewSet(); + ~ViewSet(); ViewPtrs getViewPtrs() { ViewPtrs ptrs; @@ -124,6 +111,26 @@ struct ViewSet } }; + +ViewSet::ViewSet() + : _reconfigurer(), + _fileHeaderContext(), + _writeService(), + serialNum(1), + repo(createRepo()), + _docTypeName(DOC_TYPE), + _docIdLimit(0u), + _noTlSyncer(), + _summaryMgr(), + _dmsc(), + _lidReuseDelayer(), + _commitTimeTracker(TimeStamp()), + searchView(), + feedView(), + _hwInfo() +{ } +ViewSet::~ViewSet() {} + struct EmptyConstantValueFactory : public vespalib::eval::ConstantValueFactory { virtual vespalib::eval::ConstantValue::UP create(const vespalib::string &, const vespalib::string &) const override { return std::make_unique(); @@ -147,33 +154,35 @@ struct Fixture ViewSet _views; MyDocumentDBReferenceResolver _resolver; ConfigurerUP _configurer; - Fixture() - : _clock(), - _queryLimiter(), - _constantValueFactory(), - _constantValueRepo(_constantValueFactory), - _summaryExecutor(8, 128*1024), - _views(), - _resolver(), - _configurer() - { - vespalib::rmdir(BASE_DIR, true); - vespalib::mkdir(BASE_DIR); - initViewSet(_views); - _configurer.reset(new Configurer(_views._summaryMgr, - _views.searchView, - _views.feedView, - _queryLimiter, - _constantValueRepo, - _clock, - "test", - 0)); - } - ~Fixture() { - } + Fixture(); + ~Fixture(); void initViewSet(ViewSet &views); }; +Fixture::Fixture() + : _clock(), + _queryLimiter(), + _constantValueFactory(), + _constantValueRepo(_constantValueFactory), + _summaryExecutor(8, 128*1024), + _views(), + _resolver(), + _configurer() +{ + vespalib::rmdir(BASE_DIR, true); + vespalib::mkdir(BASE_DIR); + initViewSet(_views); + _configurer.reset(new Configurer(_views._summaryMgr, + _views.searchView, + _views.feedView, + _queryLimiter, + _constantValueRepo, + _clock, + "test", + 0)); +} +Fixture::~Fixture() {} + void Fixture::initViewSet(ViewSet &views) { @@ -334,7 +343,8 @@ struct SearchViewComparer { SearchView::SP _old; SearchView::SP _new; - SearchViewComparer(SearchView::SP old, SearchView::SP new_) : _old(old), _new(new_) {} + SearchViewComparer(SearchView::SP old, SearchView::SP new_); + ~SearchViewComparer(); void expect_equal() { EXPECT_EQUAL(_old.get(), _new.get()); } @@ -379,11 +389,19 @@ struct SearchViewComparer } }; +SearchViewComparer::SearchViewComparer(SearchView::SP old, SearchView::SP new_) + : _old(std::move(old)), + _new(std::move(new_)) +{} +SearchViewComparer::~SearchViewComparer() {} + + struct FeedViewComparer { SearchableFeedView::SP _old; SearchableFeedView::SP _new; - FeedViewComparer(SearchableFeedView::SP old, SearchableFeedView::SP new_) : _old(old), _new(new_) {} + FeedViewComparer(SearchableFeedView::SP old, SearchableFeedView::SP new_); + ~FeedViewComparer(); void expect_equal() { EXPECT_EQUAL(_old.get(), _new.get()); } @@ -410,13 +428,18 @@ struct FeedViewComparer } }; +FeedViewComparer::FeedViewComparer(SearchableFeedView::SP old, SearchableFeedView::SP new_) + : _old(std::move(old)), + _new(std::move(new_)) +{} +FeedViewComparer::~FeedViewComparer() {} + struct FastAccessFeedViewComparer { FastAccessFeedView::SP _old; FastAccessFeedView::SP _new; - FastAccessFeedViewComparer(FastAccessFeedView::SP old, FastAccessFeedView::SP new_) - : _old(old), _new(new_) - {} + FastAccessFeedViewComparer(FastAccessFeedView::SP old, FastAccessFeedView::SP new_); + ~FastAccessFeedViewComparer(); void expect_not_equal() { EXPECT_NOT_EQUAL(_old.get(), _new.get()); } @@ -431,6 +454,12 @@ struct FastAccessFeedViewComparer } }; +FastAccessFeedViewComparer::FastAccessFeedViewComparer(FastAccessFeedView::SP old, FastAccessFeedView::SP new_) + : _old(std::move(old)), + _new(std::move(new_)) +{} +FastAccessFeedViewComparer::~FastAccessFeedViewComparer() {} + TEST_F("require that we can reconfigure index searchable", Fixture) { ViewPtrs o = f._views.getViewPtrs(); 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 93a1b6de3ad..841e7632730 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 @@ -139,34 +139,26 @@ struct MyStoreOnlyContext StoreOnlyContext _ctx; MyStoreOnlyContext(IThreadingService &writeService, ThreadStackExecutorBase &summaryExecutor, - std::shared_ptr bucketDB, - IBucketDBHandlerInitializer & - bucketDBHandlerInitializer) - : _owner(), - _syncProxy(), - _getSerialNum(), - _fileHeader(), - _metrics(DOCTYPE_NAME, 1), - _configMutex(), - _hwInfo(), - _ctx(_owner, - _syncProxy, - _getSerialNum, - _fileHeader, - writeService, - summaryExecutor, - bucketDB, - bucketDBHandlerInitializer, - _metrics, - _configMutex, - _hwInfo) - { - } + std::shared_ptr bucketDB, + IBucketDBHandlerInitializer & + bucketDBHandlerInitializer); + ~MyStoreOnlyContext(); const MySubDBOwner &getOwner() const { return _owner; } }; +MyStoreOnlyContext::MyStoreOnlyContext(IThreadingService &writeService, ThreadStackExecutorBase &summaryExecutor, + std::shared_ptr bucketDB, + IBucketDBHandlerInitializer &bucketDBHandlerInitializer) + : _owner(), _syncProxy(), _getSerialNum(), _fileHeader(), + _metrics(DOCTYPE_NAME, 1), _configMutex(), _hwInfo(), + _ctx(_owner, _syncProxy, _getSerialNum, _fileHeader, writeService, summaryExecutor, bucketDB, + bucketDBHandlerInitializer, _metrics, _configMutex, _hwInfo) +{ +} +MyStoreOnlyContext::~MyStoreOnlyContext() {} + template struct MyFastAccessConfig { @@ -187,18 +179,9 @@ struct MyFastAccessContext FastAccessContext _ctx; MyFastAccessContext(IThreadingService &writeService, ThreadStackExecutorBase &summaryExecutor, - std::shared_ptr bucketDB, - IBucketDBHandlerInitializer & - bucketDBHandlerInitializer) - : _storeOnlyCtx(writeService, summaryExecutor, bucketDB, - bucketDBHandlerInitializer), - _attributeMetrics(NULL), - _legacyAttributeMetrics(NULL), - _attributeMetricsCollection(_attributeMetrics, _legacyAttributeMetrics), - _wireService(), - _ctx(_storeOnlyCtx._ctx, _attributeMetricsCollection, NULL, _wireService) - { - } + std::shared_ptr bucketDB, + IBucketDBHandlerInitializer & bucketDBHandlerInitializer); + ~MyFastAccessContext(); const MyMetricsWireService &getWireService() const { return _wireService; } @@ -207,6 +190,17 @@ struct MyFastAccessContext } }; +MyFastAccessContext::MyFastAccessContext(IThreadingService &writeService, ThreadStackExecutorBase &summaryExecutor, + std::shared_ptr bucketDB, + IBucketDBHandlerInitializer & bucketDBHandlerInitializer) + : _storeOnlyCtx(writeService, summaryExecutor, bucketDB, bucketDBHandlerInitializer), + _attributeMetrics(NULL), _legacyAttributeMetrics(NULL), + _attributeMetricsCollection(_attributeMetrics, _legacyAttributeMetrics), + _wireService(), + _ctx(_storeOnlyCtx._ctx, _attributeMetricsCollection, NULL, _wireService) +{} +MyFastAccessContext::~MyFastAccessContext() {} + struct MySearchableConfig { SearchableConfig _cfg; @@ -224,19 +218,9 @@ struct MySearchableContext SearchableContext _ctx; MySearchableContext(IThreadingService &writeService, ThreadStackExecutorBase &executor, - std::shared_ptr bucketDB, - IBucketDBHandlerInitializer & - bucketDBHandlerInitializer) - : _fastUpdCtx(writeService, executor, bucketDB, - bucketDBHandlerInitializer), - _queryLimiter(), - _clock(), - _ctx(_fastUpdCtx._ctx, - _queryLimiter, - _clock, - executor) - { - } + std::shared_ptr bucketDB, + IBucketDBHandlerInitializer & bucketDBHandlerInitializer); + ~MySearchableContext(); const MyMetricsWireService &getWireService() const { return _fastUpdCtx.getWireService(); } @@ -245,6 +229,16 @@ struct MySearchableContext } }; + +MySearchableContext::MySearchableContext(IThreadingService &writeService, ThreadStackExecutorBase &executor, + std::shared_ptr bucketDB, + IBucketDBHandlerInitializer & bucketDBHandlerInitializer) + : _fastUpdCtx(writeService, executor, bucketDB, bucketDBHandlerInitializer), + _queryLimiter(), _clock(), + _ctx(_fastUpdCtx._ctx, _queryLimiter, _clock, executor) +{} +MySearchableContext::~MySearchableContext() {} + struct OneAttrSchema : public Schema { OneAttrSchema() { diff --git a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp index b5c3ba28769..ab0acb1d77c 100644 --- a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp @@ -1,7 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include -LOG_SETUP("documentbucketmover_test"); + #include #include #include @@ -112,23 +110,9 @@ struct MySubDb MaintenanceDocumentSubDB _subDb; test::UserDocuments _docs; bucketdb::BucketDBHandler _bucketDBHandler; - MySubDb(const DocumentTypeRepo::SP &repo, - std::shared_ptr bucketDB, - uint32_t subDbId, - SubDbType subDbType) - : _metaStoreSP(std::make_shared(bucketDB, - DocumentMetaStore::getFixedName(), - search::GrowStrategy(), - documentmetastore::IGidCompare::SP(new documentmetastore::DefaultGidCompare), - subDbType)), - _metaStore(*_metaStoreSP), - _realRetriever(std::make_shared(repo)), - _retriever(_realRetriever), - _subDb(_metaStoreSP, _retriever, subDbId), _docs(), - _bucketDBHandler(*bucketDB) - { - _bucketDBHandler.addDocumentMetaStore(_metaStoreSP.get(), 0); - } + MySubDb(const DocumentTypeRepo::SP &repo, std::shared_ptr bucketDB, + uint32_t subDbId, SubDbType subDbType); + ~MySubDb(); void insertDocs(const test::UserDocuments &docs_) { for (test::UserDocuments::Iterator itr = docs_.begin(); itr != docs_.end(); ++itr) { const test::BucketDocuments &bucketDocs = itr->second; @@ -171,6 +155,22 @@ struct MySubDb }; +MySubDb::MySubDb(const DocumentTypeRepo::SP &repo, std::shared_ptr bucketDB, + uint32_t subDbId, SubDbType subDbType) + : _metaStoreSP(std::make_shared(bucketDB, + DocumentMetaStore::getFixedName(), + search::GrowStrategy(), + documentmetastore::IGidCompare::SP(new documentmetastore::DefaultGidCompare), + subDbType)), + _metaStore(*_metaStoreSP), + _realRetriever(std::make_shared(repo)), + _retriever(_realRetriever), + _subDb(_metaStoreSP, _retriever, subDbId), _docs(), + _bucketDBHandler(*bucketDB) +{ + _bucketDBHandler.addDocumentMetaStore(_metaStoreSP.get(), 0); +} +MySubDb::~MySubDb() {} struct MySubDbTwoBuckets : public MySubDb { @@ -295,30 +295,27 @@ struct ScanFixtureBase std::shared_ptr _bucketDB; MySubDb _ready; MySubDb _notReady; - ScanFixtureBase() - : _builder(), - _bucketDB(std::make_shared()), - _ready(_builder.getRepo(), _bucketDB, 1, SubDbType::READY), - _notReady(_builder.getRepo(), _bucketDB, 2, SubDbType::NOTREADY) - { - } + ScanFixtureBase(); + ~ScanFixtureBase(); - ScanItr - getItr(void) - { + ScanItr getItr() { return ScanItr(_bucketDB->takeGuard(), BucketId()); } - ScanItr - getItr(BucketId bucket, - BucketId endBucket = BucketId(), - uint32_t pass = FIRST_SCAN_PASS) - { + ScanItr getItr(BucketId bucket, BucketId endBucket = BucketId(), uint32_t pass = FIRST_SCAN_PASS) { return ScanItr(_bucketDB->takeGuard(), pass, bucket, endBucket); } }; +ScanFixtureBase::ScanFixtureBase() + : _builder(), + _bucketDB(std::make_shared()), + _ready(_builder.getRepo(), _bucketDB, 1, SubDbType::READY), + _notReady(_builder.getRepo(), _bucketDB, 2, SubDbType::NOTREADY) +{} +ScanFixtureBase::~ScanFixtureBase() {} + struct ScanFixture : public ScanFixtureBase { @@ -539,23 +536,8 @@ struct ControllerFixtureBase MyFrozenBucketHandler _fbh; test::DiskMemUsageNotifier _diskMemUsageNotifier; BucketMoveJob _bmj; - ControllerFixtureBase(double resourceLimitFactor) - : _builder(), - _calc(new test::BucketStateCalculator), - _bucketHandler(), - _modifiedHandler(), - _bucketDB(std::make_shared()), - _moveHandler(*_bucketDB), - _ready(_builder.getRepo(), _bucketDB, 1, SubDbType::READY), - _notReady(_builder.getRepo(), _bucketDB, 2, SubDbType::NOTREADY), - _fbh(), - _diskMemUsageNotifier(), - _bmj(_calc, _moveHandler, _modifiedHandler, _ready._subDb, - _notReady._subDb, _fbh, _clusterStateHandler, _bucketHandler, - _diskMemUsageNotifier, resourceLimitFactor, - "test") - { - } + ControllerFixtureBase(double resourceLimitFactor); + ~ControllerFixtureBase(); ControllerFixtureBase &addReady(const BucketId &bucket) { _calc->addReady(bucket); return *this; @@ -605,7 +587,23 @@ struct ControllerFixtureBase } }; - +ControllerFixtureBase::ControllerFixtureBase(double resourceLimitFactor) + : _builder(), + _calc(new test::BucketStateCalculator), + _bucketHandler(), + _modifiedHandler(), + _bucketDB(std::make_shared()), + _moveHandler(*_bucketDB), + _ready(_builder.getRepo(), _bucketDB, 1, SubDbType::READY), + _notReady(_builder.getRepo(), _bucketDB, 2, SubDbType::NOTREADY), + _fbh(), + _diskMemUsageNotifier(), + _bmj(_calc, _moveHandler, _modifiedHandler, _ready._subDb, + _notReady._subDb, _fbh, _clusterStateHandler, _bucketHandler, + _diskMemUsageNotifier, resourceLimitFactor, + "test") +{} +ControllerFixtureBase::~ControllerFixtureBase() {} constexpr double RESOURCE_LIMIT_FACTOR = 1.0; struct ControllerFixture : public ControllerFixtureBase diff --git a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp index 473fcba8051..f18029a6449 100644 --- a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp @@ -57,16 +57,19 @@ public: struct MyDBOwner : public DummyDBOwner { std::shared_ptr _registry; - MyDBOwner() - : DummyDBOwner(), - _registry(std::make_shared()) - { - } + MyDBOwner(); + ~MyDBOwner(); std::shared_ptr getDocumentDBReferenceRegistry() const override { return _registry; } }; +MyDBOwner::MyDBOwner() + : DummyDBOwner(), + _registry(std::make_shared()) +{} +MyDBOwner::~MyDBOwner() {} + struct Fixture { DummyWireService _dummy; MyDBOwner _myDBOwner; @@ -79,6 +82,7 @@ struct Fixture { vespalib::Clock _clock; Fixture(); + ~Fixture(); }; Fixture::Fixture() @@ -119,6 +123,8 @@ Fixture::Fixture() _db->waitForOnlineState(); } +Fixture::~Fixture() {} + const IFlushTarget * extractRealFlushTarget(const IFlushTarget *target) { diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index 168bb7cefad..7df80778cb7 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -188,22 +188,8 @@ struct MyFeedView : public test::DummyFeedView { int prune_removed_count; int update_count; SerialNum update_serial; - MyFeedView(const DocumentTypeRepo::SP &dtr) : - test::DummyFeedView(dtr), - putRdz(), - usePutRdz(false), - putLatch(), - metaStore(), - put_count(0), - put_serial(0), - heartbeat_count(0), - remove_count(0), - move_count(0), - prune_removed_count(0), - update_count(0), - update_serial(0) - { - } + MyFeedView(const DocumentTypeRepo::SP &dtr); + ~MyFeedView(); void resetPutLatch(uint32_t count) { putLatch.reset(new vespalib::CountDownLatch(count)); } virtual void preparePut(PutOperation &op) { prepareDocumentOperation(op, op.getDocument()->getId().getGlobalId()); @@ -250,6 +236,23 @@ struct MyFeedView : public test::DummyFeedView { } }; +MyFeedView::MyFeedView(const DocumentTypeRepo::SP &dtr) + : test::DummyFeedView(dtr), + putRdz(), + usePutRdz(false), + putLatch(), + metaStore(), + put_count(0), + put_serial(0), + heartbeat_count(0), + remove_count(0), + move_count(0), + prune_removed_count(0), + update_count(0), + update_serial(0) +{} +MyFeedView::~MyFeedView() {} + struct SchemaContext { Schema::SP schema; @@ -294,7 +297,8 @@ struct MyTransport : public FeedToken::ITransport { vespalib::Gate gate; ResultUP result; bool documentWasFound; - MyTransport() : gate(), result(), documentWasFound(false) {} + MyTransport(); + ~MyTransport(); virtual void send(Reply::UP, ResultUP res, bool documentWasFound_, double) { result = std::move(res); documentWasFound = documentWasFound_; @@ -302,6 +306,9 @@ struct MyTransport : public FeedToken::ITransport { } }; +MyTransport::MyTransport() : gate(), result(), documentWasFound(false) {} +MyTransport::~MyTransport() {} + Reply::UP getReply(uint32_t type) { if (type == DocumentProtocol::REPLY_REMOVEDOCUMENT) { return Reply::UP(new RemoveDocumentReply); @@ -316,14 +323,9 @@ struct FeedTokenContext { FeedToken::UP token_ap; FeedToken &token; - FeedTokenContext(uint32_t type = 0) : - transport(), - token_ap(new FeedToken(transport, getReply(type))), - token(*token_ap) { - token.getReply().getTrace().setLevel(9); - } - bool await(uint32_t timeout = 80000) - { return transport.gate.await(timeout); } + FeedTokenContext(uint32_t type = 0); + ~FeedTokenContext(); + bool await(uint32_t timeout = 80000) { return transport.gate.await(timeout); } const Result *getResult() { if (transport.result.get()) { return transport.result.get(); @@ -332,6 +334,14 @@ struct FeedTokenContext { } }; +FeedTokenContext::FeedTokenContext(uint32_t type) + : transport(), + token_ap(new FeedToken(transport, getReply(type))), + token(*token_ap) +{ + token.getReply().getTrace().setLevel(9); +} +FeedTokenContext::~FeedTokenContext() {} struct PutContext { FeedTokenContext tokenCtx; diff --git a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp index 848c76275d0..42ddfa23eb6 100644 --- a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp @@ -1,7 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include -LOG_SETUP("feedview_test"); + #include #include #include @@ -33,7 +31,8 @@ LOG_SETUP("feedview_test"); #include #include #include - +#include +LOG_SETUP("feedview_test"); using document::BucketId; using document::DataType; @@ -131,23 +130,21 @@ struct ParamsContext PerDocTypeFeedMetrics _metrics; SearchableFeedView::PersistentParams _params; - ParamsContext(const vespalib::string &docType, - const vespalib::string &baseDir) - : _docTypeName(docType), - _feedMetrics(), - _metrics(&_feedMetrics), - _params(0, - 0, - _docTypeName, - _metrics, - subdb_id, - SubDbType::READY) - { - (void) baseDir; - } + ParamsContext(const vespalib::string &docType, const vespalib::string &baseDir); + ~ParamsContext(); const SearchableFeedView::PersistentParams &getParams() const { return _params; } }; +ParamsContext::ParamsContext(const vespalib::string &docType, const vespalib::string &baseDir) + : _docTypeName(docType), + _feedMetrics(), + _metrics(&_feedMetrics), + _params(0, 0, _docTypeName, _metrics, subdb_id, SubDbType::READY) +{ + (void) baseDir; +} +ParamsContext::~ParamsContext() {} + struct MyIndexWriter : public test::MockIndexWriter { MyLidVector _removes; @@ -270,8 +267,7 @@ struct MySummaryAdapter : public test::MockSummaryAdapter : _sumMgr(new MySummaryManager()), _store(static_cast(_sumMgr->getBackingStore())), _removes() - { - } + {} virtual void put(SerialNum serialNum, const document::Document &doc, const DocumentIdT lid) override { (void) serialNum; _store.write(serialNum, doc, lid); @@ -309,41 +305,13 @@ struct MyAttributeWriter : public IAttributeWriter int _heartBeatCount; uint32_t _commitCount; uint32_t _wantedLidLimit; - using AttrMap = std::map>; + using AttrMap = std::map>; AttrMap _attrMap; std::set _attrs; proton::IAttributeManager::SP _mgr; MyTracer &_tracer; - MyAttributeWriter(MyTracer &tracer) - : _removes(), - _putSerial(0), - _putDocId(), - _putLid(0), - _updateSerial(0), - _updateDocId(), - _updateLid(0), - _removeSerial(0), - _removeLid(0), - _heartBeatCount(0), - _commitCount(0), - _wantedLidLimit(0), - _attrMap(), - _attrs(), - _mgr(), - _tracer(tracer) - { - search::attribute::Config cfg(search::attribute::BasicType::INT32); - _attrMap["a1"] = search::AttributeFactory::createAttribute("test", cfg); - search::attribute::Config - cfg2(search::attribute::BasicType::PREDICATE); - _attrMap["a2"] = search::AttributeFactory::createAttribute("test2", - cfg2); - search::attribute::Config cfg3(search::attribute::BasicType::TENSOR); - cfg3.setTensorType(ValueType::from_spec("tensor(x[10])")); - _attrMap["a3"] = search::AttributeFactory::createAttribute("test3", - cfg3); - } + MyAttributeWriter(MyTracer &tracer); + ~MyAttributeWriter(); virtual std::vector getWritableAttributes() const override { return std::vector(); @@ -407,12 +375,30 @@ struct MyAttributeWriter : public IAttributeWriter } }; +MyAttributeWriter::MyAttributeWriter(MyTracer &tracer) + : _removes(), _putSerial(0), _putDocId(), _putLid(0), + _updateSerial(0), _updateDocId(), _updateLid(0), + _removeSerial(0), _removeLid(0), _heartBeatCount(0), + _commitCount(0), _wantedLidLimit(0), + _attrMap(), _attrs(), _mgr(), _tracer(tracer) +{ + search::attribute::Config cfg(search::attribute::BasicType::INT32); + _attrMap["a1"] = search::AttributeFactory::createAttribute("test", cfg); + search::attribute::Config cfg2(search::attribute::BasicType::PREDICATE); + _attrMap["a2"] = search::AttributeFactory::createAttribute("test2", cfg2); + search::attribute::Config cfg3(search::attribute::BasicType::TENSOR); + cfg3.setTensorType(ValueType::from_spec("tensor(x[10])")); + _attrMap["a3"] = search::AttributeFactory::createAttribute("test3", cfg3); +} +MyAttributeWriter::~MyAttributeWriter() {} + struct MyTransport : public FeedToken::ITransport { ResultUP lastResult; vespalib::Gate _gate; MyTracer &_tracer; - MyTransport(MyTracer &tracer) : lastResult(), _gate(), _tracer(tracer) {} + MyTransport(MyTracer &tracer); + ~MyTransport(); virtual void send(mbus::Reply::UP reply, ResultUP result, bool documentWasFound, @@ -425,6 +411,8 @@ struct MyTransport : public FeedToken::ITransport void await() { _gate.await(); } }; +MyTransport::MyTransport(MyTracer &tracer) : lastResult(), _gate(), _tracer(tracer) {} +MyTransport::~MyTransport() {} struct MyResultHandler : public IGenericResultHandler { @@ -440,20 +428,25 @@ struct SchemaContext { Schema::SP _schema; std::unique_ptr _builder; - SchemaContext() : - _schema(new Schema()), - _builder() - { - _schema->addIndexField(Schema::IndexField("i1", schema::STRING, schema::SINGLE)); - _schema->addAttributeField(Schema::AttributeField("a1", schema::STRING, schema::SINGLE)); - _schema->addAttributeField(Schema::AttributeField("a2", schema::BOOLEANTREE, schema::SINGLE)); - _schema->addAttributeField(Schema::AttributeField("a3", schema::TENSOR, schema::SINGLE)); - _schema->addSummaryField(Schema::SummaryField("s1", schema::STRING, schema::SINGLE)); - _builder.reset(new DocBuilder(*_schema)); - } + SchemaContext(); + ~SchemaContext(); const document::DocumentTypeRepo::SP &getRepo() const { return _builder->getDocumentTypeRepo(); } }; +SchemaContext::SchemaContext() : + _schema(new Schema()), + _builder() +{ + _schema->addIndexField(Schema::IndexField("i1", schema::STRING, schema::SINGLE)); + _schema->addAttributeField(Schema::AttributeField("a1", schema::STRING, schema::SINGLE)); + _schema->addAttributeField(Schema::AttributeField("a2", schema::BOOLEANTREE, schema::SINGLE)); + _schema->addAttributeField(Schema::AttributeField("a3", schema::TENSOR, schema::SINGLE)); + _schema->addSummaryField(Schema::SummaryField("s1", schema::STRING, schema::SINGLE)); + _builder.reset(new DocBuilder(*_schema)); +} +SchemaContext::~SchemaContext() {} + + struct DocumentContext { Document::SP doc; @@ -461,25 +454,23 @@ struct DocumentContext BucketId bid; Timestamp ts; typedef std::vector List; - DocumentContext(const vespalib::string &docId, uint64_t timestamp, DocBuilder &builder) : - doc(builder.startDocument(docId) - .startSummaryField("s1").addStr(docId).endField() - .endDocument().release()), - upd(new DocumentUpdate(builder.getDocumentType(), doc->getId())), - bid(BucketFactory::getNumBucketBits(), - doc->getId().getGlobalId().convertToBucketId().getRawId()), - ts(timestamp) - { - } - void addFieldUpdate(DocBuilder &builder, - const vespalib::string &fieldName) { - const document::Field &field = - builder.getDocumentType().getField(fieldName); + DocumentContext(const vespalib::string &docId, uint64_t timestamp, DocBuilder &builder); + ~DocumentContext(); + void addFieldUpdate(DocBuilder &builder, const vespalib::string &fieldName) { + const document::Field &field = builder.getDocumentType().getField(fieldName); upd->addUpdate(document::FieldUpdate(field)); } document::GlobalId gid() const { return doc->getId().getGlobalId(); } }; +DocumentContext::DocumentContext(const vespalib::string &docId, uint64_t timestamp, DocBuilder &builder) + : doc(builder.startDocument(docId).startSummaryField("s1").addStr(docId).endField().endDocument().release()), + upd(new DocumentUpdate(builder.getDocumentType(), doc->getId())), + bid(BucketFactory::getNumBucketBits(), doc->getId().getGlobalId().convertToBucketId().getRawId()), + ts(timestamp) +{} +DocumentContext::~DocumentContext() {} + namespace { mbus::Reply::UP @@ -502,13 +493,15 @@ struct FeedTokenContext FeedToken ft; typedef std::shared_ptr SP; typedef std::vector List; - FeedTokenContext(MyTracer &tracer, MessageType mtype) : - mt(tracer), - ft(mt, createReply(mtype)) - { - } + FeedTokenContext(MyTracer &tracer, MessageType mtype); + ~FeedTokenContext(); }; +FeedTokenContext::FeedTokenContext(MyTracer &tracer, MessageType mtype) + : mt(tracer), ft(mt, createReply(mtype)) +{} +FeedTokenContext::~FeedTokenContext() {} + struct FixtureBase { MyTracer _tracer; @@ -529,33 +522,9 @@ struct FixtureBase CommitTimeTracker _commitTimeTracker; SerialNum serial; std::shared_ptr _gidToLidChangeHandler; - FixtureBase(TimeStamp visibilityDelay) : - _tracer(), - iw(new MyIndexWriter(_tracer)), - sa(new MySummaryAdapter), - aw(new MyAttributeWriter(_tracer)), - miw(static_cast(*iw)), - msa(static_cast(*sa)), - maw(static_cast(*aw)), - sc(), - _docIdLimit(0u), - _dmscReal(new DocumentMetaStoreContext(std::make_shared())), - _dmsc(new test::DocumentMetaStoreContextObserver(*_dmscReal)), - pc(sc._builder->getDocumentType().getName(), "fileconfig_test"), - _writeServiceReal(), - _writeService(_writeServiceReal), - _lidReuseDelayer(_writeService, _dmsc->get()), - _commitTimeTracker(visibilityDelay), - serial(0), - _gidToLidChangeHandler(std::make_shared()) - { - _dmsc->constructFreeList(); - _lidReuseDelayer.setImmediateCommit(visibilityDelay == 0); - } + FixtureBase(TimeStamp visibilityDelay); - virtual ~FixtureBase() { - _writeServiceReal.sync(); - } + virtual ~FixtureBase(); void syncMaster() { _writeService.master().sync(); @@ -720,6 +689,34 @@ struct FixtureBase } }; + +FixtureBase::FixtureBase(TimeStamp visibilityDelay) + : _tracer(), + iw(new MyIndexWriter(_tracer)), + sa(new MySummaryAdapter), + aw(new MyAttributeWriter(_tracer)), + miw(static_cast(*iw)), + msa(static_cast(*sa)), + maw(static_cast(*aw)), + sc(), + _docIdLimit(0u), + _dmscReal(new DocumentMetaStoreContext(std::make_shared())), + _dmsc(new test::DocumentMetaStoreContextObserver(*_dmscReal)), + pc(sc._builder->getDocumentType().getName(), "fileconfig_test"), + _writeServiceReal(), + _writeService(_writeServiceReal), + _lidReuseDelayer(_writeService, _dmsc->get()), + _commitTimeTracker(visibilityDelay), + serial(0), + _gidToLidChangeHandler(std::make_shared()) +{ + _dmsc->constructFreeList(); + _lidReuseDelayer.setImmediateCommit(visibilityDelay == 0); +} + +FixtureBase::~FixtureBase() { + _writeServiceReal.sync(); +} struct SearchableFeedViewFixture : public FixtureBase { SearchableFeedView fv; @@ -786,10 +783,8 @@ assertLidVector(const MyLidVector &exp, const MyLidVector &act) } void -assertAttributeUpdate(SerialNum serialNum, - const document::DocumentId &docId, - DocumentIdT lid, - MyAttributeWriter adapter) +assertAttributeUpdate(SerialNum serialNum, const document::DocumentId &docId, + DocumentIdT lid, const MyAttributeWriter & adapter) { EXPECT_EQUAL(serialNum, adapter._updateSerial); EXPECT_EQUAL(docId, adapter._updateDocId); diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp index 746a3066b2a..ebf4cb78276 100644 --- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp +++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp @@ -76,15 +76,8 @@ struct MyHandler : public ILidSpaceCompactionHandler uint32_t _wantedLidLimit; mutable uint32_t _iteratorCnt; - MyHandler() - : _stats(), - _moveFromLid(0), - _moveToLid(0), - _handleMoveCnt(0), - _wantedSubDbId(0), - _wantedLidLimit(0), - _iteratorCnt(0) - {} + MyHandler(); + ~MyHandler(); virtual vespalib::string getName() const { return "myhandler"; } @@ -113,6 +106,17 @@ struct MyHandler : public ILidSpaceCompactionHandler } }; +MyHandler::MyHandler() + : _stats(), + _moveFromLid(0), + _moveToLid(0), + _handleMoveCnt(0), + _wantedSubDbId(0), + _wantedLidLimit(0), + _iteratorCnt(0) +{} +MyHandler::~MyHandler() {} + struct MyStorer : public IOperationStorer { uint32_t _moveCnt; @@ -203,18 +207,22 @@ struct MySummaryManager : public test::DummySummaryManager struct MySubDb : public test::DummyDocumentSubDb { DocumentTypeRepo::SP _repo; - MySubDb(const DocumentTypeRepo::SP &repo, - std::shared_ptr bucketDB) - : test::DummyDocumentSubDb(bucketDB, SUBDB_ID), - _repo(repo) - { - _summaryManager.reset(new MySummaryManager()); - } + MySubDb(const DocumentTypeRepo::SP &repo, std::shared_ptr bucketDB); + ~MySubDb(); virtual IFeedView::SP getFeedView() const { return IFeedView::SP(new MyFeedView(_repo)); } }; + +MySubDb::MySubDb(const DocumentTypeRepo::SP &repo, std::shared_ptr bucketDB) + : test::DummyDocumentSubDb(bucketDB, SUBDB_ID), + _repo(repo) +{ + _summaryManager.reset(new MySummaryManager()); +} +MySubDb::~MySubDb() {} + struct MyJobRunner : public IMaintenanceJobRunner { IMaintenanceJob &_job; diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp index 7e6e7632236..910ca286b79 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp @@ -77,30 +77,11 @@ class MyDocumentSubDB const DocTypeName &_docTypeName; public: - MyDocumentSubDB(uint32_t subDBId, - SubDbType subDbType, - const document::DocumentTypeRepo::SP &repo, - std::shared_ptr bucketDB, - const DocTypeName &docTypeName) - : _docs(), - _subDBId(subDBId), - _metaStoreSP(std::make_shared(bucketDB, - DocumentMetaStore::getFixedName(), - search::GrowStrategy(), - DocumentMetaStore::IGidCompare::SP(new DocumentMetaStore::DefaultGidCompare), - subDbType)), - _metaStore(*_metaStoreSP), - _repo(repo), - _docTypeName(docTypeName) - { - _metaStore.constructFreeList(); - } + MyDocumentSubDB(uint32_t subDBId, SubDbType subDbType, const document::DocumentTypeRepo::SP &repo, + std::shared_ptr bucketDB, const DocTypeName &docTypeName); + ~MyDocumentSubDB(); - uint32_t - getSubDBId(void) const - { - return _subDBId; - } + uint32_t getSubDBId(void) const { return _subDBId; } Document::UP getDocument(DocumentIdT lid) const @@ -113,44 +94,36 @@ public: } } - MaintenanceDocumentSubDB - getSubDB(void); - - void - handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &op); - - void - handlePut(PutOperation &op); - - void - handleRemove(RemoveOperation &op); - - void - prepareMove(MoveOperation &op); - - void - handleMove(const MoveOperation &op); - - uint32_t - getNumUsedLids(void) const; - - uint32_t - getDocumentCount(void) const - { - return _docs.size(); - } + MaintenanceDocumentSubDB getSubDB(void); + void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation &op); + void handlePut(PutOperation &op); + void handleRemove(RemoveOperation &op); + void prepareMove(MoveOperation &op); + void handleMove(const MoveOperation &op); + uint32_t getNumUsedLids(void) const; + uint32_t getDocumentCount(void) const { return _docs.size(); } void setBucketState(const BucketId &bucket, bool active) { _metaStore.setBucketState(bucket, active); } - const IDocumentMetaStore & - getMetaStore() const - { - return _metaStore; - } + const IDocumentMetaStore &getMetaStore() const { return _metaStore; } }; +MyDocumentSubDB::MyDocumentSubDB(uint32_t subDBId, SubDbType subDbType, const document::DocumentTypeRepo::SP &repo, + std::shared_ptr bucketDB, const DocTypeName &docTypeName) + : _docs(), + _subDBId(subDBId), + _metaStoreSP(std::make_shared( + bucketDB, DocumentMetaStore::getFixedName(), search::GrowStrategy(), + DocumentMetaStore::IGidCompare::SP(new DocumentMetaStore::DefaultGidCompare), subDbType)), + _metaStore(*_metaStoreSP), + _repo(repo), + _docTypeName(docTypeName) +{ + _metaStore.constructFreeList(); +} +MyDocumentSubDB::~MyDocumentSubDB() {} struct MyDocumentRetriever : public DocumentRetrieverBaseForTest { diff --git a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp index e1c097fbf06..957dd7ca4da 100644 --- a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp +++ b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp @@ -898,26 +898,8 @@ struct UserDocFixture { BucketId bid2; BucketId bid3; bucketdb::BucketDBHandler _bucketDBHandler; - UserDocFixture() - : _bucketDB(createBucketDB()), - dms(_bucketDB), gids(), bid1(), bid2(), bid3(), - _bucketDBHandler(*_bucketDB) - { - _bucketDBHandler.addDocumentMetaStore(&dms, 0); - gids.push_back(createGid(10, 1)); - gids.push_back(createGid(10, 2)); - gids.push_back(createGid(20, 3)); - gids.push_back(createGid(10, 4)); - gids.push_back(createGid(10, 5)); - gids.push_back(createGid(20, 6)); - gids.push_back(createGid(20, 7)); - gids.push_back(createGid(30, 8)); // extra - gids.push_back(createGid(10, 9)); // extra - // 3 users -> 3 buckets - bid1 = BucketId(minNumBits, gids[0].convertToBucketId().getRawId()); - bid2 = BucketId(minNumBits, gids[2].convertToBucketId().getRawId()); - bid3 = BucketId(minNumBits, gids[7].convertToBucketId().getRawId()); - } + UserDocFixture(); + ~UserDocFixture(); void addGlobalId(const GlobalId &gid, uint32_t expLid, uint32_t timestampConst = 100) { uint32_t actLid = addGid(dms, gid, Timestamp(expLid + timestampConst)); EXPECT_EQUAL(expLid, actLid); @@ -928,6 +910,28 @@ struct UserDocFixture { void addGlobalIds(size_t numGids=7) __attribute__((noinline)); }; +UserDocFixture::UserDocFixture() + : _bucketDB(createBucketDB()), + dms(_bucketDB), gids(), bid1(), bid2(), bid3(), + _bucketDBHandler(*_bucketDB) +{ + _bucketDBHandler.addDocumentMetaStore(&dms, 0); + gids.push_back(createGid(10, 1)); + gids.push_back(createGid(10, 2)); + gids.push_back(createGid(20, 3)); + gids.push_back(createGid(10, 4)); + gids.push_back(createGid(10, 5)); + gids.push_back(createGid(20, 6)); + gids.push_back(createGid(20, 7)); + gids.push_back(createGid(30, 8)); // extra + gids.push_back(createGid(10, 9)); // extra + // 3 users -> 3 buckets + bid1 = BucketId(minNumBits, gids[0].convertToBucketId().getRawId()); + bid2 = BucketId(minNumBits, gids[2].convertToBucketId().getRawId()); + bid3 = BucketId(minNumBits, gids[7].convertToBucketId().getRawId()); +} +UserDocFixture::~UserDocFixture() {} + void UserDocFixture::addGlobalIds(size_t numGids) { for (size_t i = 0; i < numGids; ++i) { @@ -1142,23 +1146,26 @@ struct SplitAndJoinEmptyFixture BucketId bid36; // contained in bid10 and bid22 bucketdb::BucketDBHandler _bucketDBHandler; - SplitAndJoinEmptyFixture(void) - : dms(createBucketDB()), - bid10(1, 0), bid11(1, 1), - bid20(2, 0), bid21(2, 1), bid22(2, 2), bid23(2, 3), - bid30(3, 0), bid32(3, 2), bid34(3, 4), bid36(3, 6), - _bucketDBHandler(dms.getBucketDB()) - { - _bucketDBHandler.addDocumentMetaStore(&dms, 0); - } + SplitAndJoinEmptyFixture(); + ~SplitAndJoinEmptyFixture(); - BucketInfo - getInfo(const BucketId &bid) const - { + BucketInfo getInfo(const BucketId &bid) const { return dms.getBucketDB().takeGuard()->get(bid); } }; +SplitAndJoinEmptyFixture::SplitAndJoinEmptyFixture() + : dms(createBucketDB()), + bid10(1, 0), bid11(1, 1), + bid20(2, 0), bid21(2, 1), bid22(2, 2), bid23(2, 3), + bid30(3, 0), bid32(3, 2), bid34(3, 4), bid36(3, 6), + _bucketDBHandler(dms.getBucketDB()) +{ + _bucketDBHandler.addDocumentMetaStore(&dms, 0); +} +SplitAndJoinEmptyFixture::~SplitAndJoinEmptyFixture() {} + + struct SplitAndJoinFixture : public SplitAndJoinEmptyFixture { typedef std::map BucketMap; @@ -1172,29 +1179,8 @@ struct SplitAndJoinFixture : public SplitAndJoinEmptyFixture const GlobalIdVector *bid23Gids; const GlobalIdVector *bid30Gids; const GlobalIdVector *bid32Gids; - SplitAndJoinFixture() - : SplitAndJoinEmptyFixture(), - gids(), - bid1s(), bid2s(), bid3s(), - bid10Gids(), bid11Gids(), bid21Gids(), bid23Gids(), - bid30Gids(), bid32Gids() - { - for (uint32_t i = 1; i <= 31; ++i) { - gids.push_back(GlobalIdEntry(i)); - bid1s[gids.back().bid1].push_back(gids.back()); - bid2s[gids.back().bid2].push_back(gids.back()); - bid3s[gids.back().bid3].push_back(gids.back()); - } - ASSERT_EQUAL(2u, bid1s.size()); - ASSERT_EQUAL(4u, bid2s.size()); - ASSERT_EQUAL(8u, bid3s.size()); - bid10Gids = &bid1s[bid10]; - bid11Gids = &bid1s[bid11]; - bid21Gids = &bid2s[bid21]; - bid23Gids = &bid2s[bid23]; - bid30Gids = &bid3s[bid30]; - bid32Gids = &bid3s[bid32]; - } + SplitAndJoinFixture(); + ~SplitAndJoinFixture(); void insertGids1() { uint32_t docSize = 1; for (size_t i = 0; i < gids.size(); ++i) { @@ -1235,6 +1221,30 @@ struct SplitAndJoinFixture : public SplitAndJoinEmptyFixture } }; +SplitAndJoinFixture::SplitAndJoinFixture() + : SplitAndJoinEmptyFixture(), + gids(), + bid1s(), bid2s(), bid3s(), + bid10Gids(), bid11Gids(), bid21Gids(), bid23Gids(), + bid30Gids(), bid32Gids() +{ + for (uint32_t i = 1; i <= 31; ++i) { + gids.push_back(GlobalIdEntry(i)); + bid1s[gids.back().bid1].push_back(gids.back()); + bid2s[gids.back().bid2].push_back(gids.back()); + bid3s[gids.back().bid3].push_back(gids.back()); + } + ASSERT_EQUAL(2u, bid1s.size()); + ASSERT_EQUAL(4u, bid2s.size()); + ASSERT_EQUAL(8u, bid3s.size()); + bid10Gids = &bid1s[bid10]; + bid11Gids = &bid1s[bid11]; + bid21Gids = &bid2s[bid21]; + bid23Gids = &bid2s[bid23]; + bid30Gids = &bid3s[bid30]; + bid32Gids = &bid3s[bid32]; +} +SplitAndJoinFixture::~SplitAndJoinFixture() {} BoolVector getBoolVector(const GlobalIdVector &gids, size_t sz) @@ -1640,17 +1650,8 @@ struct RemovedFixture DocumentMetaStore dms; bucketdb::BucketDBHandler _bucketDBHandler; - RemovedFixture(void) - : _bucketDB(createBucketDB()), - dms(_bucketDB, - DocumentMetaStore::getFixedName(), - search::GrowStrategy(), - DocumentMetaStore::IGidCompare::SP(new DocumentMetaStore::DefaultGidCompare), - SubDbType::REMOVED), - _bucketDBHandler(dms.getBucketDB()) - { - _bucketDBHandler.addDocumentMetaStore(&dms, 0); - } + RemovedFixture(); + ~RemovedFixture(); BucketInfo getInfo(const BucketId &bid) const @@ -1659,6 +1660,19 @@ struct RemovedFixture } }; +RemovedFixture::RemovedFixture() + : _bucketDB(createBucketDB()), + dms(_bucketDB, + DocumentMetaStore::getFixedName(), + search::GrowStrategy(), + DocumentMetaStore::IGidCompare::SP(new DocumentMetaStore::DefaultGidCompare), + SubDbType::REMOVED), + _bucketDBHandler(dms.getBucketDB()) +{ + _bucketDBHandler.addDocumentMetaStore(&dms, 0); +} +RemovedFixture::~RemovedFixture() {} + TEST("requireThatRemoveChangedBucketWorks") { RemovedFixture f; diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index c67b1c0a1c9..ee3cb554615 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -128,18 +128,8 @@ struct MyWorld { QueryLimiter queryLimiter; EmptyConstantValueRepo constantValueRepo; - MyWorld() - : schema(), - config(), - searchContext(), - attributeContext(), - sessionManager(), - metaStore(std::make_shared()), - matchingStats(), - clock(), - queryLimiter() - { - } + MyWorld(); + ~MyWorld(); void basicSetup(size_t heapSize=10, size_t arraySize=100) { // schema @@ -360,6 +350,18 @@ struct MyWorld { }; +MyWorld::MyWorld() + : schema(), + config(), + searchContext(), + attributeContext(), + sessionManager(), + metaStore(std::make_shared()), + matchingStats(), + clock(), + queryLimiter() +{} +MyWorld::~MyWorld() {} //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- diff --git a/searchcore/src/tests/proton/server/feedstates_test.cpp b/searchcore/src/tests/proton/server/feedstates_test.cpp index 1d38fe6806a..0d9b6d66564 100644 --- a/searchcore/src/tests/proton/server/feedstates_test.cpp +++ b/searchcore/src/tests/proton/server/feedstates_test.cpp @@ -37,7 +37,8 @@ struct MyFeedView : public test::DummyFeedView { DocumentTypeRepo::SP repo_sp; int remove_handled; - MyFeedView() : repo_sp(repo.getTypeRepoSp()), remove_handled(0) {} + MyFeedView(); + ~MyFeedView(); virtual const DocumentTypeRepo::SP &getDocumentTypeRepo() const { return repo_sp; } @@ -45,6 +46,9 @@ struct MyFeedView : public test::DummyFeedView { { ++remove_handled; } }; +MyFeedView::MyFeedView() : repo_sp(repo.getTypeRepoSp()), remove_handled(0) {} +MyFeedView::~MyFeedView() {} + struct MyReplayConfig : IReplayConfig { virtual void replayConfig(SerialNum) {} virtual void replayWipeHistory(SerialNum, fastos::TimeStamp) {} @@ -68,20 +72,24 @@ struct Fixture bucketdb::BucketDBHandler _bucketDBHandler; ReplayTransactionLogState state; - Fixture() - : feed_view1(), - feed_view2(), - feed_view_ptr(&feed_view1), - replay_config(), - config_store(), - _bucketDB(), - _bucketDBHandler(_bucketDB), - state("doctypename", feed_view_ptr, _bucketDBHandler, replay_config, - config_store) - { - } + Fixture(); + ~Fixture(); }; +Fixture::Fixture() + : feed_view1(), + feed_view2(), + feed_view_ptr(&feed_view1), + replay_config(), + config_store(), + _bucketDB(), + _bucketDBHandler(_bucketDB), + state("doctypename", feed_view_ptr, _bucketDBHandler, replay_config, config_store) +{ +} +Fixture::~Fixture() {} + + struct RemoveOperationContext { DocumentId doc_id; @@ -89,19 +97,21 @@ struct RemoveOperationContext nbostream str; std::unique_ptr packet; - RemoveOperationContext(search::SerialNum serial) - : doc_id("doc:foo:bar"), - op(BucketFactory::getBucketId(doc_id), Timestamp(10), doc_id), - str(), - packet() - { - op.serialize(str); - ConstBufferRef buf(str.c_str(), str.wp()); - packet.reset(new Packet()); - packet->add(Packet::Entry(serial, FeedOperation::REMOVE, buf)); - } + RemoveOperationContext(search::SerialNum serial); + ~RemoveOperationContext(); }; +RemoveOperationContext::RemoveOperationContext(search::SerialNum serial) + : doc_id("doc:foo:bar"), + op(BucketFactory::getBucketId(doc_id), Timestamp(10), doc_id), + str(), packet() +{ + op.serialize(str); + ConstBufferRef buf(str.c_str(), str.wp()); + packet.reset(new Packet()); + packet->add(Packet::Entry(serial, FeedOperation::REMOVE, buf)); +} +RemoveOperationContext::~RemoveOperationContext() {} TEST_F("require that active FeedView can change during replay", Fixture) { RemoveOperationContext opCtx(10); diff --git a/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp b/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp index 45dd12834fe..a3e5e478c4c 100644 --- a/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp +++ b/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp @@ -90,7 +90,8 @@ private: } } public: - ContextBuilder() : _list(), _handler(new MyFlushHandler("myhandler")) {} + ContextBuilder(); + ~ContextBuilder(); void addTls(const vespalib::string &name, const flushengine::TlsStats &tlsStats) { _map[name] = tlsStats; @@ -111,6 +112,12 @@ public: } }; + +ContextBuilder::ContextBuilder() + : _list(), _handler(new MyFlushHandler("myhandler")) +{} +ContextBuilder::~ContextBuilder() {} + MyFlushTarget::SP createTargetM(const vespalib::string &name, MemoryGain memoryGain) { diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.cpp index 6cad66a094f..7bebc3d8675 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.cpp @@ -88,8 +88,9 @@ FastAccessFeedView::FastAccessFeedView(const StoreOnlyFeedView::Context &storeOn : Parent(storeOnlyCtx, params), _attributeWriter(ctx._attrWriter), _docIdLimit(ctx._docIdLimit) -{ -} +{} + +FastAccessFeedView::~FastAccessFeedView() {} void FastAccessFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op) @@ -106,9 +107,7 @@ FastAccessFeedView::forceCommit(SerialNum serialNum, OnForceCommitDoneType onCommitDone) { _attributeWriter->commit(serialNum, onCommitDone); - onCommitDone-> - registerCommittedDocIdLimit(_metaStore.getCommittedDocIdLimit(), - &_docIdLimit); + onCommitDone->registerCommittedDocIdLimit(_metaStore.getCommittedDocIdLimit(), &_docIdLimit); Parent::forceCommit(serialNum, onCommitDone); } diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.h index bdb7a8274ef..18ecb8170a6 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.h +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.h @@ -72,6 +72,7 @@ public: FastAccessFeedView(const StoreOnlyFeedView::Context &storeOnlyCtx, const PersistentParams ¶ms, const Context &ctx); + ~FastAccessFeedView(); virtual const IAttributeWriter::SP &getAttributeWriter() const { return _attributeWriter; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp index e1e7bd3a024..fb15c505c04 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp @@ -1,20 +1,16 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "searchable_feed_view.h" -#include "ireplayconfig.h" #include "forcecommitcontext.h" #include "operationdonecontext.h" #include "removedonecontext.h" -#include #include -#include #include #include -#include #include #include -#include #include + #include LOG_SETUP(".proton.server.searchable_feed_view"); @@ -36,13 +32,9 @@ using search::makeLambdaTask; namespace proton { +namespace { -namespace -{ - -bool shouldTrace(StoreOnlyFeedView::OnOperationDoneType onWriteDone, - uint32_t traceLevel) -{ +bool shouldTrace(StoreOnlyFeedView::OnOperationDoneType onWriteDone, uint32_t traceLevel) { return onWriteDone && onWriteDone->shouldTrace(traceLevel); } @@ -52,13 +44,10 @@ SearchableFeedView::Context::Context(const IIndexWriter::SP &indexWriter, const std::shared_ptr &gidToLidChangeHandler) : _indexWriter(indexWriter), _gidToLidChangeHandler(gidToLidChangeHandler) -{ -} +{} -SearchableFeedView::Context::~Context() -{ -} +SearchableFeedView::Context::~Context() {} SearchableFeedView::SearchableFeedView(const StoreOnlyFeedView::Context &storeOnlyCtx, const PersistentParams ¶ms, @@ -68,9 +57,9 @@ SearchableFeedView::SearchableFeedView(const StoreOnlyFeedView::Context &storeOn _indexWriter(ctx._indexWriter), _hasIndexedFields(_schema->getNumIndexFields() > 0), _gidToLidChangeHandler(ctx._gidToLidChangeHandler) -{ -} +{ } +SearchableFeedView::~SearchableFeedView() {} void SearchableFeedView::performSync() diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h index ccdf15ce513..c2a3eb70705 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.h @@ -107,7 +107,7 @@ public: const FastAccessFeedView::Context &fastUpdateCtx, Context ctx); - virtual ~SearchableFeedView() {} + virtual ~SearchableFeedView(); const IIndexWriter::SP &getIndexWriter() const { return _indexWriter; } const std::shared_ptr &getGidToLidChangeHandler() const { return _gidToLidChangeHandler; } void sync() override; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchview.cpp b/searchcore/src/vespa/searchcore/proton/server/searchview.cpp index 6ed9b64d13c..f7d278fbdb8 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchview.cpp @@ -1,10 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include #include "searchcontext.h" #include "searchview.h" #include -#include #include #include LOG_SETUP(".proton.server.searchview"); @@ -115,6 +113,8 @@ SearchView::SearchView(const ISummaryManager::ISummarySetup::SP & summarySetup, _matchView(matchView) { } +SearchView::~SearchView() {} + DocsumReply::UP SearchView::getDocsums(const DocsumRequest & req) { diff --git a/searchcore/src/vespa/searchcore/proton/server/searchview.h b/searchcore/src/vespa/searchcore/proton/server/searchview.h index aaed3003f33..f79ede804f2 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchview.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchview.h @@ -16,6 +16,9 @@ public: typedef std::shared_ptr SP; SearchView(const ISummaryManager::ISummarySetup::SP &summarySetup, const MatchView::SP &matchView); + SearchView(SearchView &&) = default; + SearchView &operator=(SearchView &&) = default; + ~SearchView(); const ISummaryManager::ISummarySetup::SP & getSummarySetup() const { return _summarySetup; } const MatchView::SP & getMatchView() const { return _matchView; } diff --git a/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp b/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp index 62b337bfc59..5ed1b62bfb0 100644 --- a/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp +++ b/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp @@ -73,14 +73,8 @@ struct Fixture { std::shared_ptr imported_attr; std::shared_ptr mapper_factory; - Fixture() - : target_attr(create_single_attribute(BasicType::INT32)), - reference_attr(create_reference_attribute()), - imported_attr(create_attribute_vector_from_members()), - mapper_factory(std::make_shared()) - { - reference_attr->setGidToLidMapperFactory(mapper_factory); - } + Fixture(); + ~Fixture(); void map_reference(DocId from_lid, GlobalId via_gid, DocId to_lid) { assert(from_lid < reference_attr->getNumDocs()); @@ -178,6 +172,17 @@ struct Fixture { } }; +Fixture::Fixture() + : target_attr(create_single_attribute(BasicType::INT32)), + reference_attr(create_reference_attribute()), + imported_attr(create_attribute_vector_from_members()), + mapper_factory(std::make_shared()) +{ + reference_attr->setGidToLidMapperFactory(mapper_factory); +} + +Fixture::~Fixture() {} + template void assert_multi_value_matches(const Fixture& f, DocId lid, diff --git a/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp b/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp index f5b12d5c74c..a780cbbd229 100644 --- a/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp @@ -79,17 +79,11 @@ class MyAttributeManager : public IAttributeManager { AttributeVector::SP _other; public: - MyAttributeManager(MyAttributeManager && rhs) : - IAttributeManager(), - _attribute_vector(std::move(rhs._attribute_vector)), - _other(std::move(rhs._other)) - { - } - explicit MyAttributeManager(AttributeVector *attr) - : _attribute_vector(attr), _other() {} + MyAttributeManager(MyAttributeManager && rhs); + explicit MyAttributeManager(AttributeVector *attr); - explicit MyAttributeManager(AttributeVector::SP attr) - : _attribute_vector(attr), _other() {} + explicit MyAttributeManager(AttributeVector::SP attr); + ~MyAttributeManager(); void set_other(AttributeVector::SP attr) { _other = attr; @@ -143,11 +137,8 @@ struct Result { std::vector hits; vespalib::string iterator_dump; - Result(size_t est_hits_in, bool est_empty_in) - : est_hits(est_hits_in), est_empty(est_empty_in), - has_minmax(false), min_weight(0), max_weight(0), - wand_hits(0), wand_initial_threshold(0), wand_boost_factor(0.0), - hits(), iterator_dump() {} + Result(size_t est_hits_in, bool est_empty_in); + ~Result(); void set_minmax(int32_t min, int32_t max) { has_minmax = true; @@ -156,6 +147,31 @@ struct Result { } }; +Result::Result(size_t est_hits_in, bool est_empty_in) + : est_hits(est_hits_in), est_empty(est_empty_in), has_minmax(false), min_weight(0), max_weight(0), wand_hits(0), + wand_initial_threshold(0), wand_boost_factor(0.0), hits(), iterator_dump() +{} + +Result::~Result() {} + + +MyAttributeManager::MyAttributeManager(MyAttributeManager && rhs) + : IAttributeManager(), + _attribute_vector(std::move(rhs._attribute_vector)), + _other(std::move(rhs._other)) +{} +MyAttributeManager::MyAttributeManager(AttributeVector *attr) + : _attribute_vector(attr), + _other() +{} + +MyAttributeManager::MyAttributeManager(AttributeVector::SP attr) + : _attribute_vector(std::move(attr)), + _other() +{} + +MyAttributeManager::~MyAttributeManager() {} + void extract_posting_info(Result &result, const PostingInfo *postingInfo) { if (postingInfo != NULL) { const MinMaxPostingInfo *minMax = dynamic_cast(postingInfo); diff --git a/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp b/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp index 138e406c988..32da1743343 100644 --- a/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp +++ b/searchlib/src/tests/attribute/searchcontext/searchcontext.cpp @@ -61,7 +61,8 @@ using fef::TermFieldMatchDataPosition; class DocSet : public std::set { public: - DocSet() : std::set() {} + DocSet(); + ~DocSet(); DocSet(const uint32_t *b, const uint32_t *e) : std::set(b, e) {} DocSet & put(const uint32_t &v) { insert(v); @@ -69,6 +70,9 @@ public: } }; +DocSet::DocSet() : std::set() {} +DocSet::~DocSet() {} + template class PostingList { @@ -78,7 +82,8 @@ private: DocSet _hits; public: - PostingList(V & vec, T value) : _vec(&vec), _value(value), _hits() {} + PostingList(V & vec, T value); + ~PostingList(); const V & getAttribute() const { return *_vec; } V & getAttribute() { return *_vec; } const T & getValue() const { return _value; } @@ -87,6 +92,12 @@ public: uint32_t getHitCount() const { return _hits.size(); } }; +template +PostingList::PostingList(V & vec, T value) : _vec(&vec), _value(value), _hits() {} + +template +PostingList::~PostingList() {} + class DocRange { public: @@ -608,20 +619,8 @@ void SearchContextTest::testSearch(const ConfigMap & cfgs) { template class Verifier : public search::test::SearchIteratorVerifier { public: - Verifier(T key, const vespalib::string & keyAsString, const vespalib::string & name, const Config & cfg) : - _attribute(AttributeFactory::createAttribute(name + "-initrange", cfg)), - _sc() - { - SearchContextTest::addDocs(*_attribute, getDocIdLimit()); - for (uint32_t doc : getExpectedDocIds()) { - EXPECT_TRUE(nullptr != dynamic_cast(_attribute.get())); - EXPECT_TRUE(dynamic_cast(_attribute.get())->update(doc, key)); - } - _attribute->commit(true); - _sc = SearchContextTest::getSearch(*_attribute, keyAsString); - ASSERT_TRUE(_sc->valid()); - _sc->fetchPostings(true); - } + Verifier(T key, const vespalib::string & keyAsString, const vespalib::string & name, const Config & cfg); + ~Verifier(); SearchIterator::UP create(bool strict) const override { return _sc->createIterator(&_dummy, strict); } @@ -631,6 +630,25 @@ private: SearchContextPtr _sc; }; +template +Verifier::Verifier(T key, const vespalib::string & keyAsString, const vespalib::string & name, const Config & cfg) + :_attribute(AttributeFactory::createAttribute(name + "-initrange", cfg)), + _sc() +{ + SearchContextTest::addDocs(*_attribute, getDocIdLimit()); + for (uint32_t doc : getExpectedDocIds()) { + EXPECT_TRUE(nullptr != dynamic_cast(_attribute.get())); + EXPECT_TRUE(dynamic_cast(_attribute.get())->update(doc, key)); + } + _attribute->commit(true); + _sc = SearchContextTest::getSearch(*_attribute, keyAsString); + ASSERT_TRUE(_sc->valid()); + _sc->fetchPostings(true); +} + +template +Verifier::~Verifier() {} + template void SearchContextTest::testSearchIterator(T key, const vespalib::string &keyAsString, const ConfigMap &cfgs) { diff --git a/searchlib/src/tests/btree/btreeaggregation_test.cpp b/searchlib/src/tests/btree/btreeaggregation_test.cpp index 51ff66367a1..aa3ee432df5 100644 --- a/searchlib/src/tests/btree/btreeaggregation_test.cpp +++ b/searchlib/src/tests/btree/btreeaggregation_test.cpp @@ -205,11 +205,8 @@ public: MTree _tree; MRTree _rtree; - MockTree() - : _tree(), - _rtree() - { - } + MockTree(); + ~MockTree(); void @@ -240,6 +237,12 @@ public: }; +MockTree::MockTree() + : _tree(), + _rtree() +{} +MockTree::~MockTree() {} + class MyTreeForceApplyStore : public MyTreeStore { public: diff --git a/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp b/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp index da8f8bb4abe..55d72f3aa58 100644 --- a/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp +++ b/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp @@ -68,9 +68,8 @@ public: class Verifier : public SearchIteratorVerifier { public: - Verifier(FakePosting::SP fp) : - _fp(std::move(fp)) - { } + Verifier(FakePosting::SP fp); + ~Verifier(); SearchIterator::UP create(bool strict) const override { (void) strict; return SearchIterator::UP(_fp->createIterator(_tfmda)); @@ -80,6 +79,11 @@ private: FakePosting::SP _fp; }; + Verifier::Verifier(FakePosting::SP fp) : + _fp(std::move(fp)) + { } + Verifier::~Verifier() {} + void Test::requireThatSearchIteratorsConforms() { diff --git a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp index afc0d428ee7..d3cebd9944d 100644 --- a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp +++ b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp @@ -163,29 +163,18 @@ public: bool dynamicK, uint32_t numWordIds, uint32_t docIdLimit); - - virtual void - checkPoint(void) override; - - void - earlyOpen(void); - - void - lateOpen(void); - - void - open(void); - - void - close(void); - - void - writeCheckPoint(void); - - void - readCheckPoint(bool first); + ~WrappedFieldWriter(); + + void checkPoint() override; + void earlyOpen(); + void lateOpen(); + void open(); + void close(); + void writeCheckPoint(); + void readCheckPoint(bool first); }; +WrappedFieldWriter::~WrappedFieldWriter() {} WrappedFieldWriter::WrappedFieldWriter(const vespalib::string &namepref, bool dynamicK, diff --git a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp index d58d7cc5cf8..3f42464ffe5 100644 --- a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp +++ b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp @@ -435,21 +435,8 @@ makeDoc(const DocumentTypeRepo &repo, uint32_t i, bool extra_field) class VisitCacheStore { public: - VisitCacheStore() : - _myDir("visitcache"), - _repo(makeDocTypeRepoConfig()), - _config(DocumentStore::Config(CompressionConfig::LZ4, 1000000, 0).allowVisitCaching(true), - LogDataStore::Config(50000, 0.2, 3.0, 0.2, 1, true,CompressionConfig::LZ4, - WriteableFileChunk::Config(CompressionConfig(), 16384))), - _fileHeaderContext(), - _executor(_config.getLogConfig().getNumThreads(), 128*1024), - _tlSyncer(), - _datastore(_executor, _myDir.getDir(), _config, - GrowStrategy(), TuneFileSummary(), - _fileHeaderContext, _tlSyncer, NULL), - _inserted(), - _serial(1) - { } + VisitCacheStore(); + ~VisitCacheStore(); IDocumentStore & getStore() { return _datastore; } void write(uint32_t id) { write(id, makeDoc(_repo, id, true)); @@ -481,19 +468,8 @@ public: private: class VerifyVisitor : public IDocumentVisitor { public: - VerifyVisitor(VisitCacheStore & vcs, std::vector lids, bool allowCaching) : - _vcs(vcs), - _expected(), - _actual(), - _allowVisitCaching(allowCaching) - { - for (uint32_t lid : lids) { - _expected.insert(lid); - } - } - ~VerifyVisitor() { - EXPECT_EQUAL(_expected.size(), _actual.size()); - } + VerifyVisitor(VisitCacheStore & vcs, std::vector lids, bool allowCaching); + ~VerifyVisitor(); void visit(uint32_t lid, Document::UP doc) override { EXPECT_TRUE(_expected.find(lid) != _expected.end()); EXPECT_TRUE(_actual.find(lid) == _actual.end()); @@ -518,6 +494,34 @@ private: SerialNum _serial; }; +VisitCacheStore::VerifyVisitor::VerifyVisitor(VisitCacheStore & vcs, std::vector lids, bool allowCaching) + : _vcs(vcs), _expected(), _actual(), _allowVisitCaching(allowCaching) +{ + for (uint32_t lid : lids) { + _expected.insert(lid); + } +} +VisitCacheStore::VerifyVisitor::~VerifyVisitor() { + EXPECT_EQUAL(_expected.size(), _actual.size()); +} + +VisitCacheStore::VisitCacheStore() : + _myDir("visitcache"), + _repo(makeDocTypeRepoConfig()), + _config(DocumentStore::Config(CompressionConfig::LZ4, 1000000, 0).allowVisitCaching(true), + LogDataStore::Config(50000, 0.2, 3.0, 0.2, 1, true,CompressionConfig::LZ4, + WriteableFileChunk::Config(CompressionConfig(), 16384))), + _fileHeaderContext(), + _executor(_config.getLogConfig().getNumThreads(), 128*1024), + _tlSyncer(), + _datastore(_executor, _myDir.getDir(), _config, + GrowStrategy(), TuneFileSummary(), + _fileHeaderContext, _tlSyncer, NULL), + _inserted(), + _serial(1) +{ } +VisitCacheStore::~VisitCacheStore() {} + void verifyCacheStats(CacheStats cs, size_t hits, size_t misses, size_t elements, size_t memory_used) { EXPECT_EQUAL(hits, cs.hits); diff --git a/searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp b/searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp index 963f4a58bb0..70e1d481a6c 100644 --- a/searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp +++ b/searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp @@ -21,20 +21,24 @@ struct SetupResult { RankingExpressionBlueprint rank; DummyDependencyHandler deps; bool setup_ok; - SetupResult(const TypeMap &object_inputs, - const vespalib::string &expression) - : index_env(), rank(), deps(rank), setup_ok(false) - { - rank.setName("self"); - index_env.getProperties().add("self.rankingScript", expression); - for (const auto &input: object_inputs) { - deps.define_object_input(input.first, ValueType::from_spec(input.second)); - } - setup_ok = rank.setup(index_env, {}); - EXPECT_TRUE(!deps.accept_type_mismatch); - } + SetupResult(const TypeMap &object_inputs, const vespalib::string &expression); + ~SetupResult(); }; +SetupResult::SetupResult(const TypeMap &object_inputs, + const vespalib::string &expression) + : index_env(), rank(), deps(rank), setup_ok(false) +{ + rank.setName("self"); + index_env.getProperties().add("self.rankingScript", expression); + for (const auto &input: object_inputs) { + deps.define_object_input(input.first, ValueType::from_spec(input.second)); + } + setup_ok = rank.setup(index_env, {}); + EXPECT_TRUE(!deps.accept_type_mismatch); +} +SetupResult::~SetupResult() {} + void verify_output_type(const TypeMap &object_inputs, const vespalib::string &expression, const FeatureType &expect) { diff --git a/searchlib/src/tests/fef/termfieldmodel/termfieldmodel_test.cpp b/searchlib/src/tests/fef/termfieldmodel/termfieldmodel_test.cpp index be55d64c182..86b5304e28c 100644 --- a/searchlib/src/tests/fef/termfieldmodel/termfieldmodel_test.cpp +++ b/searchlib/src/tests/fef/termfieldmodel/termfieldmodel_test.cpp @@ -1,7 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include -LOG_SETUP("termfieldmodel_test"); + #include #include #include @@ -18,13 +16,17 @@ struct State { TermFieldMatchData *f7; TermFieldMatchDataArray array; - State() : term(), md(), f3(0), f5(0), f7(0), array() {} + State(); + ~State(); void setArray(TermFieldMatchDataArray value) { array = value; } }; +State::State() : term(), md(), f3(0), f5(0), f7(0), array() {} +State::~State() {} + void testInvalidId() { const TermFieldMatchData empty; using search::queryeval::SearchIterator; diff --git a/searchlib/src/tests/grouping/grouping_test.cpp b/searchlib/src/tests/grouping/grouping_test.cpp index 28c0c080826..10fa3267c09 100644 --- a/searchlib/src/tests/grouping/grouping_test.cpp +++ b/searchlib/src/tests/grouping/grouping_test.cpp @@ -112,7 +112,8 @@ private: AggregationContext &operator=(const AggregationContext &); public: - AggregationContext() : _attrMan(), _result(), _attrCtx(_attrMan.createContext()) {} + AggregationContext(); + ~AggregationContext(); ResultBuilder &result() { return _result; } void add(AttributeVector::SP attr) { _attrMan.add(attr); @@ -122,6 +123,9 @@ public: } }; +AggregationContext::AggregationContext() : _attrMan(), _result(), _attrCtx(_attrMan.createContext()) {} +AggregationContext::~AggregationContext() {} + //----------------------------------------------------------------------------- class Test : public TestApp diff --git a/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp b/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp index b7136741a4c..4b65477224d 100644 --- a/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp +++ b/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp @@ -114,7 +114,8 @@ private: AggregationContext &operator=(const AggregationContext &); public: - AggregationContext() : _attrMan(), _result(), _attrCtx(_attrMan.createContext()) {} + AggregationContext(); + ~AggregationContext(); ResultBuilder &result() { return _result; } void add(AttributeVector::SP attr) { _attrMan.add(attr); @@ -124,6 +125,11 @@ public: } }; + +AggregationContext::AggregationContext() + : _attrMan(), _result(), _attrCtx(_attrMan.createContext()) +{} +AggregationContext::~AggregationContext() {} //----------------------------------------------------------------------------- class Test : public TestApp diff --git a/searchlib/src/tests/groupingengine/groupingengine_test.cpp b/searchlib/src/tests/groupingengine/groupingengine_test.cpp index 96963d6e320..4b2cf6a708a 100644 --- a/searchlib/src/tests/groupingengine/groupingengine_test.cpp +++ b/searchlib/src/tests/groupingengine/groupingengine_test.cpp @@ -114,7 +114,8 @@ private: AggregationContext &operator=(const AggregationContext &); public: - AggregationContext() : _attrMan(), _result(), _attrCtx(_attrMan.createContext()) {} + AggregationContext(); + ~AggregationContext(); ResultBuilder &result() { return _result; } void add(AttributeVector::SP attr) { _attrMan.add(attr); @@ -124,6 +125,9 @@ public: } }; +AggregationContext::AggregationContext() : _attrMan(), _result(), _attrCtx(_attrMan.createContext()) {} +AggregationContext::~AggregationContext() {} + //----------------------------------------------------------------------------- class Test : public TestApp diff --git a/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp b/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp index bc9822bf7f0..4ef2e4e3617 100644 --- a/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp +++ b/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp @@ -733,17 +733,8 @@ TEST_F("requireThatFeaturesAreInPostingLists", Fixture) class Verifier : public SearchIteratorVerifier { public: - Verifier(const Schema & schema) : - _tfmd(), - _dictionary(schema) - { - WrapInserter inserter(_dictionary, 0); - inserter.word("a"); - for (uint32_t docId : getExpectedDocIds()) { - inserter.add(docId); - } - inserter.flush(); - } + Verifier(const Schema & schema); + ~Verifier(); SearchIterator::UP create(bool strict) const override { (void) strict; @@ -757,6 +748,20 @@ private: Dictionary _dictionary; }; + +Verifier::Verifier(const Schema & schema) + : _tfmd(), + _dictionary(schema) +{ + WrapInserter inserter(_dictionary, 0); + inserter.word("a"); + for (uint32_t docId : getExpectedDocIds()) { + inserter.add(docId); + } + inserter.flush(); +} +Verifier::~Verifier() {} + TEST_F("require that postingiterator conforms", Fixture) { Verifier verifier(f.getSchema()); verifier.verify(); diff --git a/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp b/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp index 57e638d26a5..a1302d7de78 100644 --- a/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp +++ b/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp @@ -54,17 +54,8 @@ struct Index { uint32_t docid; std::string currentField; - Index(const Setup &setup) - : schema(setup.schema), - _executor(1, 128 * 1024), - _invertThreads(2), - _pushThreads(2), - index(schema, _invertThreads, _pushThreads), - builder(schema), - docid(1), - currentField() - { - } + Index(const Setup &setup); + ~Index(); void closeField() { if (!currentField.empty()) { builder.endField(); @@ -111,6 +102,19 @@ private: Index &operator=(const Index &index); }; + +Index::Index(const Setup &setup) + : schema(setup.schema), + _executor(1, 128 * 1024), + _invertThreads(2), + _pushThreads(2), + index(schema, _invertThreads, _pushThreads), + builder(schema), + docid(1), + currentField() +{ +} +Index::~Index() {} //----------------------------------------------------------------------------- std::string toString(SearchIterator & search) diff --git a/searchlib/src/tests/nearsearch/nearsearch_test.cpp b/searchlib/src/tests/nearsearch/nearsearch_test.cpp index 9942bcecd4a..8a20a6a27f8 100644 --- a/searchlib/src/tests/nearsearch/nearsearch_test.cpp +++ b/searchlib/src/tests/nearsearch/nearsearch_test.cpp @@ -34,12 +34,8 @@ private: std::set _data; public: - MyTerm(const std::set &doc, - const std::set &pos) - : _docs(doc), - _data(pos) - { - } + MyTerm(const std::set &doc, const std::set &pos); + ~MyTerm(); search::queryeval::Blueprint::UP make_blueprint(uint32_t fieldId, search::fef::TermFieldHandle handle) const @@ -62,6 +58,12 @@ public: } }; +MyTerm::MyTerm(const std::set &doc, const std::set &pos) + : _docs(doc), + _data(pos) +{} +MyTerm::~MyTerm() {} + class MyQuery { private: std::vector _terms; @@ -69,12 +71,8 @@ private: uint32_t _window; public: - MyQuery(bool ordered, uint32_t window) : - _terms(), - _ordered(ordered), - _window(window) { - // empty - } + MyQuery(bool ordered, uint32_t window); + ~MyQuery(); MyQuery &addTerm(MyTerm &term) { _terms.push_back(&term); @@ -98,6 +96,13 @@ public: } }; +MyQuery::MyQuery(bool ordered, uint32_t window) + : _terms(), + _ordered(ordered), + _window(window) +{} +MyQuery::~MyQuery() {} + //////////////////////////////////////////////////////////////////////////////// // // Setup diff --git a/searchlib/src/tests/queryeval/booleanmatchiteratorwrapper/booleanmatchiteratorwrapper_test.cpp b/searchlib/src/tests/queryeval/booleanmatchiteratorwrapper/booleanmatchiteratorwrapper_test.cpp index e11bec31868..bd92acaa799 100644 --- a/searchlib/src/tests/queryeval/booleanmatchiteratorwrapper/booleanmatchiteratorwrapper_test.cpp +++ b/searchlib/src/tests/queryeval/booleanmatchiteratorwrapper/booleanmatchiteratorwrapper_test.cpp @@ -121,6 +121,7 @@ TEST("mostly everything") { class Verifier : public search::test::SearchIteratorVerifier { public: + ~Verifier(); SearchIterator::UP create(bool strict) const override { return std::make_unique(createIterator(getExpectedDocIds(), strict), _tfmda);; } @@ -128,6 +129,8 @@ private: mutable TermFieldMatchDataArray _tfmda; }; +Verifier::~Verifier() {} + TEST("Test that boolean wrapper iterators adheres to SearchIterator requirements") { Verifier searchIteratorVerifier; searchIteratorVerifier.verify(); diff --git a/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp b/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp index 2339a88be5a..d82565a9ec7 100644 --- a/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp +++ b/searchlib/src/tests/queryeval/parallel_weak_and/parallel_weak_and_test.cpp @@ -87,12 +87,8 @@ struct WandTestSpec : public WandSpec MatchParams matchParams; WandTestSpec(uint32_t scoresToTrack, uint32_t scoresAdjustFrequency = 1, - score_t scoreThreshold = 0, double thresholdBoostFactor = 1) - : WandSpec(), - heap(scoresToTrack), - rootMatchData(), - matchParams(heap, scoreThreshold, thresholdBoostFactor, scoresAdjustFrequency) - {} + score_t scoreThreshold = 0, double thresholdBoostFactor = 1); + ~WandTestSpec(); SearchIterator *create() { MatchData::UP childrenMatchData = createMatchData(); MatchData *tmp = childrenMatchData.get(); @@ -104,6 +100,18 @@ struct WandTestSpec : public WandSpec } }; +template +WandTestSpec::WandTestSpec(uint32_t scoresToTrack, uint32_t scoresAdjustFrequency, + score_t scoreThreshold, double thresholdBoostFactor) + : WandSpec(), + heap(scoresToTrack), + rootMatchData(), + matchParams(heap, scoreThreshold, thresholdBoostFactor, scoresAdjustFrequency) +{} + +template +WandTestSpec::~WandTestSpec() {} + typedef WandTestSpec WandSpecWithTestHeap; typedef WandTestSpec WandSpecWithRealHeap; @@ -403,7 +411,8 @@ struct BlueprintFixtureBase { WandBlueprintSpec spec; FakeSearchable searchable; - BlueprintFixtureBase() : spec(), searchable() {} + BlueprintFixtureBase(); + ~BlueprintFixtureBase(); Blueprint::UP blueprint(const search::query::Node &term) { return spec.blueprint(searchable, "field", term); } @@ -418,6 +427,9 @@ struct BlueprintFixtureBase } }; +BlueprintFixtureBase::BlueprintFixtureBase() : spec(), searchable() {} +BlueprintFixtureBase::~BlueprintFixtureBase() {} + struct BlueprintHitsFixture : public BlueprintFixtureBase { FakeResult createResult(size_t hits) { diff --git a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp index 85fce4a8215..6f87f6befb0 100644 --- a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp +++ b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp @@ -105,17 +105,8 @@ private: bool _strict; public: - PhraseSearchTest(bool expiredDoom=false) : - _requestContext(nullptr, expiredDoom ? 0 : std::numeric_limits::max()), - _index(), - _phrase_fs(field, fieldId, phrase_handle), - _phrase(_phrase_fs, _requestContext), - _children(), - _md(MatchData::makeTestInstance(100, 10)), - _order(), - _pos(1), - _strict(false) - {} + PhraseSearchTest(bool expiredDoom=false); + ~PhraseSearchTest(); TermFieldHandle childHandle(uint32_t idx) const { return (10 * idx + 11); } @@ -186,6 +177,19 @@ public: } }; +PhraseSearchTest::PhraseSearchTest(bool expiredDoom) + : _requestContext(nullptr, expiredDoom ? 0 : std::numeric_limits::max()), + _index(), + _phrase_fs(field, fieldId, phrase_handle), + _phrase(_phrase_fs, _requestContext), + _children(), + _md(MatchData::makeTestInstance(100, 10)), + _order(), + _pos(1), + _strict(false) +{} +PhraseSearchTest::~PhraseSearchTest() {} + void Test::requireThatIteratorFindsSimplePhrase(bool useBlueprint) { PhraseSearchTest test; test.addTerm("foo", 0).addTerm("bar", 1); diff --git a/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp b/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp index 9f5faca2668..f6446c4b5cb 100644 --- a/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp +++ b/searchlib/src/tests/queryeval/sourceblender/sourceblender.cpp @@ -143,16 +143,8 @@ using search::test::SearchIteratorVerifier; class Verifier : public SearchIteratorVerifier { public: - Verifier() : - _indexes(3), - _selector(getDocIdLimit()) - { - for (uint32_t docId : getExpectedDocIds()) { - const size_t indexId = docId % _indexes.size(); - _selector.set(docId, indexId); - _indexes[indexId].push_back(docId); - } - } + Verifier(); + ~Verifier(); SearchIterator::UP create(bool strict) const override { return SearchIterator::UP(SourceBlenderSearch::create(_selector.createIterator(), createChildren(strict), @@ -171,6 +163,18 @@ private: MySelector _selector; }; +Verifier::Verifier() : + _indexes(3), + _selector(getDocIdLimit()) +{ + for (uint32_t docId : getExpectedDocIds()) { + const size_t indexId = docId % _indexes.size(); + _selector.set(docId, indexId); + _indexes[indexId].push_back(docId); + } +} +Verifier::~Verifier() {} + TEST("Test that source blender iterator adheres to SearchIterator requirements") { Verifier searchIteratorVerifier; searchIteratorVerifier.verify(); diff --git a/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp b/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp index 70e087f7c49..5a3ddc04295 100644 --- a/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp +++ b/searchlib/src/tests/queryeval/termwise_eval/termwise_eval_test.cpp @@ -81,6 +81,7 @@ struct MyBlueprint : SimpleLeafBlueprint { setEstimate(HitEstimate(hits.size(), hits.empty())); set_allow_termwise_eval(allow_termwise_eval); } + ~MyBlueprint(); SearchIterator::UP createLeafSearch(const fef::TermFieldMatchDataArray &, bool strict) const override { @@ -88,6 +89,8 @@ struct MyBlueprint : SimpleLeafBlueprint { } }; +MyBlueprint::~MyBlueprint() {} + struct MyOr : OrBlueprint { bool use_my_value; bool my_value; diff --git a/searchlib/src/tests/ranksetup/ranksetup_test.cpp b/searchlib/src/tests/ranksetup/ranksetup_test.cpp index fd34e030d33..ba676ac8e2a 100644 --- a/searchlib/src/tests/ranksetup/ranksetup_test.cpp +++ b/searchlib/src/tests/ranksetup/ranksetup_test.cpp @@ -1,7 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include -LOG_SETUP("ranksetup_test"); + #include #include @@ -98,14 +96,20 @@ private: RankProgram::UP _secondPhaseProgram; public: - RankExecutor(const vespalib::string &initRank, - const vespalib::string &finalRank, const RankEnvironment &rankEnv) : - _initRank(initRank), _finalRank(finalRank), _rankEnv(rankEnv), _layout(), - _rs(), _firstPhaseProgram(), _secondPhaseProgram() {} + RankExecutor(const vespalib::string &initRank, const vespalib::string &finalRank, const RankEnvironment &rankEnv); + ~RankExecutor(); bool setup(); RankResult execute(uint32_t docId = 1); }; +RankExecutor::RankExecutor(const vespalib::string &initRank, const vespalib::string &finalRank, + const RankEnvironment &rankEnv) + : _initRank(initRank), _finalRank(finalRank), _rankEnv(rankEnv), _layout(), + _rs(), _firstPhaseProgram(), _secondPhaseProgram() +{} + +RankExecutor::~RankExecutor() {} + bool RankExecutor::setup() { @@ -158,17 +162,21 @@ private: RankProgram::UP _rankProgram; public: - FeatureDumper(const RankEnvironment & rankEnv) : - _rankEnv(rankEnv), - _setup(_rankEnv.factory(), _rankEnv.indexEnvironment()), - _layout(), - _rankProgram() {} + FeatureDumper(const RankEnvironment & rankEnv); + ~FeatureDumper(); void addDumpFeature(const vespalib::string &name); void configure(); bool setup(); RankResult dump(); }; +FeatureDumper::FeatureDumper(const RankEnvironment & rankEnv) + : _rankEnv(rankEnv), + _setup(_rankEnv.factory(), _rankEnv.indexEnvironment()), + _layout(), + _rankProgram() +{} +FeatureDumper::~FeatureDumper() {} void FeatureDumper::addDumpFeature(const vespalib::string &name) { diff --git a/searchlib/src/tests/transactionlogstress/translogstress.cpp b/searchlib/src/tests/transactionlogstress/translogstress.cpp index 1e569f8791a..c11aa62cd21 100644 --- a/searchlib/src/tests/transactionlogstress/translogstress.cpp +++ b/searchlib/src/tests/transactionlogstress/translogstress.cpp @@ -206,13 +206,19 @@ private: public: FeederThread(const std::string & tlsSpec, const std::string & domain, - const EntryGenerator & generator, uint32_t feedRate, size_t packetSize) : - _tlsSpec(tlsSpec), _domain(domain), _client(tlsSpec), _session(), - _generator(generator), _feedRate(feedRate), _packet(packetSize), _current(1), _lastCommited(1), _timer() {} + const EntryGenerator & generator, uint32_t feedRate, size_t packetSize); + ~FeederThread(); virtual void doRun(); SerialNumRange getRange() const { return SerialNumRange(1, _lastCommited); } }; +FeederThread::FeederThread(const std::string & tlsSpec, const std::string & domain, + const EntryGenerator & generator, uint32_t feedRate, size_t packetSize) + : _tlsSpec(tlsSpec), _domain(domain), _client(tlsSpec), _session(), + _generator(generator), _feedRate(feedRate), _packet(packetSize), _current(1), _lastCommited(1), _timer() +{} +FeederThread::~FeederThread() {} + void FeederThread::commitPacket() { @@ -543,20 +549,8 @@ private: public: ControllerThread(const std::string & tlsSpec, const std::string & domain, const EntryGenerator & generator, uint32_t numSubscribers, uint32_t numVisitors, - uint64_t visitorInterval, uint64_t pruneInterval) : - _tlsSpec(tlsSpec), _domain(domain), _client(tlsSpec.c_str()), _session(), - _generator(generator), _subscribers(), _visitors(), _rndVisitors(), _visitorInterval(visitorInterval), - _pruneInterval(pruneInterval), _pruneTimer(), _begin(0), _end(0), _count(0) - { - for (uint32_t i = 0; i < numSubscribers; ++i) { - _subscribers.push_back(std::shared_ptr - (new SubscriberAgent(tlsSpec, domain, generator, 0, i, true))); - } - - for (uint32_t i = 0; i < numVisitors; ++i) { - _visitors.push_back(std::shared_ptr(new VisitorAgent(tlsSpec, domain, generator, i, true))); - } - } + uint64_t visitorInterval, uint64_t pruneInterval); + ~ControllerThread(); void startSubscribers(); uint32_t runningVisitors(); std::vector > & getSubscribers() { return _subscribers; } @@ -565,6 +559,23 @@ public: }; +ControllerThread::ControllerThread(const std::string & tlsSpec, const std::string & domain, + const EntryGenerator & generator, uint32_t numSubscribers, uint32_t numVisitors, + uint64_t visitorInterval, uint64_t pruneInterval) + : _tlsSpec(tlsSpec), _domain(domain), _client(tlsSpec.c_str()), _session(), + _generator(generator), _subscribers(), _visitors(), _rndVisitors(), _visitorInterval(visitorInterval), + _pruneInterval(pruneInterval), _pruneTimer(), _begin(0), _end(0), _count(0) +{ + for (uint32_t i = 0; i < numSubscribers; ++i) { + _subscribers.push_back(std::make_shared(tlsSpec, domain, generator, 0, i, true)); + } + + for (uint32_t i = 0; i < numVisitors; ++i) { + _visitors.push_back(std::make_shared(tlsSpec, domain, generator, i, true)); + } +} +ControllerThread::~ControllerThread() {} + void ControllerThread::getStatus() { diff --git a/searchlib/src/tests/util/bufferwriter/bufferwriter_test.cpp b/searchlib/src/tests/util/bufferwriter/bufferwriter_test.cpp index 95e4db95e03..a20cdb1e8eb 100644 --- a/searchlib/src/tests/util/bufferwriter/bufferwriter_test.cpp +++ b/searchlib/src/tests/util/bufferwriter/bufferwriter_test.cpp @@ -1,8 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include -LOG_SETUP("bufferwriter_test"); #include #include #include @@ -12,8 +9,7 @@ LOG_SETUP("bufferwriter_test"); namespace search { -namespace -{ +namespace { class StoreBufferWriter : public BufferWriter { @@ -25,15 +21,11 @@ public: static constexpr size_t BUFFER_SIZE = 262144; StoreBufferWriter(); + ~StoreBufferWriter(); - virtual ~StoreBufferWriter() = default; - - virtual void flush() override; - + void flush() override; size_t getBytesWritten() const { return _bytesWritten; } - std::vector getSingleBuffer() const; - }; @@ -47,6 +39,8 @@ StoreBufferWriter::StoreBufferWriter() setup(&_buf[0], _buf.size()); } +StoreBufferWriter::~StoreBufferWriter() {} + void StoreBufferWriter::flush() { diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakeword.h b/searchlib/src/vespa/searchlib/test/fakedata/fakeword.h index 8814bd9cf7e..23fc4ee9863 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakeword.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakeword.h @@ -12,27 +12,18 @@ #include #include -namespace search -{ +namespace search { -namespace fakedata -{ +namespace fakedata { class CheckPointCallback { public: - CheckPointCallback(void) - { - } - - virtual - ~CheckPointCallback(void) - { - } + CheckPointCallback() {} + virtual ~CheckPointCallback() {} - virtual void - checkPoint(void) = 0; + virtual void checkPoint() = 0; }; /* @@ -52,16 +43,14 @@ public: int32_t _elementWeight; uint32_t _elementLen; - inline bool - operator<(const DocWordPosFeature &rhs) const - { + bool operator<(const DocWordPosFeature &rhs) const { if (_elementId != rhs._elementId) return _elementId < rhs._elementId; return _wordPos < rhs._wordPos; } - DocWordPosFeature(void); - ~DocWordPosFeature(void); + DocWordPosFeature(); + ~DocWordPosFeature(); }; typedef std::vector DocWordPosFeatureList; @@ -69,8 +58,8 @@ public: class DocWordCollapsedFeature { public: - DocWordCollapsedFeature(void); - ~DocWordCollapsedFeature(void); + DocWordCollapsedFeature(); + ~DocWordCollapsedFeature(); }; class DocWordFeature @@ -81,8 +70,8 @@ public: uint32_t _positions; uint32_t _accPositions; // accumulated positions for previous words - DocWordFeature(void); - ~DocWordFeature(void); + DocWordFeature(); + ~DocWordFeature(); }; typedef std::vector DocWordFeatureList; @@ -93,57 +82,32 @@ public: uint32_t _random; int32_t _ref; - Randomizer(void) - : _random(0), - _ref(0) - { - } + Randomizer() : _random(0), _ref(0) {} - bool - operator<(const Randomizer &rhs) const - { + bool operator<(const Randomizer &rhs) const { if (_random != rhs._random) return _random < rhs._random; return _ref < rhs._ref; } - bool - operator==(const Randomizer &rhs) const - { + bool operator==(const Randomizer &rhs) const { return _random == rhs._random && _ref == rhs._ref; } - bool - isExtra(void) const - { - return _ref < 0; - } - - bool - isRemove(void) const - { - return isExtra() && (_ref & 1) == 0; - } - - uint32_t - extraIdx(void) const - { - return (~_ref) >> 1; - } + bool isExtra() const { return _ref < 0; } + bool isRemove() const { return isExtra() && (_ref & 1) == 0; } + uint32_t extraIdx() const { return (~_ref) >> 1; } }; class RandomizedWriter { public: - virtual - ~RandomizedWriter(void); + virtual~RandomizedWriter(); - virtual void - add(uint32_t wordIdx, index::DocIdAndFeatures &features) = 0; + virtual void add(uint32_t wordIdx, index::DocIdAndFeatures &features) = 0; - virtual void - remove(uint32_t wordIdx, uint32_t docId) = 0; + virtual void remove(uint32_t wordIdx, uint32_t docId) = 0; }; class RandomizedReader @@ -156,10 +120,8 @@ public: std::vector::const_iterator _re; index::DocIdAndPosOccFeatures _features; public: - RandomizedReader(void); - - void - read(void); + RandomizedReader(); + void read(); void write(RandomizedWriter &writer) @@ -174,11 +136,7 @@ public: } } - bool - isValid(void) const - { - return _valid; - } + bool isValid() const { return _valid; } bool operator<(const RandomizedReader &rhs) const { @@ -189,9 +147,7 @@ public: return _wordIdx < rhs._wordIdx; } - void - setup(const FakeWord *fw, - uint32_t wordIdx); + void setup(const FakeWord *fw, uint32_t wordIdx); }; DocWordFeatureList _postings; @@ -215,8 +171,7 @@ public: uint32_t docIdLimit, uint32_t tempWordDocs); - void - setupRandomizer(search::Rand48 &rnd); + void setupRandomizer(search::Rand48 &rnd); const DocWordFeature & getDocWordFeature(const Randomizer &r) const @@ -283,7 +238,7 @@ public: const PosOccFieldsParams &fieldsParams, uint32_t packedIndex); - ~FakeWord(void); + ~FakeWord(); bool validate(search::queryeval::SearchIterator *iterator, @@ -296,9 +251,7 @@ public: const fef::TermFieldMatchDataArray &matchData, bool verbose) const; - bool - validate(search::queryeval::SearchIterator *iterator, - bool verbose) const; + bool validate(search::queryeval::SearchIterator *iterator, bool verbose) const; bool validate(std::shared_ptr &fieldReader, @@ -309,11 +262,8 @@ public: uint32_t checkPointInterval, CheckPointCallback *const checkPointCallback) const; - void - validate(const std::vector &docIds) const; - - void - validate(const BitVector &bv) const; + void validate(const std::vector &docIds) const; + void validate(const BitVector &bv) const; bool dump(std::shared_ptr &fieldWriter, @@ -322,31 +272,11 @@ public: uint32_t checkPointInterval, CheckPointCallback *checkPointCallback) const; - const std::string &getName(void) const - { - return _name; - } - - uint32_t - getDocIdLimit(void) const - { - return _docIdLimit; - } - - const PosOccFieldsParams & - getFieldsParams(void) const - { - return _fieldsParams; - } - - uint32_t - getPackedIndex(void) const - { - return _packedIndex; - } - - void - addDocIdBias(uint32_t docIdBias); + const std::string &getName() const { return _name; } + uint32_t getDocIdLimit() const { return _docIdLimit; } + const PosOccFieldsParams &getFieldsParams() const { return _fieldsParams; } + uint32_t getPackedIndex() const { return _packedIndex; } + void addDocIdBias(uint32_t docIdBias); }; } // namespace fakedata diff --git a/searchsummary/src/tests/docsumformat/docsum-pack.cpp b/searchsummary/src/tests/docsumformat/docsum-pack.cpp index 3f1b088bd12..bb01027d116 100644 --- a/searchsummary/src/tests/docsumformat/docsum-pack.cpp +++ b/searchsummary/src/tests/docsumformat/docsum-pack.cpp @@ -1,15 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// Copyright (C) 2001-2003 Fast Search & Transfer ASA -// Copyright (C) 2003 Overture Services Norway AS - -#include -#include -LOG_SETUP("docsum-pack"); #include #include #include #include +#include +#include +LOG_SETUP("docsum-pack"); using namespace search::docsummary; @@ -27,13 +24,8 @@ private: search::docsummary::ResultPacker _packer; public: - MyApp() - : _rc(false), - _cnt(0u), - _config(), - _packer(&_config) - { - } + MyApp(); + ~MyApp(); // log test results void ReportTestResult(uint32_t line, bool rc); @@ -74,6 +66,13 @@ public: int Main(); }; +MyApp::MyApp() + : _rc(false), + _cnt(0u), + _config(), + _packer(&_config) +{} +MyApp::~MyApp() {} void MyApp::ReportTestResult(uint32_t line, bool rc) diff --git a/searchsummary/src/tests/docsummary/slime_summary/slime_summary_test.cpp b/searchsummary/src/tests/docsummary/slime_summary/slime_summary_test.cpp index 7a17e803ea8..806eb15b622 100644 --- a/searchsummary/src/tests/docsummary/slime_summary/slime_summary_test.cpp +++ b/searchsummary/src/tests/docsummary/slime_summary/slime_summary_test.cpp @@ -36,27 +36,8 @@ struct DocsumFixture : IDocsumStore, GetDocsumsStateCallback { std::unique_ptr writer; std::unique_ptr packer; GetDocsumsState state; - DocsumFixture() : writer(), packer(), state(*this) { - ResultConfig *config = new ResultConfig(); - ResultClass *cfg = config->AddResultClass("default", 0); - EXPECT_TRUE(cfg != 0); - EXPECT_TRUE(cfg->AddConfigEntry("int_field", RES_INT)); - EXPECT_TRUE(cfg->AddConfigEntry("short_field", RES_SHORT)); - EXPECT_TRUE(cfg->AddConfigEntry("byte_field", RES_BYTE)); - EXPECT_TRUE(cfg->AddConfigEntry("float_field", RES_FLOAT)); - EXPECT_TRUE(cfg->AddConfigEntry("double_field", RES_DOUBLE)); - EXPECT_TRUE(cfg->AddConfigEntry("int64_field", RES_INT64)); - EXPECT_TRUE(cfg->AddConfigEntry("string_field", RES_STRING)); - EXPECT_TRUE(cfg->AddConfigEntry("data_field", RES_DATA)); - EXPECT_TRUE(cfg->AddConfigEntry("longstring_field", RES_LONG_STRING)); - EXPECT_TRUE(cfg->AddConfigEntry("longdata_field", RES_LONG_DATA)); - EXPECT_TRUE(cfg->AddConfigEntry("xmlstring_field", RES_XMLSTRING)); - EXPECT_TRUE(cfg->AddConfigEntry("jsonstring_field", RES_JSONSTRING)); - EXPECT_TRUE(cfg->AddConfigEntry("bad_jsonstring_field", RES_JSONSTRING)); - config->CreateEnumMaps(); - writer.reset(new DynamicDocsumWriter(config, 0)); - packer.reset(new ResultPacker(writer->GetResultConfig())); - } + DocsumFixture(); + ~DocsumFixture(); void getDocsum(Slime &slime) { uint32_t classId; search::RawBuf buf(4096); @@ -102,6 +83,32 @@ struct DocsumFixture : IDocsumStore, GetDocsumsStateCallback { void ParseLocation(GetDocsumsState *) override { } }; + +DocsumFixture::DocsumFixture() + : writer(), packer(), state(*this) +{ + ResultConfig *config = new ResultConfig(); + ResultClass *cfg = config->AddResultClass("default", 0); + EXPECT_TRUE(cfg != 0); + EXPECT_TRUE(cfg->AddConfigEntry("int_field", RES_INT)); + EXPECT_TRUE(cfg->AddConfigEntry("short_field", RES_SHORT)); + EXPECT_TRUE(cfg->AddConfigEntry("byte_field", RES_BYTE)); + EXPECT_TRUE(cfg->AddConfigEntry("float_field", RES_FLOAT)); + EXPECT_TRUE(cfg->AddConfigEntry("double_field", RES_DOUBLE)); + EXPECT_TRUE(cfg->AddConfigEntry("int64_field", RES_INT64)); + EXPECT_TRUE(cfg->AddConfigEntry("string_field", RES_STRING)); + EXPECT_TRUE(cfg->AddConfigEntry("data_field", RES_DATA)); + EXPECT_TRUE(cfg->AddConfigEntry("longstring_field", RES_LONG_STRING)); + EXPECT_TRUE(cfg->AddConfigEntry("longdata_field", RES_LONG_DATA)); + EXPECT_TRUE(cfg->AddConfigEntry("xmlstring_field", RES_XMLSTRING)); + EXPECT_TRUE(cfg->AddConfigEntry("jsonstring_field", RES_JSONSTRING)); + EXPECT_TRUE(cfg->AddConfigEntry("bad_jsonstring_field", RES_JSONSTRING)); + config->CreateEnumMaps(); + writer.reset(new DynamicDocsumWriter(config, 0)); + packer.reset(new ResultPacker(writer->GetResultConfig())); +} +DocsumFixture::~DocsumFixture() {} + } // namespace TEST_FF("require that docsum can be written as slime", DocsumFixture(), Slime()) { diff --git a/storage/src/vespa/storage/tools/analyzedistribution.cpp b/storage/src/vespa/storage/tools/analyzedistribution.cpp index b2b95c15d30..0368e46c668 100644 --- a/storage/src/vespa/storage/tools/analyzedistribution.cpp +++ b/storage/src/vespa/storage/tools/analyzedistribution.cpp @@ -23,42 +23,40 @@ struct Options : public vespalib::ProgramOptions { double redundancy; std::string testdir; - Options(int argc, const char* const* argv) - : vespalib::ProgramOptions(argc, argv), - showSyntaxPage(false), - systemState(""), - numDisks(0), - diskDistribution(1), - redundancy(2.0) - { - setSyntaxMessage( - "Analyzes distribution from a real cluster. " - "This tool reads gzipped files containing directory " - "listings from a live system and analyze how current " - "distribution and ideal distribution is in that cluster." - "The tool is typically run from the perl check_cluster script " - "to create raw data for further analysis of cluster " - "distribution." - ); - addOption("h help", showSyntaxPage, false, - "Shows this help page"); - addOption("v verbose", verbose, false, - "Show verbose progress"); - addOption("c clusterstate", systemState, - "Cluster state to use for ideal state calculations"); - addOption("n numdisks", numDisks, - "The number of disks on each node"); - addOption("r redundancy", redundancy, 2.0, - "The redundancy used"); - addOption("d distribution", diskDistribution, 1, - "The disk distribution to use (0 = MODULO, 1 = " - "MODULO_INDEX, 2 = MODULO_KNUTH, 3 = MODULO_BID"); - addArgument("Test directory", testdir, std::string("."), - "The directory within to find gzipped file listings named " - "storage.*.shell.filelist.gz"); - } + Options(int argc, const char* const* argv); + ~Options(); }; +Options::Options(int argc, const char* const* argv) + : vespalib::ProgramOptions(argc, argv), + showSyntaxPage(false), + systemState(""), + numDisks(0), + diskDistribution(1), + redundancy(2.0) +{ + setSyntaxMessage("Analyzes distribution from a real cluster. " + "This tool reads gzipped files containing directory " + "listings from a live system and analyze how current " + "distribution and ideal distribution is in that cluster." + "The tool is typically run from the perl check_cluster script " + "to create raw data for further analysis of cluster " + "distribution." + ); + addOption("h help", showSyntaxPage, false, "Shows this help page"); + addOption("v verbose", verbose, false, "Show verbose progress"); + addOption("c clusterstate", systemState, "Cluster state to use for ideal state calculations"); + addOption("n numdisks", numDisks, "The number of disks on each node"); + addOption("r redundancy", redundancy, 2.0, "The redundancy used"); + addOption("d distribution", diskDistribution, 1, + "The disk distribution to use (0 = MODULO, 1 = MODULO_INDEX, 2 = MODULO_KNUTH, 3 = MODULO_BID"); + addArgument("Test directory", testdir, std::string("."), + "The directory within to find gzipped file listings named storage.*.shell.filelist.gz"); +} +Options::~Options() {} + + + struct Disk { struct Count { uint32_t bucketCount; @@ -111,16 +109,8 @@ struct Node { std::vector disks; Disk::Count distributor; - Node(const lib::NodeState& dstate, const lib::NodeState& sstate, - uint32_t diskCount) - : distributorState(dstate), - storageState(sstate), - disks() - { - for (uint32_t i=0; i nodes; enum Type { INDEX, BID, TEST }; diff --git a/storage/src/vespa/storage/tools/generatedistributionbits.cpp b/storage/src/vespa/storage/tools/generatedistributionbits.cpp index 1acbc7e899c..53c7c7cf1a1 100644 --- a/storage/src/vespa/storage/tools/generatedistributionbits.cpp +++ b/storage/src/vespa/storage/tools/generatedistributionbits.cpp @@ -1,15 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include #include #include #include #include -#include #include -#include #include #include -#include #include namespace storage { @@ -30,34 +26,8 @@ namespace storage { uint32_t skipNodeCountsBelow; uint32_t startAtNodeCount; - Options(int argc, const char* const* argv) - : vespalib::ProgramOptions(argc, argv) - { - setSyntaxMessage( - "Utility program for calculating skew of buckets stored on " - "storage nodes." - ); - addOption("r redundancy", redundancy, 2u, - "Number of copies stored on the nodes."); - addOption("b maxbit", maxBit, 32u, - "Maximum distribution bit count to calculate for."); - addOption("h hide", hideUtilizationAbove, 0.3, - "Hide utilizations worse than this."); - addOption("s skip", skipGood, false, - "Attempt to skip computations for node counts that " - "already have good distributions"); - addOption("highrange", highRange, false, - "Compute distribution for large systems instead of small " - "systems"); - addOption("html", printHtml, false, - "Print result as an HTML table"); - addOption("skipbitsbelow", skipBitsBelow, 0u, - "Skip calculating for bits below given value"); - addOption("skipnodecountsbelow", skipNodeCountsBelow, 0u, - "Skip calculating for node counts below given value"); - addOption("startatnodecount", startAtNodeCount, 0u, - "Start calculating for first bit at given node count"); - } + Options(int argc, const char* const* argv); + ~Options(); void finalize() { if (highRange) { @@ -118,6 +88,32 @@ namespace storage { } } + +Options::Options(int argc, const char* const* argv) + : vespalib::ProgramOptions(argc, argv) +{ + setSyntaxMessage("Utility program for calculating skew of buckets stored on storage nodes."); + addOption("r redundancy", redundancy, 2u, + "Number of copies stored on the nodes."); + addOption("b maxbit", maxBit, 32u, + "Maximum distribution bit count to calculate for."); + addOption("h hide", hideUtilizationAbove, 0.3, + "Hide utilizations worse than this."); + addOption("s skip", skipGood, false, + "Attempt to skip computations for node counts that already have good distributions"); + addOption("highrange", highRange, false, + "Compute distribution for large systems instead of small systems"); + addOption("html", printHtml, false, + "Print result as an HTML table"); + addOption("skipbitsbelow", skipBitsBelow, 0u, + "Skip calculating for bits below given value"); + addOption("skipnodecountsbelow", skipNodeCountsBelow, 0u, + "Skip calculating for node counts below given value"); + addOption("startatnodecount", startAtNodeCount, 0u, + "Start calculating for first bit at given node count"); +} +Options::~Options() {} + } // storage int main(int argc, char** argv) { diff --git a/storage/src/vespa/storage/tools/getidealstate.cpp b/storage/src/vespa/storage/tools/getidealstate.cpp index c3c7a4ba480..e221ce686e4 100644 --- a/storage/src/vespa/storage/tools/getidealstate.cpp +++ b/storage/src/vespa/storage/tools/getidealstate.cpp @@ -25,42 +25,8 @@ struct Options : public vespalib::ProgramOptions { bool bucketsOnStdIn; bool verbose; - Options(int argc, const char* const* argv) - : vespalib::ProgramOptions(argc, argv) - { - setSyntaxMessage( - "Utility program for calculating the ideal state of " - "buckets. Useful to verify correctness of distribution " - "operations." - ); - addOption("h help", showSyntaxPage, false, - "Shows this help page"); - addOption("s clusterstate", clusterState, std::string(""), - "The state of the cluster to calculate position in"); - addOption("n diskcount", diskCount, uint32_t(0), - "The number of disks on each node"); - addOption("r redundancy", redundancy, uint32_t(2), - "The redundancy to keep for each bucket"); - addOption("diskdistribution", diskDistribution, - std::string("MODULO_BID"), - "Disk distribution algorithm used"); - addOption("u upstates", upStates, std::string("uims"), - "States to consider as up in ideal state calculations"); - addOption("i stdin", bucketsOnStdIn, false, - "Read stdin to get buckets to calculate ideal position for"); - addOption("v verbose", verbose, false, - "Print extra information while running"); - addArgument("bucket", bucket, std::string(""), - "Bucket for which to calculate ideal state"); - - addOptionHeader( - "By default, it will be assumed that all nodes are in one top " - "group, and no config will be read to calculate bucket " - "positions. If a cluster name is specified, config will be " - "read to get group hierarchy correctly for cluster."); - addOption("c clustername", clusterName, std::string(""), - "Name of the cluster to get config from"); - } + Options(int argc, const char* const* argv); + ~Options(); bool useConfig() const { return !clusterName.empty(); } @@ -71,6 +37,39 @@ struct Options : public vespalib::ProgramOptions { } }; +Options::Options(int argc, const char* const* argv) + : vespalib::ProgramOptions(argc, argv) +{ + setSyntaxMessage("Utility program for calculating the ideal state of buckets." + " Useful to verify correctness of distribution operations."); + addOption("h help", showSyntaxPage, false, + "Shows this help page"); + addOption("s clusterstate", clusterState, std::string(""), + "The state of the cluster to calculate position in"); + addOption("n diskcount", diskCount, uint32_t(0), + "The number of disks on each node"); + addOption("r redundancy", redundancy, uint32_t(2), + "The redundancy to keep for each bucket"); + addOption("diskdistribution", diskDistribution, std::string("MODULO_BID"), + "Disk distribution algorithm used"); + addOption("u upstates", upStates, std::string("uims"), + "States to consider as up in ideal state calculations"); + addOption("i stdin", bucketsOnStdIn, false, + "Read stdin to get buckets to calculate ideal position for"); + addOption("v verbose", verbose, false, + "Print extra information while running"); + addArgument("bucket", bucket, std::string(""), + "Bucket for which to calculate ideal state"); + addOptionHeader("By default, it will be assumed that all nodes are in one top " + "group, and no config will be read to calculate bucket " + "positions. If a cluster name is specified, config will be " + "read to get group hierarchy correctly for cluster."); + addOption("c clustername", clusterName, std::string(""), + "Name of the cluster to get config from"); +} +Options::~Options() {} + + void processBucket(const lib::Distribution& distribution, const lib::ClusterState& clusterState, const std::string& upStates, diff --git a/storage/src/vespa/storage/tools/statfs.cpp b/storage/src/vespa/storage/tools/statfs.cpp index d23a3037a7a..29cedc97bbc 100644 --- a/storage/src/vespa/storage/tools/statfs.cpp +++ b/storage/src/vespa/storage/tools/statfs.cpp @@ -1,7 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include #include #include #include @@ -11,18 +9,23 @@ struct Options : public vespalib::ProgramOptions { bool showSyntaxPage; std::string _filename; - Options(int argc, const char* const* argv) - : vespalib::ProgramOptions(argc, argv), - showSyntaxPage(false) - { - setSyntaxMessage( - "Utility program for checking output of statfs." - ); - addOption("h help", showSyntaxPage, false, - "Shows this help page"); - addArgument("file", _filename, "File to use when calling statfs()"); - } - }; + Options(int argc, const char* const* argv); + ~Options(); +}; + +Options::Options(int argc, const char* const* argv) + : vespalib::ProgramOptions(argc, argv), + showSyntaxPage(false) +{ + setSyntaxMessage( + "Utility program for checking output of statfs." + ); + addOption("h help", showSyntaxPage, false, + "Shows this help page"); + addArgument("file", _filename, "File to use when calling statfs()"); +} +Options::~Options() {} + int main(int argc, char** argv) { Options o(argc, argv); diff --git a/storage/src/vespa/storage/tools/throttlingsim.h b/storage/src/vespa/storage/tools/throttlingsim.h index 765b007ab99..9135507c0d3 100644 --- a/storage/src/vespa/storage/tools/throttlingsim.h +++ b/storage/src/vespa/storage/tools/throttlingsim.h @@ -50,13 +50,17 @@ public: int lastOk; int meanwaitms; - Messaging(int meanwait) : lastOk(0), meanwaitms(meanwait) {}; + Messaging(int meanwait); + ~Messaging(); void sendMessage(const Message& m); void print(); void run(); }; +Messaging::Messaging(int meanwait) : lastOk(0), meanwaitms(meanwait) {} +Messaging::~Messaging() {} + class Client : public document::Runnable { public: vespalib::Monitor sync; @@ -74,10 +78,14 @@ public: virtual void run(); virtual void print(double timenow); - Client(Messaging& msgng, double windowSize, int to) : - ok(0), failed(0), busy(0), pending(0), windowsize(windowSize), messaging(msgng), timeout(to), max_diff(0) {} + Client(Messaging& msgng, double windowSize, int to); + ~Client(); }; +Client::Client(Messaging& msgng, double windowSize, int to) + : ok(0), failed(0), busy(0), pending(0), windowsize(windowSize), messaging(msgng), timeout(to), max_diff(0) +{} +Client::~Client() {} class FixedClient : public Client { public: diff --git a/storageserver/src/apps/storaged/storage.cpp b/storageserver/src/apps/storaged/storage.cpp index fca37df0123..255895c8c72 100644 --- a/storageserver/src/apps/storaged/storage.cpp +++ b/storageserver/src/apps/storaged/storage.cpp @@ -65,6 +65,7 @@ class StorageApp : public FastOS_Application, public: StorageApp(); + ~StorageApp(); void handleSignal(int signal) { LOG(info, "Got signal %d, waiting for lock", signal); @@ -101,6 +102,8 @@ StorageApp::StorageApp() "abruptly killing the process."); } +StorageApp::~StorageApp() {} + bool StorageApp::Init() { FastOS_Application::Init(); diff --git a/storageserver/src/tests/storageservertest.cpp b/storageserver/src/tests/storageservertest.cpp index 62a96ea8111..feff39fb8d4 100644 --- a/storageserver/src/tests/storageservertest.cpp +++ b/storageserver/src/tests/storageservertest.cpp @@ -85,6 +85,9 @@ struct StorageServerTest : public CppUnit::TestFixture { std::unique_ptr storConfig; std::unique_ptr slobrokMirror; + StorageServerTest(); + ~StorageServerTest(); + void setUp(); void tearDown(); @@ -118,6 +121,9 @@ struct StorageServerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE_END(); }; +StorageServerTest::StorageServerTest() {} +StorageServerTest::~StorageServerTest() {} + CPPUNIT_TEST_SUITE_REGISTRATION(StorageServerTest); namespace { @@ -157,12 +163,8 @@ namespace { struct Distributor : public Node { DistributorProcess _process; - Distributor(vdstestlib::DirConfig& config) - : _process(config.getConfigId()) - { - _process.setupConfig(60000); - _process.createNode(); - } + Distributor(vdstestlib::DirConfig& config); + ~Distributor(); virtual StorageNode& getNode() { return _process.getNode(); } virtual StorageNodeContext& getContext() @@ -173,13 +175,8 @@ namespace { MemFileServiceLayerProcess _process; StorageComponent::UP _component; - Storage(vdstestlib::DirConfig& config) : _process(config.getConfigId()) - { - _process.setupConfig(60000); - _process.createNode(); - _component.reset(new StorageComponent( - getContext().getComponentRegister(), "test")); - } + Storage(vdstestlib::DirConfig& config); + ~Storage(); virtual StorageNode& getNode() { return _process.getNode(); } virtual StorageNodeContext& getContext() @@ -189,6 +186,25 @@ namespace { uint16_t getDiskCount() { return getPartitions().size(); } StorageComponent& getComponent() { return *_component; } }; + +Distributor::Distributor(vdstestlib::DirConfig& config) + : _process(config.getConfigId()) +{ + _process.setupConfig(60000); + _process.createNode(); +} +Distributor::~Distributor() {} + +Storage::Storage(vdstestlib::DirConfig& config) + : _process(config.getConfigId()) +{ + _process.setupConfig(60000); + _process.createNode(); + _component.reset(new StorageComponent( + getContext().getComponentRegister(), "test")); +} +Storage::~Storage() {} + } void diff --git a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp index f1d58259879..fe6f2ff396c 100644 --- a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp +++ b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp @@ -14,6 +14,10 @@ DistributorProcess::DistributorProcess(const config::ConfigUri & configUri) { } +DistributorProcess::~DistributorProcess() { + shutdown(); +} + void DistributorProcess::shutdown() { diff --git a/storageserver/src/vespa/storageserver/app/distributorprocess.h b/storageserver/src/vespa/storageserver/app/distributorprocess.h index 32472a68793..c2193783e3d 100644 --- a/storageserver/src/vespa/storageserver/app/distributorprocess.h +++ b/storageserver/src/vespa/storageserver/app/distributorprocess.h @@ -22,7 +22,7 @@ class DistributorProcess : public Process { public: DistributorProcess(const config::ConfigUri & configUri); - ~DistributorProcess() { shutdown(); } + ~DistributorProcess(); virtual void shutdown(); diff --git a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp index 37a2b981063..a320b7613e2 100644 --- a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp +++ b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp @@ -85,87 +85,8 @@ struct Options : public vespalib::ProgramOptions { std::string _doc; uint32_t _slobrokTimeout; - Options(Mode mode) : _mode(mode), _cluster("", ""), _nodeIndex(0xffffffff), _nonfriendlyOutput(false), _slobrokTimeout(0) { - _doc = "https://yahoo.github.io/vespa/"; - if (_mode == SETNODESTATE) { - setSyntaxMessage( - "Set the wanted node state of a storage node. This will " - "override the state the node is in in the cluster state, if " - "the current state is \"better\" than the wanted state. " - "For instance, a node that is currently in initializing state " - "can be forced into down state, while a node that is currently" - " down can not be forced into retired state, but can be forced" - " into maintenance state.\n\n" - "For more info on states refer to\n" + _doc - ); - } else if (_mode == GETCLUSTERSTATE) { - setSyntaxMessage( - "Get the cluster state of a given cluster.\n\n" - "For more info on states refer to\n" + _doc - ); - } else { - setSyntaxMessage( - "Retrieve the state of a one or more storage services from the " - "fleet controller. Will list the state of the locally running " - "services, possibly restricted to less by options.\n\n" - "The result will show the slobrok address of the service, and " - "three states. The first state will show how the state of that " - "given service looks in the current cluster state. This state " - "is the state the fleetcontroller is reporting to all nodes " - "in the cluster this service is in. The second state is the " - "reported state, which is the state the given node is reporting" - " to be in itself. The third state is the wanted state, which " - "is the state we want the node to be in. In most cases this " - "should be the up state, but in some cases the fleet controller" - " or an administrator may have set the wanted state otherwise, " - "in order to get problem nodes out of the cluster.\n\n" - "For more info on states refer to\n" + _doc - ); - } - addOption("h help", _showSyntax, false, - "Show this help page."); - - addOption("c cluster", _clusterName, std::string("storage"), - "Which cluster to connect to. By default it will attempt to " - "connect to cluster named 'storage'."); - if (_mode != GETCLUSTERSTATE) { - addOption("t type", _nodeType, std::string(""), - "Node type to query. This can either be 'storage' or " - "'distributor'. If not specified, the operation will " - "affect both types."); - addOption("i index", _nodeIndex, uint32_t(0xffffffff), - "The node index of the distributor or storage node to " - "contact. If not specified, all indexes running locally " - "on this node will be queried"); - } - if (_mode != SETNODESTATE) { - addOption("r raw", _nonfriendlyOutput, false, - "Show the serialized state formats directly instead of " - "reformatting them to look more user friendly."); - } - if (_mode == SETNODESTATE) { - addArgument("Wanted state", _state, "Wanted state to set node in. " - "This must be one of up, down or maintenance. Or if " - "it's not a distributor it can also be retired."); - addArgument("Reason", _message, std::string(""), - "Give a reason for why you're altering the wanted " - "state, which will show up in various admin tools. " - "(Use double quotes to give a reason with whitespace " - "in it)"); - } - addOptionHeader("Advanced options. Not needed for most usecases"); - addOption("l slobrokconfig", _slobrokConfigId, - std::string("admin/slobrok.0"), - "Config id of slobrok. Will use the default config id of " - "admin/slobrok.0 if not specified."); - addOption("p slobrokspec", _slobrokConnectionSpec, std::string(""), - "Slobrok connection spec. By setting this, this application " - "will not need config at all, but will use the given " - "connection spec to talk with slobrok."); - addOption("s slobroktimeout", _slobrokTimeout, uint32_t(5 * 60), - "Seconds to wait for slobrok client to connect to a slobrok " - "server before failing."); - } + Options(Mode mode); + ~Options(); bool validate() { if (_nodeType != "" @@ -211,6 +132,90 @@ struct Options : public vespalib::ProgramOptions { } }; +Options::Options(Mode mode) + : _mode(mode), _cluster("", ""), _nodeIndex(0xffffffff), _nonfriendlyOutput(false), _slobrokTimeout(0) +{ + _doc = "https://yahoo.github.io/vespa/"; + if (_mode == SETNODESTATE) { + setSyntaxMessage( + "Set the wanted node state of a storage node. This will " + "override the state the node is in in the cluster state, if " + "the current state is \"better\" than the wanted state. " + "For instance, a node that is currently in initializing state " + "can be forced into down state, while a node that is currently" + " down can not be forced into retired state, but can be forced" + " into maintenance state.\n\n" + "For more info on states refer to\n" + _doc + ); + } else if (_mode == GETCLUSTERSTATE) { + setSyntaxMessage( + "Get the cluster state of a given cluster.\n\n" + "For more info on states refer to\n" + _doc + ); + } else { + setSyntaxMessage( + "Retrieve the state of a one or more storage services from the " + "fleet controller. Will list the state of the locally running " + "services, possibly restricted to less by options.\n\n" + "The result will show the slobrok address of the service, and " + "three states. The first state will show how the state of that " + "given service looks in the current cluster state. This state " + "is the state the fleetcontroller is reporting to all nodes " + "in the cluster this service is in. The second state is the " + "reported state, which is the state the given node is reporting" + " to be in itself. The third state is the wanted state, which " + "is the state we want the node to be in. In most cases this " + "should be the up state, but in some cases the fleet controller" + " or an administrator may have set the wanted state otherwise, " + "in order to get problem nodes out of the cluster.\n\n" + "For more info on states refer to\n" + _doc + ); + } + addOption("h help", _showSyntax, false, + "Show this help page."); + + addOption("c cluster", _clusterName, std::string("storage"), + "Which cluster to connect to. By default it will attempt to connect to cluster named 'storage'."); + if (_mode != GETCLUSTERSTATE) { + addOption("t type", _nodeType, std::string(""), + "Node type to query. This can either be 'storage' or " + "'distributor'. If not specified, the operation will " + "affect both types."); + addOption("i index", _nodeIndex, uint32_t(0xffffffff), + "The node index of the distributor or storage node to " + "contact. If not specified, all indexes running locally " + "on this node will be queried"); + } + if (_mode != SETNODESTATE) { + addOption("r raw", _nonfriendlyOutput, false, + "Show the serialized state formats directly instead of " + "reformatting them to look more user friendly."); + } + if (_mode == SETNODESTATE) { + addArgument("Wanted state", _state, + "Wanted state to set node in. " + "This must be one of up, down or maintenance. Or if " + "it's not a distributor it can also be retired."); + addArgument("Reason", _message, std::string(""), + "Give a reason for why you're altering the wanted " + "state, which will show up in various admin tools. " + "(Use double quotes to give a reason with whitespace " + "in it)"); + } + addOptionHeader("Advanced options. Not needed for most usecases"); + addOption("l slobrokconfig", _slobrokConfigId, + std::string("admin/slobrok.0"), + "Config id of slobrok. Will use the default config id of admin/slobrok.0 if not specified."); + addOption("p slobrokspec", _slobrokConnectionSpec, std::string(""), + "Slobrok connection spec. By setting this, this application " + "will not need config at all, but will use the given " + "connection spec to talk with slobrok."); + addOption("s slobroktimeout", _slobrokTimeout, uint32_t(5 * 60), + "Seconds to wait for slobrok client to connect to a slobrok server before failing."); +} +Options::~Options() {} + + struct StateApp : public FastOS_Application { Options _options; diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp b/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp index c5d29b23d99..e9482c1eddc 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp +++ b/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp @@ -26,11 +26,12 @@ Application::Application() : _net(), _mbus(), _params() -{ - // empty -} +{ } + +Application::~Application() {} + -int + int Application::Main() { try { diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/application.h b/vespaclient/src/vespa/vespaclient/vesparoute/application.h index 215ffaecfcf..c4f9d0ef047 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/application.h +++ b/vespaclient/src/vespa/vespaclient/vesparoute/application.h @@ -66,6 +66,7 @@ private: public: /** Null member variables. */ Application(); + ~Application(); // Inherit doc from FastOS_Application. int Main(); diff --git a/vsm/src/tests/searcher/searcher.cpp b/vsm/src/tests/searcher/searcher.cpp index d1c1cd2060b..fbbc8796a7c 100644 --- a/vsm/src/tests/searcher/searcher.cpp +++ b/vsm/src/tests/searcher/searcher.cpp @@ -68,9 +68,8 @@ public: QueryNodeResultFactory eqnr; std::vector qtv; QueryTermList qtl; - Query(const StringList & terms) : eqnr(), qtv(), qtl() { - setupQuery(terms); - } + Query(const StringList & terms); + ~Query(); static ParsedQueryTerm parseQueryTerm(const std::string & queryTerm) { size_t i = queryTerm.find(':'); if (i != std::string::npos) { @@ -91,23 +90,30 @@ public: } }; +Query::Query(const StringList & terms) : eqnr(), qtv(), qtl() { + setupQuery(terms); +} +Query::~Query() {} + struct SnippetModifierSetup { Query query; UTF8SubstringSnippetModifier::SP searcher; SharedSearcherBuf buf; SnippetModifier modifier; - explicit SnippetModifierSetup(const StringList & terms) : - query(terms), - searcher(new UTF8SubstringSnippetModifier()), - buf(new SearcherBuf(8)), - modifier(searcher) - { - searcher->prepare(query.qtl, buf); - } + explicit SnippetModifierSetup(const StringList & terms); + ~SnippetModifierSetup(); }; - +SnippetModifierSetup::SnippetModifierSetup(const StringList & terms) + : query(terms), + searcher(new UTF8SubstringSnippetModifier()), + buf(new SearcherBuf(8)), + modifier(searcher) +{ + searcher->prepare(query.qtl, buf); +} +SnippetModifierSetup::~SnippetModifierSetup() {} // helper functions ArrayFieldValue getFieldValue(const StringList &fv); -- cgit v1.2.3