diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-03-09 14:59:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-09 14:59:47 +0100 |
commit | 9e57bebcf1683230c402a769567d5f78566debdf (patch) | |
tree | 0129a73081cfb61af12018c5954c6641e89df8e8 | |
parent | 853cff57ce2ff6f1760bfe363118d24f3cd5fcb4 (diff) | |
parent | 27821c298d6f61b025e400812cdd71871c1e3982 (diff) |
Merge pull request #1973 from yahoo/balder/deinline-destructors-2
Balder/deinline destructors 2
365 files changed, 4421 insertions, 2981 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/config/src/apps/configproxy-cmd/flags.h b/config/src/apps/configproxy-cmd/flags.h deleted file mode 100644 index ce64889256b..00000000000 --- a/config/src/apps/configproxy-cmd/flags.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include <vespa/vespalib/stllike/string.h> -#include <vector> - -struct Flags { - vespalib::string method; - std::vector<vespalib::string> args; - vespalib::string hostname; - int portnumber; - Flags() : method("cache"), args(), hostname("localhost"), portnumber(19090) {} -}; - diff --git a/config/src/apps/configproxy-cmd/main.cpp b/config/src/apps/configproxy-cmd/main.cpp index b9090d3b641..3a8cf33c343 100644 --- a/config/src/apps/configproxy-cmd/main.cpp +++ b/config/src/apps/configproxy-cmd/main.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "flags.h" #include "proxycmd.h" #include "methods.h" #include <vespa/fastos/app.h> diff --git a/config/src/apps/configproxy-cmd/proxycmd.cpp b/config/src/apps/configproxy-cmd/proxycmd.cpp index 48c343367f7..794c005f485 100644 --- a/config/src/apps/configproxy-cmd/proxycmd.cpp +++ b/config/src/apps/configproxy-cmd/proxycmd.cpp @@ -4,12 +4,24 @@ #include <iostream> #include <vespa/vespalib/util/stringfmt.h> +Flags::Flags(const Flags &) = default; +Flags & Flags::operator=(const Flags &) = default; +Flags::Flags() + : method("cache"), + args(), + hostname("localhost"), + portnumber(19090) +{ } +Flags::~Flags() { } + ProxyCmd::ProxyCmd(const Flags& flags) : _supervisor(NULL), _target(NULL), _req(NULL), _flags(flags) -{} +{ } + +ProxyCmd::~ProxyCmd() { } void ProxyCmd::initRPC() { _supervisor = new FRT_Supervisor(); diff --git a/config/src/apps/configproxy-cmd/proxycmd.h b/config/src/apps/configproxy-cmd/proxycmd.h index 6fc8261991f..a0ef02edaae 100644 --- a/config/src/apps/configproxy-cmd/proxycmd.h +++ b/config/src/apps/configproxy-cmd/proxycmd.h @@ -1,9 +1,18 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "flags.h" #include <vespa/fnet/frt/frt.h> +struct Flags { + vespalib::string method; + std::vector<vespalib::string> args; + vespalib::string hostname; + int portnumber; + Flags(const Flags &); + Flags & operator=(const Flags &); + Flags(); + ~Flags(); +}; class ProxyCmd { @@ -22,7 +31,7 @@ private: public: ProxyCmd(const Flags& flags); - virtual ~ProxyCmd() {} + virtual ~ProxyCmd(); int action(); }; diff --git a/config/src/tests/configfetcher/configfetcher.cpp b/config/src/tests/configfetcher/configfetcher.cpp index 6d319fdff67..5d4ee8dcd2b 100644 --- a/config/src/tests/configfetcher/configfetcher.cpp +++ b/config/src/tests/configfetcher/configfetcher.cpp @@ -12,8 +12,9 @@ using namespace config; class MyCallback : public IFetcherCallback<MyConfig> { public: - MyCallback(const std::string & badConfig="") : _config(), _configured(false), _badConfig(badConfig) { } - void configure(std::unique_ptr<MyConfig> config) + MyCallback(const std::string & badConfig=""); + ~MyCallback(); + void configure(std::unique_ptr<MyConfig> config) override { _config = std::move(config); _configured = true; @@ -26,6 +27,9 @@ public: std::string _badConfig; }; +MyCallback::MyCallback(const std::string & badConfig) : _config(), _configured(false), _badConfig(badConfig) { } +MyCallback::~MyCallback() { } + TEST("requireThatConfigIsAvailableOnConstruction") { RawSpec spec("myField \"foo\"\n"); MyCallback cb; diff --git a/config/src/tests/configmanager/configmanager.cpp b/config/src/tests/configmanager/configmanager.cpp index d0e8f5444e0..1b20458b47e 100644 --- a/config/src/tests/configmanager/configmanager.cpp +++ b/config/src/tests/configmanager/configmanager.cpp @@ -106,11 +106,8 @@ namespace { ConfigManager _mgr; ConfigSubscription::SP sub; - ManagerTester(const ConfigKey & k, const MySpec & s) - : key(k), - _mgr(s.createSourceFactory(testTimingValues), 1) - { - } + ManagerTester(const ConfigKey & k, const MySpec & s); + ~ManagerTester(); void subscribe() { @@ -118,6 +115,12 @@ namespace { } }; + ManagerTester::ManagerTester(const ConfigKey & k, const MySpec & s) + : key(k), + _mgr(s.createSourceFactory(testTimingValues), 1) + { } + ManagerTester::~ManagerTester() { } + } TEST("requireThatSubscriptionTimesout") { diff --git a/config/src/tests/frt/frt.cpp b/config/src/tests/frt/frt.cpp index 597951af352..89cf9dd9e6a 100644 --- a/config/src/tests/frt/frt.cpp +++ b/config/src/tests/frt/frt.cpp @@ -128,13 +128,8 @@ namespace { FRT_Supervisor supervisor; FNET_Scheduler scheduler; vespalib::string address; - ConnectionMock(FRT_RPCRequest * answer = NULL) - : errorCode(0), - timeout(0), - ans(answer), - supervisor(), - address() - { } + ConnectionMock(FRT_RPCRequest * answer = NULL); + ~ConnectionMock(); FRT_RPCRequest * allocRPCRequest() { return supervisor.AllocRPCRequest(); } void setError(int ec) { errorCode = ec; } void invoke(FRT_RPCRequest * req, double t, FRT_IRequestWait * waiter) @@ -149,6 +144,15 @@ namespace { void setTransientDelay(int64_t delay) { (void) delay; } }; + ConnectionMock::ConnectionMock(FRT_RPCRequest * answer) + : errorCode(0), + timeout(0), + ans(answer), + supervisor(), + address() + { } + ConnectionMock::~ConnectionMock() { } + struct FactoryMock : public ConnectionFactory { ConnectionMock * current; FactoryMock(ConnectionMock * c) : current(c) { } diff --git a/config/src/tests/functiontest/functiontest.cpp b/config/src/tests/functiontest/functiontest.cpp index 24d50b44ca4..deed6f15f1a 100644 --- a/config/src/tests/functiontest/functiontest.cpp +++ b/config/src/tests/functiontest/functiontest.cpp @@ -94,13 +94,16 @@ struct LazyTestFixture ConfigHandle<FunctionTestConfig>::UP _handle; std::unique_ptr<FunctionTestConfig> _config; - LazyTestFixture(const std::string & dirName) + LazyTestFixture(const std::string & dirName); + ~LazyTestFixture(); +}; + +LazyTestFixture::LazyTestFixture(const std::string & dirName) : _spec(TEST_PATH(dirName)), _subscriber(_spec), _handle(_subscriber.subscribe<FunctionTestConfig>("")) - { - } -}; +{ } +LazyTestFixture::~LazyTestFixture() { } struct TestFixture : public LazyTestFixture { diff --git a/config/src/vespa/config/common/payload_converter.cpp b/config/src/vespa/config/common/payload_converter.cpp index 5dc45c12fa3..0dbbd62f392 100644 --- a/config/src/vespa/config/common/payload_converter.cpp +++ b/config/src/vespa/config/common/payload_converter.cpp @@ -12,6 +12,8 @@ PayloadConverter::PayloadConverter(const Inspector & inspector) _lines() {} +PayloadConverter::~PayloadConverter() { } + const std::vector<vespalib::string> & PayloadConverter::convert() { diff --git a/config/src/vespa/config/common/payload_converter.h b/config/src/vespa/config/common/payload_converter.h index 3a9d53f4c77..63a4b0a7964 100644 --- a/config/src/vespa/config/common/payload_converter.h +++ b/config/src/vespa/config/common/payload_converter.h @@ -14,6 +14,7 @@ namespace config { class PayloadConverter : public vespalib::slime::ObjectTraverser, public vespalib::slime::ArrayTraverser { public: PayloadConverter(const vespalib::slime::Inspector & inspector); + ~PayloadConverter(); const std::vector<vespalib::string> & convert(); void field(const vespalib::Memory & symbol, const vespalib::slime::Inspector & inspector); void entry(size_t idx, const vespalib::slime::Inspector & inspector); diff --git a/config/src/vespa/config/helper/configpoller.cpp b/config/src/vespa/config/helper/configpoller.cpp index 281fe8df140..ee9ec1bbc31 100644 --- a/config/src/vespa/config/helper/configpoller.cpp +++ b/config/src/vespa/config/helper/configpoller.cpp @@ -1,7 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "configpoller.h" + #include <vespa/log/log.h> LOG_SETUP(".config.helper.configpoller"); -#include "configpoller.h" namespace config { @@ -14,6 +16,8 @@ ConfigPoller::ConfigPoller(const IConfigContext::SP & context) { } +ConfigPoller::~ConfigPoller() { } + void ConfigPoller::run() { diff --git a/config/src/vespa/config/helper/configpoller.h b/config/src/vespa/config/helper/configpoller.h index f614cab5175..af660f6c536 100644 --- a/config/src/vespa/config/helper/configpoller.h +++ b/config/src/vespa/config/helper/configpoller.h @@ -1,11 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include "ifetchercallback.h" +#include "ihandle.h" #include <vespa/config/subscription/configsubscriber.h> #include <vespa/config/common/timingvalues.h> #include <vespa/vespalib/util/runnable.h> -#include "ifetchercallback.h" -#include "ihandle.h" namespace config { @@ -16,7 +16,8 @@ namespace config { class ConfigPoller : public vespalib::Runnable { public: ConfigPoller(const IConfigContext::SP & context); - void run(); + ~ConfigPoller(); + void run() override; template <typename ConfigType> void subscribe(const std::string & configId, IFetcherCallback<ConfigType> * callback, uint64_t subscribeTimeout = DEFAULT_SUBSCRIBE_TIMEOUT); void subscribeGenerationChanges(IGenerationCallback * callback) { _genCallback = callback; } diff --git a/configutil/src/apps/configstatus/main.cpp b/configutil/src/apps/configstatus/main.cpp index db411d309d1..1376624b207 100644 --- a/configutil/src/apps/configstatus/main.cpp +++ b/configutil/src/apps/configstatus/main.cpp @@ -20,9 +20,17 @@ public: void usage(void); int Main(void); - Application() : _flags(), _cfgId("admin/model"), _specString("") {} + Application(); + ~Application(); }; +Application::Application() + : _flags(), + _cfgId("admin/model"), + _specString("") +{} +Application::~Application() { } + int Application::parseOpts() { char c = '?'; const char *optArg = NULL; diff --git a/configutil/src/apps/modelinspect/main.cpp b/configutil/src/apps/modelinspect/main.cpp index ca660791223..9b5c2ccdd09 100644 --- a/configutil/src/apps/modelinspect/main.cpp +++ b/configutil/src/apps/modelinspect/main.cpp @@ -18,12 +18,16 @@ class Application : public FastOS_Application int parseOpts(); vespalib::string getSources(); public: - void usage(void); - int Main(void); + void usage(); + int Main(); - Application() : _flags(), _cfgId("admin/model"), _specString("") {} + Application(); + ~Application(); }; +Application::Application() : _flags(), _cfgId("admin/model"), _specString("") {} +Application::~Application() { } + int Application::parseOpts() { diff --git a/configutil/src/lib/configstatus.cpp b/configutil/src/lib/configstatus.cpp index bd3b9cb43ea..5f15b469d90 100644 --- a/configutil/src/lib/configstatus.cpp +++ b/configutil/src/lib/configstatus.cpp @@ -29,6 +29,8 @@ struct ComponentTraverser : public vespalib::slime::ObjectTraverser : _configId(configId), _state(ROOT), _generations(generations) {} + ~ComponentTraverser(); + void object(const vespalib::slime::Inspector &inspector) { inspector.traverse(*this); } @@ -70,6 +72,8 @@ struct ComponentTraverser : public vespalib::slime::ObjectTraverser } }; +ComponentTraverser::~ComponentTraverser() {} + class MyHttpHandler : public vbench::HttpResultHandler { private: std::string _json; @@ -81,6 +85,7 @@ public: MyHttpHandler(std::string configId) : _json(), _error(), _configId(configId) {} + ~MyHttpHandler(); virtual void handleHeader(const vbench::string &name, const vbench::string &value) { (void) name; @@ -105,6 +110,8 @@ public: } }; +MyHttpHandler::~MyHttpHandler() {} + ConfigStatus::ConfigStatus(Flags flags, const config::ConfigUri uri) : _cfg(), _flags(flags), _generation(0) { diff --git a/document/src/tests/documenttestcase.cpp b/document/src/tests/documenttestcase.cpp index 29ccefc1d86..25c7fa2ac57 100644 --- a/document/src/tests/documenttestcase.cpp +++ b/document/src/tests/documenttestcase.cpp @@ -104,20 +104,26 @@ void DocumentTest::testFieldPath() } } +class Handler : public FieldValue::IteratorHandler { +public: + Handler(); + ~Handler(); + const std::string & getResult() const { return _result; } +private: + virtual void onPrimitive(const Content&) { _result += 'P'; } + virtual void onCollectionStart(const Content&) { _result += '['; } + virtual void onCollectionEnd(const Content&) { _result += ']'; } + virtual void onStructStart(const Content&) { _result += '<'; } + virtual void onStructEnd(const Content&) { _result += '>'; } + std::string _result; +}; + +Handler::Handler() { } +Handler::~Handler() { } + + void DocumentTest::testTraversing() { - class Handler : public FieldValue::IteratorHandler { - public: - const std::string & getResult() const { return _result; } - private: - virtual void onPrimitive(const Content&) { _result += 'P'; } - virtual void onCollectionStart(const Content&) { _result += '['; } - virtual void onCollectionEnd(const Content&) { _result += ']'; } - virtual void onStructStart(const Content&) { _result += '<'; } - virtual void onStructEnd(const Content&) { _result += '>'; } - std::string _result; - }; - Field primitive1("primitive1", 1, *DataType::INT, true); Field primitive2("primitive2", 2, *DataType::INT, true); StructDataType struct1("struct1"); @@ -180,6 +186,8 @@ void DocumentTest::testTraversing() class VariableIteratorHandler : public FieldValue::IteratorHandler { public: + VariableIteratorHandler(); + ~VariableIteratorHandler(); std::string retVal; virtual void onPrimitive(const Content & fv) { @@ -190,6 +198,9 @@ public: }; }; +VariableIteratorHandler::VariableIteratorHandler() {} +VariableIteratorHandler::~VariableIteratorHandler() {} + void DocumentTest::testVariables() { diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp index 6ed36527734..f0784bf2ba7 100644 --- a/document/src/tests/documentupdatetestcase.cpp +++ b/document/src/tests/documentupdatetestcase.cpp @@ -488,17 +488,8 @@ struct WeightedSetAutoCreateFixture const Field& field; DocumentUpdate update; - WeightedSetAutoCreateFixture() - : repo(makeConfig()), - docType(repo.getDocumentType("test")), - doc(*docType, DocumentId("doc::testdoc")), - field(docType->getField("strwset")), - update(*docType, DocumentId("doc::testdoc")) - { - update.addUpdate(FieldUpdate(field) - .addUpdate(MapValueUpdate(StringFieldValue("foo"), - ArithmeticValueUpdate(ArithmeticValueUpdate::Add, 1)))); - } + ~WeightedSetAutoCreateFixture(); + WeightedSetAutoCreateFixture(); void applyUpdateToDocument() { update.applyTo(doc); @@ -518,6 +509,18 @@ struct WeightedSetAutoCreateFixture } }; +WeightedSetAutoCreateFixture::~WeightedSetAutoCreateFixture() {} +WeightedSetAutoCreateFixture::WeightedSetAutoCreateFixture() + : repo(makeConfig()), + docType(repo.getDocumentType("test")), + doc(*docType, DocumentId("doc::testdoc")), + field(docType->getField("strwset")), + update(*docType, DocumentId("doc::testdoc")) +{ + update.addUpdate(FieldUpdate(field) + .addUpdate(MapValueUpdate(StringFieldValue("foo"), + ArithmeticValueUpdate(ArithmeticValueUpdate::Add, 1)))); +} } // anon ns void @@ -1048,18 +1051,22 @@ struct CreateIfNonExistentFixture TestDocMan docMan; Document::UP document; DocumentUpdate::UP update; - CreateIfNonExistentFixture() - : docMan(), - document(docMan.createDocument()), - update(new DocumentUpdate(*document->getDataType(), - document->getId())) - { - update->addUpdate(FieldUpdate(document->getField("headerval")) - .addUpdate(AssignValueUpdate(IntFieldValue(1)))); - update->setCreateIfNonExistent(true); - } + ~CreateIfNonExistentFixture(); + CreateIfNonExistentFixture(); }; +CreateIfNonExistentFixture::~CreateIfNonExistentFixture() {} +CreateIfNonExistentFixture::CreateIfNonExistentFixture() + : docMan(), + document(docMan.createDocument()), + update(new DocumentUpdate(*document->getDataType(), + document->getId())) +{ + update->addUpdate(FieldUpdate(document->getField("headerval")) + .addUpdate(AssignValueUpdate(IntFieldValue(1)))); + update->setCreateIfNonExistent(true); +} + void DocumentUpdateTest::testThatCreateIfNonExistentFlagIsSerialized50AndDeserialized50() { diff --git a/document/src/tests/fieldpathupdatetestcase.cpp b/document/src/tests/fieldpathupdatetestcase.cpp index 3f14629f1e1..991c1d6b908 100644 --- a/document/src/tests/fieldpathupdatetestcase.cpp +++ b/document/src/tests/fieldpathupdatetestcase.cpp @@ -282,18 +282,11 @@ struct TestFieldPathUpdate : FieldPathUpdate mutable std::string _str; - TestFieldPathUpdate(const DocumentTypeRepo& repo, - const DataType *type, - const std::string& fieldPath, - const std::string& whereClause) - : FieldPathUpdate(repo, *type, fieldPath, whereClause) - { - } + ~TestFieldPathUpdate(); + TestFieldPathUpdate(const DocumentTypeRepo& repo, const DataType *type, + const std::string& fieldPath, const std::string& whereClause); - TestFieldPathUpdate(const TestFieldPathUpdate& other) - : FieldPathUpdate(other) - { - } + TestFieldPathUpdate(const TestFieldPathUpdate& other); std::unique_ptr<FieldValue::IteratorHandler> getIteratorHandler(Document&) const { @@ -312,6 +305,18 @@ struct TestFieldPathUpdate : FieldPathUpdate uint8_t getSerializedType() const override { assert(false); return 7; } }; +TestFieldPathUpdate::~TestFieldPathUpdate() { } +TestFieldPathUpdate::TestFieldPathUpdate(const DocumentTypeRepo& repo, const DataType *type, + const std::string& fieldPath, const std::string& whereClause) + : FieldPathUpdate(repo, *type, fieldPath, whereClause) +{ +} + +TestFieldPathUpdate::TestFieldPathUpdate(const TestFieldPathUpdate& other) + : FieldPathUpdate(other) +{ +} + void FieldPathUpdateTestCase::setUp() { @@ -851,9 +856,13 @@ struct Keys { vespalib::string key1; vespalib::string key2; vespalib::string key3; - Keys() : key1("foo"), key2("bar"), key3("zoo") {} + Keys(); + ~Keys(); }; +Keys::Keys() : key1("foo"), key2("bar"), key3("zoo") {} +Keys::~Keys() {} + struct Fixture { Document::UP doc; MapFieldValue mfv; @@ -864,32 +873,36 @@ struct Fixture { doc_type.getField("structmap").getDataType()); } - Fixture(const DocumentType &doc_type, const Keys &k) - : doc(new Document(doc_type, DocumentId("doc:planet:express"))), - mfv(getMapType(doc_type)), - fv1(getMapType(doc_type).getValueType()), - fv2(getMapType(doc_type).getValueType()), - fv3(getMapType(doc_type).getValueType()), - fv4(getMapType(doc_type).getValueType()) { + ~Fixture(); + Fixture(const DocumentType &doc_type, const Keys &k); +}; - fv1.setValue("title", StringFieldValue("fry")); - fv1.setValue("rating", IntFieldValue(30)); - mfv.put(StringFieldValue(k.key1), fv1); +Fixture::~Fixture() { } +Fixture::Fixture(const DocumentType &doc_type, const Keys &k) + : doc(new Document(doc_type, DocumentId("doc:planet:express"))), + mfv(getMapType(doc_type)), + fv1(getMapType(doc_type).getValueType()), + fv2(getMapType(doc_type).getValueType()), + fv3(getMapType(doc_type).getValueType()), + fv4(getMapType(doc_type).getValueType()) +{ + fv1.setValue("title", StringFieldValue("fry")); + fv1.setValue("rating", IntFieldValue(30)); + mfv.put(StringFieldValue(k.key1), fv1); - fv2.setValue("title", StringFieldValue("farnsworth")); - fv2.setValue("rating", IntFieldValue(60)); - mfv.put(StringFieldValue(k.key2), fv2); + fv2.setValue("title", StringFieldValue("farnsworth")); + fv2.setValue("rating", IntFieldValue(60)); + mfv.put(StringFieldValue(k.key2), fv2); - fv3.setValue("title", StringFieldValue("zoidberg")); - fv3.setValue("rating", IntFieldValue(-20)); - mfv.put(StringFieldValue(k.key3), fv3); + fv3.setValue("title", StringFieldValue("zoidberg")); + fv3.setValue("rating", IntFieldValue(-20)); + mfv.put(StringFieldValue(k.key3), fv3); - doc->setValue("structmap", mfv); + doc->setValue("structmap", mfv); - fv4.setValue("title", StringFieldValue("farnsworth")); - fv4.setValue("rating", IntFieldValue(48)); - } -}; + fv4.setValue("title", StringFieldValue("farnsworth")); + fv4.setValue("rating", IntFieldValue(48)); +} } // namespace diff --git a/document/src/tests/fieldvalue/referencefieldvalue_test.cpp b/document/src/tests/fieldvalue/referencefieldvalue_test.cpp index 1399c71fcc3..254bd546926 100644 --- a/document/src/tests/fieldvalue/referencefieldvalue_test.cpp +++ b/document/src/tests/fieldvalue/referencefieldvalue_test.cpp @@ -19,8 +19,12 @@ struct Fixture { DocumentType otherDocType{"bar"}; ReferenceDataType otherRefType{otherDocType, 54321}; + Fixture(); + ~Fixture(); }; + Fixture::Fixture() { } + Fixture::~Fixture() { } } using vespalib::IllegalArgumentException; diff --git a/document/src/tests/gid_filter_test.cpp b/document/src/tests/gid_filter_test.cpp index 9caf55f6a0b..02a47bffe6f 100644 --- a/document/src/tests/gid_filter_test.cpp +++ b/document/src/tests/gid_filter_test.cpp @@ -17,12 +17,8 @@ class GidFilterTest : public CppUnit::TestFixture { BucketIdFactory _id_factory; std::unique_ptr<Node> _root; - Fixture(vespalib::stringref selection) - : _repo(), - _id_factory(), - _root(Parser(_repo.getTypeRepo(), _id_factory).parse(selection)) - { - } + Fixture(vespalib::stringref selection); + ~Fixture(); Fixture(Fixture&&) = default; Fixture& operator=(Fixture&&) = default; @@ -87,6 +83,13 @@ public: void composite_group_comparison_sub_expressions_not_supported(); }; +GidFilterTest::Fixture::Fixture(vespalib::stringref selection) + : _repo(), + _id_factory(), + _root(Parser(_repo.getTypeRepo(), _id_factory).parse(selection)) +{ } +GidFilterTest::Fixture::~Fixture() { } + CPPUNIT_TEST_SUITE_REGISTRATION(GidFilterTest); void diff --git a/document/src/vespa/document/annotation/spannode.cpp b/document/src/vespa/document/annotation/spannode.cpp index 5feaffd8656..1b0ee71cc15 100644 --- a/document/src/vespa/document/annotation/spannode.cpp +++ b/document/src/vespa/document/annotation/spannode.cpp @@ -11,7 +11,8 @@ namespace { class ToStringVisitor : public SpanTreeVisitor { public: - ToStringVisitor() : _os(), _indent() { } + ToStringVisitor(); + ~ToStringVisitor(); vespalib::stringref str() const { return _os.str(); } private: vespalib::asciistream _os; @@ -79,6 +80,9 @@ private: } }; +ToStringVisitor::ToStringVisitor() : _os(), _indent() { } +ToStringVisitor::~ToStringVisitor() { } + } vespalib::string diff --git a/document/src/vespa/document/fieldvalue/stringfieldvalue.cpp b/document/src/vespa/document/fieldvalue/stringfieldvalue.cpp index 04580f906fa..9793184aa0f 100644 --- a/document/src/vespa/document/fieldvalue/stringfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/stringfieldvalue.cpp @@ -26,6 +26,8 @@ StringFieldValue::StringFieldValue(const StringFieldValue & rhs) : { } +StringFieldValue::~StringFieldValue() {} + StringFieldValue & StringFieldValue::operator=(const StringFieldValue & rhs) { if (&rhs != this) { diff --git a/document/src/vespa/document/fieldvalue/stringfieldvalue.h b/document/src/vespa/document/fieldvalue/stringfieldvalue.h index bb3c8ddf9d5..b1690a2245a 100644 --- a/document/src/vespa/document/fieldvalue/stringfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/stringfieldvalue.h @@ -30,6 +30,7 @@ public: StringFieldValue &operator=(const StringFieldValue &rhs); StringFieldValue &operator=(const vespalib::stringref &value) override; + ~StringFieldValue(); FieldValue &assign(const FieldValue &) override; diff --git a/document/src/vespa/document/select/valuenode.cpp b/document/src/vespa/document/select/valuenode.cpp index 2138b8eac41..54ab19f3087 100644 --- a/document/src/vespa/document/select/valuenode.cpp +++ b/document/src/vespa/document/select/valuenode.cpp @@ -1,15 +1,15 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "valuenode.h" #include "visitor.h" - -#include <iomanip> -#include <vespa/document/base/exceptions.h> #include "parser.h" +#include <vespa/document/base/exceptions.h> #include <vespa/document/fieldvalue/fieldvalues.h> #include <vespa/vespalib/util/md5.h> #include <vespa/document/util/stringutil.h> #include <vespa/vespalib/text/lowercase.h> #include <regex> +#include <iomanip> + #include <vespa/log/log.h> LOG_SETUP(".document.select.valuenode"); @@ -263,6 +263,9 @@ FieldValueNode::getValue(const Context& context) const } } +FieldValueNode::IteratorHandler::IteratorHandler() { } +FieldValueNode::IteratorHandler::~IteratorHandler() { } + bool FieldValueNode::IteratorHandler::hasSingleValue() const { return _firstValue.get() && (_values.size() == 0); diff --git a/document/src/vespa/document/select/valuenode.h b/document/src/vespa/document/select/valuenode.h index 60d0e3afbb3..cbbc77f8818 100644 --- a/document/src/vespa/document/select/valuenode.h +++ b/document/src/vespa/document/select/valuenode.h @@ -269,6 +269,8 @@ private: class IteratorHandler : public FieldValue::IteratorHandler { public: + IteratorHandler(); + ~IteratorHandler(); bool hasSingleValue() const; std::unique_ptr<Value> getSingleValue(); diff --git a/document/src/vespa/document/serialization/CMakeLists.txt b/document/src/vespa/document/serialization/CMakeLists.txt index e17e4a735e4..212e640b2d8 100644 --- a/document/src/vespa/document/serialization/CMakeLists.txt +++ b/document/src/vespa/document/serialization/CMakeLists.txt @@ -3,6 +3,7 @@ vespa_add_library(document_serialization OBJECT SOURCES annotationdeserializer.cpp annotationserializer.cpp + slime_output_to_vector.cpp vespadocumentserializer.cpp vespadocumentdeserializer.cpp DEPENDS diff --git a/document/src/vespa/document/serialization/slime_output_to_vector.cpp b/document/src/vespa/document/serialization/slime_output_to_vector.cpp new file mode 100644 index 00000000000..210f36e43bc --- /dev/null +++ b/document/src/vespa/document/serialization/slime_output_to_vector.cpp @@ -0,0 +1,14 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "slime_output_to_vector.h" + +namespace document { + +SlimeOutputToVector::SlimeOutputToVector() + : _buf(), + _size(0) +{ } + +SlimeOutputToVector::~SlimeOutputToVector() { } + +} diff --git a/document/src/vespa/document/serialization/slime_output_to_vector.h b/document/src/vespa/document/serialization/slime_output_to_vector.h index ae95accdd79..eac460d062f 100644 --- a/document/src/vespa/document/serialization/slime_output_to_vector.h +++ b/document/src/vespa/document/serialization/slime_output_to_vector.h @@ -13,7 +13,8 @@ class SlimeOutputToVector : public vespalib::Output { size_t _size; public: - SlimeOutputToVector() : _buf(), _size(0) {} + SlimeOutputToVector(); + ~SlimeOutputToVector(); vespalib::WritableMemory reserve(size_t reserve) { if (_size + reserve > _buf.size()) { diff --git a/document/src/vespa/document/update/fieldupdate.cpp b/document/src/vespa/document/update/fieldupdate.cpp index e932d985056..5a677488467 100644 --- a/document/src/vespa/document/update/fieldupdate.cpp +++ b/document/src/vespa/document/update/fieldupdate.cpp @@ -27,6 +27,8 @@ FieldUpdate::FieldUpdate(const DocumentTypeRepo& repo, deserialize(repo, type, buffer, version); } +FieldUpdate::~FieldUpdate() {} + bool FieldUpdate::operator==(const FieldUpdate& other) const { diff --git a/document/src/vespa/document/update/fieldupdate.h b/document/src/vespa/document/update/fieldupdate.h index 14766af57e1..d47e5579a31 100644 --- a/document/src/vespa/document/update/fieldupdate.h +++ b/document/src/vespa/document/update/fieldupdate.h @@ -13,8 +13,8 @@ */ #pragma once +#include "valueupdate.h" #include <vespa/document/base/field.h> -#include <vespa/document/update/valueupdate.h> #include <vespa/document/util/serializable.h> namespace document { @@ -34,6 +34,7 @@ public: typedef vespalib::CloneablePtr<FieldUpdate> CP; FieldUpdate(const Field& field); + ~FieldUpdate(); /** * This is a convenience function to construct a field update directly from 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/eval/src/tests/eval/function/function_test.cpp b/eval/src/tests/eval/function/function_test.cpp index 306fdb95386..e90525ce2fa 100644 --- a/eval/src/tests/eval/function/function_test.cpp +++ b/eval/src/tests/eval/function/function_test.cpp @@ -608,8 +608,12 @@ struct UnWrapped { vespalib::string wrapper; vespalib::string body; vespalib::string error; + ~UnWrapped(); }; + +UnWrapped::~UnWrapped() {} + UnWrapped unwrap(const vespalib::string &str) { UnWrapped result; bool ok = Function::unwrap(str, result.wrapper, result.body, result.error); diff --git a/eval/src/tests/eval/value_type/value_type_test.cpp b/eval/src/tests/eval/value_type/value_type_test.cpp index 529d45e616d..b72b5a3a972 100644 --- a/eval/src/tests/eval/value_type/value_type_test.cpp +++ b/eval/src/tests/eval/value_type/value_type_test.cpp @@ -308,14 +308,18 @@ struct ParseResult { const char *end; const char *after; ValueType type; - ParseResult(const vespalib::string &spec_in) - : spec(spec_in), - pos(spec.data()), - end(pos + spec.size()), - after(nullptr), - type(value_type::parse_spec(pos, end, after)) {} + ParseResult(const vespalib::string &spec_in); + ~ParseResult(); bool after_inside() const { return ((after > pos) && (after < end)); } }; +ParseResult::ParseResult(const vespalib::string &spec_in) + : spec(spec_in), + pos(spec.data()), + end(pos + spec.size()), + after(nullptr), + type(value_type::parse_spec(pos, end, after)) +{ } +ParseResult::~ParseResult() { } TEST("require that we can parse a partial string into a type with the low-level API") { ParseResult result("tensor(a[]) , "); diff --git a/eval/src/tests/tensor/dense_dot_product_function/dense_dot_product_function_test.cpp b/eval/src/tests/tensor/dense_dot_product_function/dense_dot_product_function_test.cpp index 8b7ea1d03a9..3b16c9e3026 100644 --- a/eval/src/tests/tensor/dense_dot_product_function/dense_dot_product_function_test.cpp +++ b/eval/src/tests/tensor/dense_dot_product_function/dense_dot_product_function_test.cpp @@ -90,11 +90,8 @@ struct Fixture { DenseDotProductFunction function; FunctionInput input; - Fixture(size_t lhsNumCells, size_t rhsNumCells) - : function(0, 1), - input(lhsNumCells, rhsNumCells) - { - } + Fixture(size_t lhsNumCells, size_t rhsNumCells); + ~Fixture(); double eval() const { Stash stash; const Value &result = function.eval(input, stash); @@ -107,6 +104,13 @@ struct Fixture } }; +Fixture::Fixture(size_t lhsNumCells, size_t rhsNumCells) + : function(0, 1), + input(lhsNumCells, rhsNumCells) +{ } + +Fixture::~Fixture() { } + void assertDotProduct(size_t numCells) { diff --git a/eval/src/vespa/eval/eval/call_nodes.cpp b/eval/src/vespa/eval/eval/call_nodes.cpp index 8260ede54a0..cc09b53835c 100644 --- a/eval/src/vespa/eval/eval/call_nodes.cpp +++ b/eval/src/vespa/eval/eval/call_nodes.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include "call_nodes.h" #include "node_visitor.h" @@ -8,6 +7,9 @@ namespace vespalib { namespace eval { namespace nodes { +Call::~Call() { } + + template <typename T> void CallHelper<T>::accept(NodeVisitor &visitor) const { visitor.visit(static_cast<const T&>(*this)); } diff --git a/eval/src/vespa/eval/eval/call_nodes.h b/eval/src/vespa/eval/eval/call_nodes.h index 70996e2f629..01283a00e42 100644 --- a/eval/src/vespa/eval/eval/call_nodes.h +++ b/eval/src/vespa/eval/eval/call_nodes.h @@ -2,9 +2,9 @@ #pragma once +#include "basic_nodes.h" #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/stringfmt.h> -#include "basic_nodes.h" #include <map> #include <cmath> @@ -29,6 +29,7 @@ private: public: Call(const vespalib::string &name_in, size_t num_params_in) : _name(name_in), _num_params(num_params_in), _is_const(false) {} + ~Call(); virtual bool is_const() const override { return _is_const; } const vespalib::string &name() const { return _name; } size_t num_params() const { return _num_params; } diff --git a/eval/src/vespa/eval/eval/interpreted_function.cpp b/eval/src/vespa/eval/eval/interpreted_function.cpp index 13622e9999f..b308de6b3c0 100644 --- a/eval/src/vespa/eval/eval/interpreted_function.cpp +++ b/eval/src/vespa/eval/eval/interpreted_function.cpp @@ -1,19 +1,15 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include "interpreted_function.h" #include "node_visitor.h" #include "node_traverser.h" #include "check_type.h" -#include <cmath> -#include <vespa/vespalib/util/approx.h> -#include "operation.h" -#include <set> #include "tensor_spec.h" -#include "simple_tensor_engine.h" #include <vespa/vespalib/util/classname.h> #include <vespa/eval/eval/llvm/compile_cache.h> #include <vespa/vespalib/util/benchmark_timer.h> +#include <set> + namespace vespalib { namespace eval { @@ -516,10 +512,17 @@ const Function *get_lambda(const nodes::Node &node) { } // namespace vespalib::<unnamed> + InterpretedFunction::LazyParams::~LazyParams() { } +InterpretedFunction::SimpleParams::SimpleParams(const std::vector<double> ¶ms_in) + : params(params_in) +{} + +InterpretedFunction::SimpleParams::~SimpleParams() { } + const Value & InterpretedFunction::SimpleParams::resolve(size_t idx, Stash &stash) const { @@ -534,6 +537,36 @@ InterpretedFunction::SimpleObjectParams::resolve(size_t idx, Stash &) const return params[idx]; } +InterpretedFunction::State::State(const TensorEngine &engine_in) + : engine(engine_in), + params(nullptr), + stash(), + stack(), + let_values(), + program_offset(0) +{ +} + +InterpretedFunction::State::~State() {} + +void +InterpretedFunction::State::init(const LazyParams ¶ms_in) { + params = ¶ms_in; + stash.clear(); + stack.clear(); + let_values.clear(); + program_offset = 0; + if_cnt = 0; +} + +void +InterpretedFunction::State::replace(size_t prune_cnt, const Value &value) { + for (size_t i = 0; i < prune_cnt; ++i) { + stack.pop_back(); + } + stack.push_back(value); +} + InterpretedFunction::Context::Context(const InterpretedFunction &ifun) : _state(ifun._tensor_engine) { diff --git a/eval/src/vespa/eval/eval/interpreted_function.h b/eval/src/vespa/eval/eval/interpreted_function.h index 3a3e6173fd5..540f8212256 100644 --- a/eval/src/vespa/eval/eval/interpreted_function.h +++ b/eval/src/vespa/eval/eval/interpreted_function.h @@ -3,9 +3,9 @@ #pragma once #include "function.h" -#include <vespa/vespalib/util/stash.h> #include "simple_tensor_engine.h" #include "node_types.h" +#include <vespa/vespalib/util/stash.h> namespace vespalib { namespace eval { @@ -39,7 +39,8 @@ public: **/ struct SimpleParams : LazyParams { std::vector<double> params; - explicit SimpleParams(const std::vector<double> ¶ms_in) : params(params_in) {} + explicit SimpleParams(const std::vector<double> ¶ms_in); + ~SimpleParams(); const Value &resolve(size_t idx, Stash &stash) const override; }; /** @@ -59,25 +60,15 @@ public: std::vector<Value::CREF> let_values; uint32_t program_offset; uint32_t if_cnt; - State(const TensorEngine &engine_in) - : engine(engine_in), params(nullptr), stash(), stack(), let_values(), program_offset(0) {} - void init(const LazyParams ¶ms_in) { - params = ¶ms_in; - stash.clear(); - stack.clear(); - let_values.clear(); - program_offset = 0; - if_cnt = 0; - } + + State(const TensorEngine &engine_in); + ~State(); + + void init(const LazyParams ¶ms_in); const Value &peek(size_t ridx) const { return stack[stack.size() - 1 - ridx]; } - void replace(size_t prune_cnt, const Value &value) { - for (size_t i = 0; i < prune_cnt; ++i) { - stack.pop_back(); - } - stack.push_back(value); - } + void replace(size_t prune_cnt, const Value &value); }; class Context { friend class InterpretedFunction; diff --git a/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp b/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp index 0d404f2077b..021e850188d 100644 --- a/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp +++ b/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp @@ -163,6 +163,7 @@ struct FunctionBuilder : public NodeVisitor, public NodeTraverser { params.push_back(itr); } } + ~FunctionBuilder(); //------------------------------------------------------------------------- @@ -618,6 +619,8 @@ struct FunctionBuilder : public NodeVisitor, public NodeTraverser { } }; +FunctionBuilder::~FunctionBuilder() { } + } // namespace vespalib::eval::<unnamed> struct InitializeNativeTarget { diff --git a/eval/src/vespa/eval/eval/node_types.cpp b/eval/src/vespa/eval/eval/node_types.cpp index 4834f102790..c02060a1060 100644 --- a/eval/src/vespa/eval/eval/node_types.cpp +++ b/eval/src/vespa/eval/eval/node_types.cpp @@ -72,8 +72,8 @@ struct TypeResolver : public NodeVisitor, public NodeTraverser { using action_function = void (*)(State &); std::vector<std::pair<const Node *, action_function>> actions; TypeResolver(const std::vector<ValueType> ¶ms_in, - std::map<const Node *, ValueType> &type_map_out) - : state(params_in, type_map_out), actions() {} + std::map<const Node *, ValueType> &type_map_out); + ~TypeResolver(); //------------------------------------------------------------------------- @@ -242,6 +242,14 @@ struct TypeResolver : public NodeVisitor, public NodeTraverser { } }; +TypeResolver::TypeResolver(const std::vector<ValueType> ¶ms_in, + std::map<const Node *, ValueType> &type_map_out) + : state(params_in, type_map_out), + actions() +{ } + +TypeResolver::~TypeResolver() { } + } // namespace vespalib::eval::nodes::<unnamed> } // namespace vespalib::eval::nodes diff --git a/eval/src/vespa/eval/eval/operator_nodes.cpp b/eval/src/vespa/eval/eval/operator_nodes.cpp index ab6955a8248..ea8ab56030f 100644 --- a/eval/src/vespa/eval/eval/operator_nodes.cpp +++ b/eval/src/vespa/eval/eval/operator_nodes.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include "operator_nodes.h" #include "node_visitor.h" @@ -8,6 +7,17 @@ namespace vespalib { namespace eval { namespace nodes { +Operator::Operator(const vespalib::string &op_str_in, int priority_in, Order order_in) + : _op_str(op_str_in), + _priority(priority_in), + _order(order_in), + _lhs(), + _rhs(), + _is_const(false) +{} + +Operator::~Operator() { } + template <typename T> void OperatorHelper<T>::accept(NodeVisitor &visitor) const { visitor.visit(static_cast<const T&>(*this)); } diff --git a/eval/src/vespa/eval/eval/operator_nodes.h b/eval/src/vespa/eval/eval/operator_nodes.h index 34b1e60d571..a0726137015 100644 --- a/eval/src/vespa/eval/eval/operator_nodes.h +++ b/eval/src/vespa/eval/eval/operator_nodes.h @@ -2,11 +2,11 @@ #pragma once -#include <cmath> -#include <memory> +#include "basic_nodes.h" #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/stringfmt.h> -#include "basic_nodes.h" +#include <cmath> +#include <memory> #include <map> namespace vespalib { @@ -35,8 +35,8 @@ private: bool _is_const; public: - Operator(const vespalib::string &op_str_in, int priority_in, Order order_in) - : _op_str(op_str_in), _priority(priority_in), _order(order_in), _lhs(), _rhs(), _is_const(false) {} + Operator(const vespalib::string &op_str_in, int priority_in, Order order_in); + ~Operator(); vespalib::string op_str() const { return _op_str; } int priority() const { return _priority; } Order order() const { return _order; } diff --git a/eval/src/vespa/eval/eval/simple_tensor.cpp b/eval/src/vespa/eval/eval/simple_tensor.cpp index fbe2278a0c9..8845974acf7 100644 --- a/eval/src/vespa/eval/eval/simple_tensor.cpp +++ b/eval/src/vespa/eval/eval/simple_tensor.cpp @@ -141,27 +141,8 @@ private: size_t _block_size; BlockMap _blocks; public: - explicit Builder(const ValueType &type) - : _type(type), - _mapped(), - _indexed(), - _block_size(1), - _blocks() - { - assert_type(_type); - for (size_t i = 0; i < type.dimensions().size(); ++i) { - const auto &dimension = _type.dimensions()[i]; - if (dimension.is_mapped()) { - _mapped.push_back(i); - } else { - _block_size *= dimension.size; - _indexed.push_back(i); - } - } - if (_mapped.empty()) { - _blocks.emplace(Address(), Block(_type, _indexed, _block_size)); - } - } + explicit Builder(const ValueType &type); + ~Builder(); void set(const Address &address, double value) { assert_address(address, _type); Address block_key = select(address, _mapped); @@ -189,6 +170,29 @@ public: } }; +Builder::Builder(const ValueType &type) + : _type(type), + _mapped(), + _indexed(), + _block_size(1), + _blocks() +{ + assert_type(_type); + for (size_t i = 0; i < type.dimensions().size(); ++i) { + const auto &dimension = _type.dimensions()[i]; + if (dimension.is_mapped()) { + _mapped.push_back(i); + } else { + _block_size *= dimension.size; + _indexed.push_back(i); + } + } + if (_mapped.empty()) { + _blocks.emplace(Address(), Block(_type, _indexed, _block_size)); + } +} +Builder::~Builder() { } + /** * Helper class used to calculate which dimensions are shared between * types and which are not. Also calculates how address elements from @@ -204,42 +208,18 @@ struct TypeAnalyzer { IndexList combine; size_t ignored_a; size_t ignored_b; - TypeAnalyzer(const ValueType &lhs, const ValueType &rhs, const vespalib::string &ignore = "") - : only_a(), overlap_a(), overlap_b(), only_b(), combine(), ignored_a(npos), ignored_b(npos) - { - const auto &a = lhs.dimensions(); - const auto &b = rhs.dimensions(); - size_t b_idx = 0; - for (size_t a_idx = 0; a_idx < a.size(); ++a_idx) { - while ((b_idx < b.size()) && (b[b_idx].name < a[a_idx].name)) { - if (b[b_idx].name != ignore) { - only_b.push_back(b_idx); - combine.push_back(a.size() + b_idx); - } else { - ignored_b = b_idx; - } - ++b_idx; - } - if ((b_idx < b.size()) && (b[b_idx].name == a[a_idx].name)) { - if (a[a_idx].name != ignore) { - overlap_a.push_back(a_idx); - overlap_b.push_back(b_idx); - combine.push_back(a_idx); - } else { - ignored_a = a_idx; - ignored_b = b_idx; - } - ++b_idx; - } else { - if (a[a_idx].name != ignore) { - only_a.push_back(a_idx); - combine.push_back(a_idx); - } else { - ignored_a = a_idx; - } - } - } - while (b_idx < b.size()) { + TypeAnalyzer(const ValueType &lhs, const ValueType &rhs, const vespalib::string &ignore = ""); + ~TypeAnalyzer(); +}; + +TypeAnalyzer::TypeAnalyzer(const ValueType &lhs, const ValueType &rhs, const vespalib::string &ignore) + : only_a(), overlap_a(), overlap_b(), only_b(), combine(), ignored_a(npos), ignored_b(npos) +{ + const auto &a = lhs.dimensions(); + const auto &b = rhs.dimensions(); + size_t b_idx = 0; + for (size_t a_idx = 0; a_idx < a.size(); ++a_idx) { + while ((b_idx < b.size()) && (b[b_idx].name < a[a_idx].name)) { if (b[b_idx].name != ignore) { only_b.push_back(b_idx); combine.push_back(a.size() + b_idx); @@ -248,8 +228,37 @@ struct TypeAnalyzer { } ++b_idx; } + if ((b_idx < b.size()) && (b[b_idx].name == a[a_idx].name)) { + if (a[a_idx].name != ignore) { + overlap_a.push_back(a_idx); + overlap_b.push_back(b_idx); + combine.push_back(a_idx); + } else { + ignored_a = a_idx; + ignored_b = b_idx; + } + ++b_idx; + } else { + if (a[a_idx].name != ignore) { + only_a.push_back(a_idx); + combine.push_back(a_idx); + } else { + ignored_a = a_idx; + } + } } -}; + while (b_idx < b.size()) { + if (b[b_idx].name != ignore) { + only_b.push_back(b_idx); + combine.push_back(a.size() + b_idx); + } else { + ignored_b = b_idx; + } + ++b_idx; + } +} + +TypeAnalyzer::~TypeAnalyzer() { } /** * A view is a total ordering of cells from a SimpleTensor according @@ -316,6 +325,7 @@ public: } std::sort(_refs.begin(), _refs.end(), _less); } + ~View(); const IndexList &selector() const { return _less.selector; } const CellRef *refs_begin() const { return &_refs[0]; } const CellRef *refs_end() const { return (refs_begin() + _refs.size()); } @@ -323,6 +333,8 @@ public: EqualRange next_range(const EqualRange &prev) const { return make_range(prev.end()); } }; +View::~View() { } + /** * Helper class used to find matching EqualRanges from two different * SimpleTensor Views. @@ -343,6 +355,7 @@ public: { assert(a_selector.size() == b_selector.size()); } + ~CrossCompare(); Result compare(const Cell &a, const Cell &b) const { for (size_t i = 0; i < a_selector.size(); ++i) { if (a.address[a_selector[i]] != b.address[b_selector[i]]) { @@ -392,6 +405,7 @@ public: { find_match(); } + ~ViewMatcher(); bool valid() const { return (has_a() && has_b()); } const EqualRange &get_a() const { return _a_range; } const EqualRange &get_b() const { return _b_range; } @@ -402,6 +416,10 @@ public: } }; +ViewMatcher::~ViewMatcher() { } + +ViewMatcher::CrossCompare::~CrossCompare() { } + } // namespace vespalib::eval::<unnamed> constexpr size_t TensorSpec::Label::npos; diff --git a/eval/src/vespa/eval/eval/tensor_spec.cpp b/eval/src/vespa/eval/eval/tensor_spec.cpp index eec930b8da4..dfd8b06bb52 100644 --- a/eval/src/vespa/eval/eval/tensor_spec.cpp +++ b/eval/src/vespa/eval/eval/tensor_spec.cpp @@ -1,17 +1,23 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/vespalib/util/stringfmt.h> #include "tensor_spec.h" -#include <iostream> +#include <vespa/vespalib/util/stringfmt.h> +#include <ostream> namespace vespalib { namespace eval { +TensorSpec::TensorSpec(const vespalib::string &type_spec) + : _type(type_spec), + _cells() +{ } + +TensorSpec::~TensorSpec() { } + vespalib::string TensorSpec::to_string() const { - vespalib::string out = vespalib::make_string("spec(%s) {\n", _type.c_str()); + vespalib::string out = make_string("spec(%s) {\n", _type.c_str()); for (const auto &cell: _cells) { size_t n = 0; out.append(" ["); @@ -22,10 +28,10 @@ TensorSpec::to_string() const if (label.second.is_mapped()) { out.append(label.second.name); } else { - out.append(vespalib::make_string("%zu", label.second.index)); + out.append(make_string("%zu", label.second.index)); } } - out.append(vespalib::make_string("]: %g\n", cell.second.value)); + out.append(make_string("]: %g\n", cell.second.value)); } out.append("}"); return out; diff --git a/eval/src/vespa/eval/eval/tensor_spec.h b/eval/src/vespa/eval/eval/tensor_spec.h index 06a9a3a2825..4f615d21906 100644 --- a/eval/src/vespa/eval/eval/tensor_spec.h +++ b/eval/src/vespa/eval/eval/tensor_spec.h @@ -54,7 +54,8 @@ private: vespalib::string _type; Cells _cells; public: - TensorSpec(const vespalib::string &type_spec) : _type(type_spec), _cells() {} + TensorSpec(const vespalib::string &type_spec); + ~TensorSpec(); TensorSpec &add(const Address &address, double value) { _cells.emplace(address, value); return *this; diff --git a/eval/src/vespa/eval/eval/test/tensor_conformance.cpp b/eval/src/vespa/eval/eval/test/tensor_conformance.cpp index 2445160bcd9..93b0cde7363 100644 --- a/eval/src/vespa/eval/eval/test/tensor_conformance.cpp +++ b/eval/src/vespa/eval/eval/test/tensor_conformance.cpp @@ -124,7 +124,11 @@ struct Domain { : dimension(dimension_in), size(size_in), keys() {} Domain(const vespalib::string &dimension_in, const std::vector<vespalib::string> &keys_in) : dimension(dimension_in), size(0), keys(keys_in) {} + ~Domain(); }; + +Domain::~Domain() { } + using Layout = std::vector<Domain>; Domain x() { return Domain("x", {}); } diff --git a/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.cpp b/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.cpp index 53af60bd101..a85a65ed8a9 100644 --- a/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.cpp +++ b/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.cpp @@ -33,6 +33,8 @@ public: } +DenseTensorAddressCombiner::~DenseTensorAddressCombiner() { } + DenseTensorAddressCombiner::DenseTensorAddressCombiner(const eval::ValueType &lhs, const eval::ValueType &rhs) : _ops(), diff --git a/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.h b/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.h index 482b7f86fc1..9e5f009fa82 100644 --- a/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.h +++ b/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.h @@ -2,10 +2,10 @@ #pragma once +#include "dense_tensor_cells_iterator.h" #include <vespa/eval/tensor/tensor.h> #include <vespa/eval/tensor/types.h> #include <vespa/eval/eval/value_type.h> -#include "dense_tensor_cells_iterator.h" namespace vespalib { namespace tensor { @@ -36,6 +36,7 @@ private: public: DenseTensorAddressCombiner(const eval::ValueType &lhs, const eval::ValueType &rhs); + ~DenseTensorAddressCombiner(); bool combine(const CellsIterator &lhsItr, const CellsIterator &rhsItr); diff --git a/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.cpp b/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.cpp index 8a7ed1928ef..e98bc0261d8 100644 --- a/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.cpp +++ b/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.cpp @@ -35,6 +35,8 @@ calculateCellAddress(const Address &address, const ValueType &type) } +DirectDenseTensorBuilder::~DirectDenseTensorBuilder() { } + DirectDenseTensorBuilder::DirectDenseTensorBuilder(const ValueType &type_in) : _type(type_in), _cells(calculateCellsSize(_type)) diff --git a/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.h b/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.h index b5329860e86..dc755e5bd1d 100644 --- a/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.h +++ b/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.h @@ -22,6 +22,7 @@ private: public: DirectDenseTensorBuilder(const eval::ValueType &type_in); + ~DirectDenseTensorBuilder(); void insertCell(const Address &address, double cellValue); Tensor::UP build(); }; diff --git a/fastos/src/tests/filetest.cpp b/fastos/src/tests/filetest.cpp index c967fc4caff..dcd1b224464 100644 --- a/fastos/src/tests/filetest.cpp +++ b/fastos/src/tests/filetest.cpp @@ -817,8 +817,14 @@ public: return allWasOk() ? 0 : 1; } + FileTest(); + ~FileTest(); }; +FileTest::FileTest() { } +FileTest::~FileTest() { } + + int main (int argc, char **argv) { FileTest app; diff --git a/filedistribution/src/apps/filedistributor/filedistributor.cpp b/filedistribution/src/apps/filedistributor/filedistributor.cpp index c51182134a0..1d51c032e9c 100644 --- a/filedistribution/src/apps/filedistributor/filedistributor.cpp +++ b/filedistribution/src/apps/filedistributor/filedistributor.cpp @@ -137,14 +137,8 @@ class FileDistributor : public config::IFetcherCallback<ZookeepersConfig>, public: FileDistributor(const FileDistributor &) = delete; FileDistributor & operator = (const FileDistributor &) = delete; - FileDistributor() - : _configMutex(), - _completeReconfigurationNeeded(false), - _zooKeepersConfig(), - _fileDistributorConfig(), - _rpcConfig(), - _components() - { } + FileDistributor(); + ~FileDistributor(); void notifyGenerationChange(int64_t generation) { if (_components && ! completeReconfigurationNeeded()) { @@ -232,6 +226,16 @@ public: } }; +FileDistributor::FileDistributor() + : _configMutex(), + _completeReconfigurationNeeded(false), + _zooKeepersConfig(), + _fileDistributorConfig(), + _rpcConfig(), + _components() +{ } +FileDistributor::~FileDistributor() { } + class FileDistributorApplication : public FastOS_Application { const config::ConfigUri _configUri; public: diff --git a/filedistribution/src/vespa/filedistribution/distributor/filedistributortrackerimpl.cpp b/filedistribution/src/vespa/filedistribution/distributor/filedistributortrackerimpl.cpp index 5112df7de09..2412b00ecd6 100644 --- a/filedistribution/src/vespa/filedistribution/distributor/filedistributortrackerimpl.cpp +++ b/filedistribution/src/vespa/filedistribution/distributor/filedistributortrackerimpl.cpp @@ -64,72 +64,92 @@ struct TrackingTask : public Scheduler::Task { const libtorrent::tracker_request& trackerRequest, const TorrentSP & torrent, const std::weak_ptr<FileDownloader>& downloader, - const std::shared_ptr<FileDistributionModel>& model) - : Task(scheduler), - _numTimesRescheduled(0), - _trackerRequest(trackerRequest), - _torrent(torrent), - _downloader(downloader), - _model(model) - {} + const std::shared_ptr<FileDistributionModel>& model); + ~TrackingTask(); //TODO: refactor - void doHandle() { - if (std::shared_ptr<FileDownloader> downloader = _downloader.lock()) { - //All torrents must be destructed before the session is destructed. - //It's okay to prevent the torrent from expiring here - //since the session can't be destructed while - //we hold a shared_ptr to the downloader. - if (TorrentSP torrent = _torrent.lock()) { - PeerEntries peers = getPeers(downloader); - - if (!peers.empty()) { - torrent->session().m_io_service.dispatch( - [torrent_weak_ptr = _torrent, trackerRequest = _trackerRequest, peers = peers]() mutable { - if (auto torrent_sp = torrent_weak_ptr.lock()) { - torrent_sp->tracker_response( - trackerRequest, - libtorrent::address(), - std::list<libtorrent::address>(), - peers, - -1, -1, -1, -1, -1, - libtorrent::address(), "trackerid"); - } - }); - } - - if (peers.size() < 5) { - reschedule(); - } + void doHandle(); + PeerEntries getPeers(const std::shared_ptr<FileDownloader>& downloader); + void reschedule(); +}; + +TrackingTask::TrackingTask(Scheduler& scheduler, + const libtorrent::tracker_request& trackerRequest, + const TorrentSP & torrent, + const std::weak_ptr<FileDownloader>& downloader, + const std::shared_ptr<FileDistributionModel>& model) + : Task(scheduler), + _numTimesRescheduled(0), + _trackerRequest(trackerRequest), + _torrent(torrent), + _downloader(downloader), + _model(model) +{ } + +TrackingTask::~TrackingTask() {} + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winline" +//TODO: refactor +void +TrackingTask::doHandle() { + if (std::shared_ptr<FileDownloader> downloader = _downloader.lock()) { + //All torrents must be destructed before the session is destructed. + //It's okay to prevent the torrent from expiring here + //since the session can't be destructed while + //we hold a shared_ptr to the downloader. + if (TorrentSP torrent = _torrent.lock()) { + PeerEntries peers = getPeers(downloader); + + if (!peers.empty()) { + torrent->session().m_io_service.dispatch( + [torrent_weak_ptr = _torrent, trackerRequest = _trackerRequest, peers = peers]() mutable { + if (auto torrent_sp = torrent_weak_ptr.lock()) { + torrent_sp->tracker_response( + trackerRequest, + libtorrent::address(), + std::list<libtorrent::address>(), + peers, + -1, -1, -1, -1, -1, + libtorrent::address(), "trackerid"); + } + }); + } + + if (peers.size() < 5) { + reschedule(); } } } +} +#pragma GCC diagnostic pop - PeerEntries getPeers(const std::shared_ptr<FileDownloader>& downloader) { - std::string fileReference = downloader->infoHash2FileReference(_trackerRequest.info_hash); - - const size_t recommendedMaxNumberOfPeers = 30; - PeerEntries peers = _model->getPeers(fileReference, recommendedMaxNumberOfPeers); +PeerEntries +TrackingTask::getPeers(const std::shared_ptr<FileDownloader>& downloader) { + std::string fileReference = downloader->infoHash2FileReference(_trackerRequest.info_hash); - //currently, libtorrent stops working if it tries to connect to itself. - filterSelf(peers, downloader->_hostName, downloader->_port); - resolveIPAddresses(peers); - for (const auto& peer: peers) { - LOG(debug, "Returning peer with ip %s", peer.ip.c_str()); - } + const size_t recommendedMaxNumberOfPeers = 30; + PeerEntries peers = _model->getPeers(fileReference, recommendedMaxNumberOfPeers); - return peers; + //currently, libtorrent stops working if it tries to connect to itself. + filterSelf(peers, downloader->_hostName, downloader->_port); + resolveIPAddresses(peers); + for (const auto& peer: peers) { + LOG(debug, "Returning peer with ip %s", peer.ip.c_str()); } - void reschedule() { - if (_numTimesRescheduled < 5) { - double fudgeFactor = 0.1; - schedule(boost::posix_time::seconds(static_cast<int>( - std::pow(3., _numTimesRescheduled) + fudgeFactor))); - _numTimesRescheduled++; - } + return peers; +} + +void +TrackingTask::reschedule() { + if (_numTimesRescheduled < 5) { + double fudgeFactor = 0.1; + schedule(boost::posix_time::seconds(static_cast<int>( + std::pow(3., _numTimesRescheduled) + fudgeFactor))); + _numTimesRescheduled++; } -}; +} } //anonymous namespace diff --git a/juniper/src/test/auxTest.cpp b/juniper/src/test/auxTest.cpp index 99ccd24af35..4b1274cb2a6 100644 --- a/juniper/src/test/auxTest.cpp +++ b/juniper/src/test/auxTest.cpp @@ -696,6 +696,32 @@ AuxTest::assertChar(ucs4_t act, char exp) return _test((char) act == exp); } +typedef std::unique_ptr<QueryNode> QueryNodeUP; +struct QB { + QueryNodeUP q; + QB(size_t numTerms) : q(new QueryNode(numTerms, 0, 0)) {} + QB(QB & rhs) : q(std::move(rhs.q)) { } + QB & add(const char * t, bool st = true) { + QueryTerm * qt = new QueryTerm(t, strlen(t), 0); + if (st) qt->_options |= X_SPECIALTOKEN; + q->AddChild(qt); + return *this; + } +}; +struct Ctx { + std::string text; + QB qb; + SpecialTokenRegistry str; + Fast_NormalizeWordFolder wf; + TokenProcessor tp; + JuniperTokenizer jt; + Ctx(const std::string & text_, QB & qb_); + ~Ctx(); +}; + +Ctx::Ctx(const std::string & text_, QB & qb_) : text(text_), qb(qb_), str(qb.q.get()), wf(), tp(text), jt(&wf, text.c_str(), text.size(), &tp, &str) { jt.scan(); } +Ctx::~Ctx() { } + void AuxTest::TestSpecialTokenRegistry() { @@ -775,27 +801,6 @@ AuxTest::TestSpecialTokenRegistry() } } { // test tokenizer with special token registry - typedef std::unique_ptr<QueryNode> QueryNodeUP; - struct QB { - QueryNodeUP q; - QB(size_t numTerms) : q(new QueryNode(numTerms, 0, 0)) {} - QB(QB & rhs) : q(std::move(rhs.q)) { } - QB & add(const char * t, bool st = true) { - QueryTerm * qt = new QueryTerm(t, strlen(t), 0); - if (st) qt->_options |= X_SPECIALTOKEN; - q->AddChild(qt); - return *this; - } - }; - struct Ctx { - std::string text; - QB qb; - SpecialTokenRegistry str; - Fast_NormalizeWordFolder wf; - TokenProcessor tp; - JuniperTokenizer jt; - Ctx(const std::string & text_, QB & qb_) : text(text_), qb(qb_), str(qb.q.get()), wf(), tp(text), jt(&wf, text.c_str(), text.size(), &tp, &str) { jt.scan(); } - }; { // only special token registered Ctx c("foo", QB(2).add("c++").add("foo", false)); diff --git a/memfilepersistence/src/vespa/memfilepersistence/device/directory.cpp b/memfilepersistence/src/vespa/memfilepersistence/device/directory.cpp index 9c03e1eb449..a108ad4d4d9 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/device/directory.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/device/directory.cpp @@ -49,8 +49,13 @@ namespace { std::string path; Device::State status; std::string description; + Entry(); + ~Entry(); }; + Entry::Entry() {} + Entry::~Entry() {} + Entry parseDirectoryString(const std::string& serialized) { while (1) { Entry e; diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.cpp b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.cpp index 7622f421331..3c10efdf0c9 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.cpp @@ -154,6 +154,12 @@ SimpleMemFileIOBuffer::HeaderChunkEncoder::bufferDocument(const Document& doc) doc.serializeHeader(_serializedDoc); } +SimpleMemFileIOBuffer::HeaderChunkEncoder::HeaderChunkEncoder(const document::DocumentId& docId) + : _serializedDoc(DEFAULT_STREAM_ALLOC_SIZE), + _docId(docId.toString()) +{ } +SimpleMemFileIOBuffer::HeaderChunkEncoder::~HeaderChunkEncoder() {} + /** * Buffer is comprised of the following: * - Document header blob (n bytes) diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h index 4628291352e..3e91916ff0b 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h @@ -157,10 +157,8 @@ public: public: static const size_t DEFAULT_STREAM_ALLOC_SIZE = 5 * 2014; - HeaderChunkEncoder(const document::DocumentId& docId) - : _serializedDoc(DEFAULT_STREAM_ALLOC_SIZE), - _docId(docId.toString()) - { } + HeaderChunkEncoder(const document::DocumentId& docId); + ~HeaderChunkEncoder(); /** * Serializes header chunk to buf, which must have at least a size diff --git a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp index 1893dc041b2..f3eb1429207 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp @@ -46,48 +46,53 @@ namespace { std::string docId; // bool useConstructor; - CmdOptions(int argc, const char* const* argv) - : vespalib::ProgramOptions(argc, argv), - showSyntaxPage(false) - { - setSyntaxMessage( - "Utility program for showing the contents of the slotfiles " - "used by Vespa Document Storage in a user readable format. " - "Intended for debugging purposes." - ); - addOption("h help", showSyntaxPage, false, - "Shows this help page"); - addOption("n noheader", printHeader, true, - "If given, the header block content is not shown"); - addOption("N nobody", printBody, true, - "If given, the body block content is not shown"); - addOption("f friendly", userFriendlyOutput, false, - "Gives less compact, but more user friendly output"); - addOption("x toxml", toXml, false, - "Print document XML of contained documents"); - addOption("b tobinary", toBinary, false, - "Print binary representations of contained documents"); - addOption("includeremoveddocs", includeRemovedDocs, false, - "When showing XML, include documents that are still in " - "the file, but have been removed."); - addOption("includeremoveentries", includeRemoveEntries, false, - "When showing XML, include remove entries."); - addOption("c documentconfig", documentManConfigId, - std::string("client"), - "The document config to use, needed if deserializing " - "documents."); + CmdOptions(int argc, const char* const* argv); + ~CmdOptions(); + + }; + + CmdOptions::CmdOptions(int argc, const char* const* argv) + : vespalib::ProgramOptions(argc, argv), + showSyntaxPage(false) + { + setSyntaxMessage( + "Utility program for showing the contents of the slotfiles " + "used by Vespa Document Storage in a user readable format. " + "Intended for debugging purposes." + ); + addOption("h help", showSyntaxPage, false, + "Shows this help page"); + addOption("n noheader", printHeader, true, + "If given, the header block content is not shown"); + addOption("N nobody", printBody, true, + "If given, the body block content is not shown"); + addOption("f friendly", userFriendlyOutput, false, + "Gives less compact, but more user friendly output"); + addOption("x toxml", toXml, false, + "Print document XML of contained documents"); + addOption("b tobinary", toBinary, false, + "Print binary representations of contained documents"); + addOption("includeremoveddocs", includeRemovedDocs, false, + "When showing XML, include documents that are still in " + "the file, but have been removed."); + addOption("includeremoveentries", includeRemoveEntries, false, + "When showing XML, include remove entries."); + addOption("c documentconfig", documentManConfigId, + std::string("client"), + "The document config to use, needed if deserializing " + "documents."); // addOption("s sort", metaDataSort, std::string("none"), // "How to sort metadatalist. Valid arguments: " // "bodypos, headerpos & none."); - addOption("t time", timestampToShow, uint64_t(0), - "If set, only present data related to this timestamp, " - "when outputting XML or binary data."); - addOption("docid", docId, std::string(""), - "Retrieve single document using get semantics"); + addOption("t time", timestampToShow, uint64_t(0), + "If set, only present data related to this timestamp, " + "when outputting XML or binary data."); + addOption("docid", docId, std::string(""), + "Retrieve single document using get semantics"); // addOption("useconstructor", useConstructor, false, "Debug option"); - addArgument("slotfile", filename, "The slotfile to dump."); - } - }; + addArgument("slotfile", filename, "The slotfile to dump."); + } + CmdOptions::~CmdOptions() { } void printDoc(document::Document& doc, CmdOptions& o) { if (o.toXml) { @@ -154,41 +159,8 @@ namespace { std::unique_ptr<Environment> _env; EnvironmentImpl(config::ConfigUri& externalConfig, - const char* documentConfigId) - : _compReg(), - _component(_compReg, "dumpslotfile"), - _clock(), - _metrics(_component), - _threadMetrics(_metrics.addThreadMetrics()), - _cache(), - _mapper(*this), - _deviceManager(DeviceMapper::UP(new SimpleDeviceMapper), _clock), - _docType("foo", 1) - { - _compReg.setClock(_clock); - _compReg.setMemoryManager(_memoryMan); - _cache.reset(new MemFileCache(_compReg, _metrics._cache)); - if (documentConfigId == 0) { - _repo.reset(new DocumentTypeRepo(_docType)); - } else { - config::ConfigUri uri( - externalConfig.createWithNewId(documentConfigId)); - std::unique_ptr<document::DocumenttypesConfig> config( - ConfigGetter<DocumenttypesConfig>::getConfig( - uri.getConfigId(), uri.getContext())); - _repo.reset(new DocumentTypeRepo(*config)); - } - _deviceConfig.rootFolder = "."; - std::string configId("defaultId"); - _configSet.addBuilder(configId, &_memFileConfig); - _configSet.addBuilder(configId, &_persistenceConfig); - _configSet.addBuilder(configId, &_deviceConfig); - _configContext.reset(new config::ConfigContext(_configSet)); - _internalConfig.reset( - new config::ConfigUri(configId, _configContext)); - _env.reset(new Environment( - *_internalConfig, *_cache, _mapper, *_repo, _clock, true)); - } + const char* documentConfigId); + ~EnvironmentImpl(); MemFilePersistenceThreadMetrics& getMetrics() const { return *_threadMetrics; @@ -196,6 +168,43 @@ namespace { }; + EnvironmentImpl::EnvironmentImpl(config::ConfigUri& externalConfig, const char* documentConfigId) + : _compReg(), + _component(_compReg, "dumpslotfile"), + _clock(), + _metrics(_component), + _threadMetrics(_metrics.addThreadMetrics()), + _cache(), + _mapper(*this), + _deviceManager(DeviceMapper::UP(new SimpleDeviceMapper), _clock), + _docType("foo", 1) + { + _compReg.setClock(_clock); + _compReg.setMemoryManager(_memoryMan); + _cache.reset(new MemFileCache(_compReg, _metrics._cache)); + if (documentConfigId == 0) { + _repo.reset(new DocumentTypeRepo(_docType)); + } else { + config::ConfigUri uri( + externalConfig.createWithNewId(documentConfigId)); + std::unique_ptr<document::DocumenttypesConfig> config( + ConfigGetter<DocumenttypesConfig>::getConfig( + uri.getConfigId(), uri.getContext())); + _repo.reset(new DocumentTypeRepo(*config)); + } + _deviceConfig.rootFolder = "."; + std::string configId("defaultId"); + _configSet.addBuilder(configId, &_memFileConfig); + _configSet.addBuilder(configId, &_persistenceConfig); + _configSet.addBuilder(configId, &_deviceConfig); + _configContext.reset(new config::ConfigContext(_configSet)); + _internalConfig.reset( + new config::ConfigUri(configId, _configContext)); + _env.reset(new Environment( + *_internalConfig, *_cache, _mapper, *_repo, _clock, true)); + } + EnvironmentImpl::~EnvironmentImpl() {} + } int SlotFileDumper::dump(int argc, const char * const * argv, diff --git a/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp b/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp index 0011dddd421..ad9b08f4994 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp @@ -123,6 +123,7 @@ struct CmdLineOptions : public vespalib::ProgramOptions { "Required when disabling a disk, such that other " "administrators can see why it has happened."); } + ~CmdLineOptions(); vector<std::string> listDir(const std::string& dir) { DIR* dirp = opendir(dir.c_str()); @@ -313,6 +314,7 @@ struct CmdLineOptions : public vespalib::ProgramOptions { }; +CmdLineOptions::~CmdLineOptions() {} int VdsDiskTool::run(int argc, const char * const * argv, diff --git a/messagebus/src/tests/advancedrouting/advancedrouting.cpp b/messagebus/src/tests/advancedrouting/advancedrouting.cpp index 384c9be667f..26e62ca7956 100644 --- a/messagebus/src/tests/advancedrouting/advancedrouting.cpp +++ b/messagebus/src/tests/advancedrouting/advancedrouting.cpp @@ -32,6 +32,7 @@ public: public: TestData(); + ~TestData(); bool start(); }; @@ -47,6 +48,7 @@ public: TEST_APPHOOK(Test); +TestData::~TestData() {} TestData::TestData() : _slobrok(), _retryPolicy(new RetryTransientErrorsPolicy()), diff --git a/messagebus/src/tests/choke/choke.cpp b/messagebus/src/tests/choke/choke.cpp index 023554250cc..4c223f6a55a 100644 --- a/messagebus/src/tests/choke/choke.cpp +++ b/messagebus/src/tests/choke/choke.cpp @@ -30,6 +30,7 @@ public: public: TestData(); + ~TestData(); bool start(); }; @@ -65,6 +66,8 @@ TestData::TestData() : // empty } +TestData::~TestData() {} + bool TestData::start() { diff --git a/messagebus/src/tests/messageordering/messageordering.cpp b/messagebus/src/tests/messageordering/messageordering.cpp index a502769a9e8..0c102915cb1 100644 --- a/messagebus/src/tests/messageordering/messageordering.cpp +++ b/messagebus/src/tests/messageordering/messageordering.cpp @@ -88,51 +88,60 @@ class VerifyReplyReceptor : public IReplyHandler std::string _failure; int _replyCount; public: - VerifyReplyReceptor() - : _mon(), - _failure(), - _replyCount(0) - {} - void handleReply(Reply::UP reply) - { - vespalib::MonitorGuard lock(_mon); - if (reply->hasErrors()) { - std::ostringstream ss; - ss << "Reply failed with " - << reply->getError(0).getMessage() - << "\n" - << reply->getTrace().toString(); + ~VerifyReplyReceptor(); + VerifyReplyReceptor(); + void handleReply(Reply::UP reply); + void waitUntilDone(int waitForCount) const; + const std::string& getFailure() const { return _failure; } +}; + +VerifyReplyReceptor::~VerifyReplyReceptor() {} +VerifyReplyReceptor::VerifyReplyReceptor() + : _mon(), + _failure(), + _replyCount(0) +{} + +void +VerifyReplyReceptor::handleReply(Reply::UP reply) +{ + vespalib::MonitorGuard lock(_mon); + if (reply->hasErrors()) { + std::ostringstream ss; + ss << "Reply failed with " + << reply->getError(0).getMessage() + << "\n" + << reply->getTrace().toString(); + if (_failure.empty()) { + _failure = ss.str(); + } + LOG(warning, "%s", ss.str().c_str()); + } else { + vespalib::string expected(vespalib::make_vespa_string("%d", _replyCount)); + SimpleReply& simpleReply(static_cast<SimpleReply&>(*reply)); + if (simpleReply.getValue() != expected) { + std::stringstream ss; + ss << "Received out-of-sequence reply! Expected " + << expected + << ", but got " + << simpleReply.getValue(); + LOG(warning, "%s", ss.str().c_str()); if (_failure.empty()) { _failure = ss.str(); } - LOG(warning, "%s", ss.str().c_str()); - } else { - vespalib::string expected(vespalib::make_vespa_string("%d", _replyCount)); - SimpleReply& simpleReply(static_cast<SimpleReply&>(*reply)); - if (simpleReply.getValue() != expected) { - std::stringstream ss; - ss << "Received out-of-sequence reply! Expected " - << expected - << ", but got " - << simpleReply.getValue(); - LOG(warning, "%s", ss.str().c_str()); - if (_failure.empty()) { - _failure = ss.str(); - } - } } - ++_replyCount; - lock.broadcast(); } - void waitUntilDone(int waitForCount) const - { - vespalib::MonitorGuard lock(_mon); - while (_replyCount < waitForCount) { - lock.wait(1000); - } + ++_replyCount; + lock.broadcast(); +} +void +VerifyReplyReceptor::waitUntilDone(int waitForCount) const +{ + vespalib::MonitorGuard lock(_mon); + while (_replyCount < waitForCount) { + lock.wait(1000); } - const std::string& getFailure() const { return _failure; } -}; +} int Test::Main() diff --git a/messagebus/src/tests/resender/resender.cpp b/messagebus/src/tests/resender/resender.cpp index a067616d1ba..c559f244a62 100644 --- a/messagebus/src/tests/resender/resender.cpp +++ b/messagebus/src/tests/resender/resender.cpp @@ -55,6 +55,7 @@ public: Receptor _dstHandler; public: + ~TestData(); TestData(); bool start(); }; @@ -88,9 +89,9 @@ TestData::TestData() : RPCNetworkParams().setIdentity(Identity("dst")).setSlobrokConfig(_slobrok.config())), _dstSession(), _dstHandler() -{ - // empty -} +{ } + +TestData::~TestData() {} bool TestData::start() diff --git a/messagebus/src/tests/routing/routing.cpp b/messagebus/src/tests/routing/routing.cpp index 23698279137..be0a69e855a 100644 --- a/messagebus/src/tests/routing/routing.cpp +++ b/messagebus/src/tests/routing/routing.cpp @@ -476,6 +476,7 @@ public: public: TestData(); + ~TestData(); bool start(); }; @@ -570,6 +571,8 @@ TestData::TestData() : _retryPolicy->setBaseDelay(0); } +TestData::~TestData() {} + bool TestData::start() { diff --git a/messagebus/src/tests/routingcontext/routingcontext.cpp b/messagebus/src/tests/routingcontext/routingcontext.cpp index 02c7ef6dd72..d8d76a3069c 100644 --- a/messagebus/src/tests/routingcontext/routingcontext.cpp +++ b/messagebus/src/tests/routingcontext/routingcontext.cpp @@ -202,6 +202,7 @@ public: public: TestData(); + ~TestData(); bool start(); }; @@ -234,6 +235,8 @@ TestData::TestData() : _retryPolicy->setBaseDelay(0); } +TestData::~TestData() {} + bool TestData::start() { diff --git a/messagebus/src/tests/sendadapter/sendadapter.cpp b/messagebus/src/tests/sendadapter/sendadapter.cpp index b25240acdac..f4973b96e31 100644 --- a/messagebus/src/tests/sendadapter/sendadapter.cpp +++ b/messagebus/src/tests/sendadapter/sendadapter.cpp @@ -55,6 +55,7 @@ public: public: TestData(); + ~TestData(); bool start(); }; @@ -91,9 +92,9 @@ TestData::TestData() : RPCNetworkParams().setIdentity(Identity("dst")).setSlobrokConfig(_slobrok.config())), _dstSession(), _dstHandler() -{ - // empty -} +{ } + +TestData::~TestData() {} bool TestData::start() diff --git a/messagebus/src/vespa/messagebus/error.cpp b/messagebus/src/vespa/messagebus/error.cpp index 7bbe47319f2..215edaaa938 100644 --- a/messagebus/src/vespa/messagebus/error.cpp +++ b/messagebus/src/vespa/messagebus/error.cpp @@ -11,6 +11,8 @@ Error::Error() _service() { } +Error::~Error() {} + Error::Error(uint32_t c, const string &m, const string &s) : _code(c), _msg(m), diff --git a/messagebus/src/vespa/messagebus/error.h b/messagebus/src/vespa/messagebus/error.h index f94e6532307..d67442c054c 100644 --- a/messagebus/src/vespa/messagebus/error.h +++ b/messagebus/src/vespa/messagebus/error.h @@ -28,6 +28,7 @@ public: * for standard library containers. **/ Error(); + ~Error(); /** * Create a new error with the given code and message diff --git a/messagebus/src/vespa/messagebus/messagebusparams.cpp b/messagebus/src/vespa/messagebus/messagebusparams.cpp index c8efe9f97bd..14edd24a3e0 100644 --- a/messagebus/src/vespa/messagebus/messagebusparams.cpp +++ b/messagebus/src/vespa/messagebus/messagebusparams.cpp @@ -9,9 +9,9 @@ MessageBusParams::MessageBusParams() : _retryPolicy(new RetryTransientErrorsPolicy()), _maxPendingCount(1024), _maxPendingSize(128 * 1024 * 1024) -{ - // empty -} +{ } + +MessageBusParams::~MessageBusParams() {} uint32_t MessageBusParams::getNumProtocols() const diff --git a/messagebus/src/vespa/messagebus/messagebusparams.h b/messagebus/src/vespa/messagebus/messagebusparams.h index 6dbcfb8781f..b6b8accf793 100644 --- a/messagebus/src/vespa/messagebus/messagebusparams.h +++ b/messagebus/src/vespa/messagebus/messagebusparams.h @@ -29,6 +29,7 @@ public: * Constructs a new instance of this parameter object with default values for all members. */ MessageBusParams(); + ~MessageBusParams(); /** * Returns the retry policy for the resender. diff --git a/messagebus/src/vespa/messagebus/network/rpcsendv1.cpp b/messagebus/src/vespa/messagebus/network/rpcsendv1.cpp index 34f979c00be..c62b1c3f0b8 100644 --- a/messagebus/src/vespa/messagebus/network/rpcsendv1.cpp +++ b/messagebus/src/vespa/messagebus/network/rpcsendv1.cpp @@ -66,9 +66,9 @@ RPCSendV1::RPCSendV1() : _net(NULL), _clientIdent("client"), _serverIdent("server") -{ - // empty -} +{ } + +RPCSendV1::~RPCSendV1() {} void RPCSendV1::attach(RPCNetwork &net) diff --git a/messagebus/src/vespa/messagebus/network/rpcsendv1.h b/messagebus/src/vespa/messagebus/network/rpcsendv1.h index 570b3daff82..8ea63f39403 100644 --- a/messagebus/src/vespa/messagebus/network/rpcsendv1.h +++ b/messagebus/src/vespa/messagebus/network/rpcsendv1.h @@ -56,6 +56,7 @@ public: * its attach() method has been called. */ RPCSendV1(); + ~RPCSendV1(); // Implements RPCSendAdapter. void attach(RPCNetwork &net) override; diff --git a/messagebus/src/vespa/messagebus/routing/routingtablespec.cpp b/messagebus/src/vespa/messagebus/routing/routingtablespec.cpp index 06d1aa73d60..9c8c7ac93a9 100644 --- a/messagebus/src/vespa/messagebus/routing/routingtablespec.cpp +++ b/messagebus/src/vespa/messagebus/routing/routingtablespec.cpp @@ -8,9 +8,9 @@ RoutingTableSpec::RoutingTableSpec(const string &protocol) : _protocol(protocol), _hops(), _routes() -{ - // empty -} +{ } + +RoutingTableSpec::~RoutingTableSpec() {} HopSpec RoutingTableSpec::removeHop(uint32_t i) diff --git a/messagebus/src/vespa/messagebus/routing/routingtablespec.h b/messagebus/src/vespa/messagebus/routing/routingtablespec.h index 993031a0adf..8e59ce311a7 100644 --- a/messagebus/src/vespa/messagebus/routing/routingtablespec.h +++ b/messagebus/src/vespa/messagebus/routing/routingtablespec.h @@ -31,6 +31,7 @@ public: * @param protocol The name of the protocol that this belongs to. */ RoutingTableSpec(const string &protocol); + ~RoutingTableSpec(); /** * Returns the name of the protocol that this is the routing table for. diff --git a/metrics/src/tests/metricmanagertest.cpp b/metrics/src/tests/metricmanagertest.cpp index 72a4a287f2c..7159207e0ff 100644 --- a/metrics/src/tests/metricmanagertest.cpp +++ b/metrics/src/tests/metricmanagertest.cpp @@ -63,17 +63,22 @@ struct SubMetricSet : public MetricSet DoubleValueMetric val2; SumMetric<DoubleValueMetric> valsum; - SubMetricSet(const Metric::String & name, MetricSet* owner) - : MetricSet(name, "sub", "sub desc", owner, "sub"), - val1("val1", "tag4 snaptest", "val1 desc", this), - val2("val2", "tag5", "val2 desc", this), - valsum("valsum", "tag4 snaptest", "valsum desc", this) - { - valsum.addMetricToSum(val1); - valsum.addMetricToSum(val2); - } + SubMetricSet(const Metric::String & name, MetricSet* owner); + ~SubMetricSet(); }; + +SubMetricSet::SubMetricSet(const Metric::String & name, MetricSet* owner) + : MetricSet(name, "sub", "sub desc", owner, "sub"), + val1("val1", "tag4 snaptest", "val1 desc", this), + val2("val2", "tag5", "val2 desc", this), + valsum("valsum", "tag4 snaptest", "valsum desc", this) +{ + valsum.addMetricToSum(val1); + valsum.addMetricToSum(val2); +} +SubMetricSet::~SubMetricSet() { } + struct MultiSubMetricSet { MetricSet set; @@ -82,21 +87,23 @@ struct MultiSubMetricSet SubMetricSet b; SumMetric<MetricSet> sum; - MultiSubMetricSet(MetricSet* owner) - : set("multisub", "multisub", "", owner), - count("count", "snaptest", "counter", &set), - a("a", &set), - b("b", &set), - sum("sum", "snaptest", "", &set) - { - sum.addMetricToSum(a); - sum.addMetricToSum(b); - } - + MultiSubMetricSet(MetricSet* owner); + ~MultiSubMetricSet(); }; -struct TestMetricSet +MultiSubMetricSet::MultiSubMetricSet(MetricSet* owner) + : set("multisub", "multisub", "", owner), + count("count", "snaptest", "counter", &set), + a("a", &set), + b("b", &set), + sum("sum", "snaptest", "", &set) { + sum.addMetricToSum(a); + sum.addMetricToSum(b); +} + MultiSubMetricSet::~MultiSubMetricSet() { } + +struct TestMetricSet { MetricSet set; DoubleValueMetric val1; DoubleValueMetric val2; @@ -109,23 +116,27 @@ struct TestMetricSet SubMetricSet val9; MultiSubMetricSet val10; - TestMetricSet() - : set("temp", "test", "desc of test set"), - val1("val1", "tag1", "val1 desc", &set), - val2("val2", "tag1 tag2", "val2 desc", &set), - val3("val3", "tag2 tag3", "val3 desc", &set), - val4("val4", "tag3", "val4 desc", &set), - val5("val5", "tag2", "val5 desc", &set), - val6("val6", "tag4 snaptest", "val6 desc", &set), - val7("val7", "", "val7 desc", &set), - val8("val8", "tag6", "val8 desc", &set), - val9("sub", &set), - val10(&set) - { - } - + TestMetricSet(); + ~TestMetricSet(); }; +TestMetricSet::TestMetricSet() + : set("temp", "test", "desc of test set"), + val1("val1", "tag1", "val1 desc", &set), + val2("val2", "tag1 tag2", "val2 desc", &set), + val3("val3", "tag2 tag3", "val3 desc", &set), + val4("val4", "tag3", "val4 desc", &set), + val5("val5", "tag2", "val5 desc", &set), + val6("val6", "tag4 snaptest", "val6 desc", &set), + val7("val7", "", "val7 desc", &set), + val8("val8", "tag6", "val8 desc", &set), + val9("sub", &set), + val10(&set) +{ } + +TestMetricSet::~TestMetricSet() { } + + struct MetricNameVisitor : public MetricVisitor { std::ostringstream ost; bool debug; @@ -898,12 +909,8 @@ class JsonMetricWrapper std::string _jsonText; vespalib::Slime _tree; public: - JsonMetricWrapper(const std::string& jsonText) - : _jsonText(jsonText) - { - vespalib::slime::JsonFormat::decode( - vespalib::Memory(jsonText), _tree); - } + JsonMetricWrapper(const std::string& jsonText); + ~JsonMetricWrapper(); // XXX ideally all these should be const, but is not clear how/if it's // possible to get a const cursor into the underlying tree. @@ -945,20 +952,29 @@ public: } }; +JsonMetricWrapper::JsonMetricWrapper(const std::string& jsonText) + : _jsonText(jsonText) +{ + vespalib::slime::JsonFormat::decode(vespalib::Memory(jsonText), _tree); +} +JsonMetricWrapper::~JsonMetricWrapper() { } + struct DimensionTestMetricSet : MetricSet { DoubleValueMetric val1; LongCountMetric val2; - DimensionTestMetricSet(MetricSet* owner = nullptr) - : MetricSet("temp", {{"foo", "megafoo"}, {"bar", "hyperbar"}}, - "", owner), - val1("val1", "tag1", "val1 desc", this), // Legacy tag; not dimension - val2("val2", {{"baz", "superbaz"}}, "val2 desc", this) - { - } + DimensionTestMetricSet(MetricSet* owner = nullptr); + ~DimensionTestMetricSet(); }; +DimensionTestMetricSet::DimensionTestMetricSet(MetricSet* owner) + : MetricSet("temp", {{"foo", "megafoo"}, {"bar", "hyperbar"}}, "", owner), + val1("val1", "tag1", "val1 desc", this), + val2("val2", {{"baz", "superbaz"}}, "val2 desc", this) +{ } +DimensionTestMetricSet::~DimensionTestMetricSet() { } + } // anon ns void @@ -1027,8 +1043,7 @@ struct DimensionOverridableTestMetricSet : MetricSet MetricSet* owner = nullptr) : MetricSet("temp", {{"foo", dimValue}}, "", owner), val("val", "", "val desc", this) - { - } + { } }; struct SameNamesTestMetricSet : MetricSet @@ -1036,14 +1051,17 @@ struct SameNamesTestMetricSet : MetricSet DimensionOverridableTestMetricSet set1; DimensionOverridableTestMetricSet set2; - SameNamesTestMetricSet() - : MetricSet("outer", {{"fancy", "stuff"}}, ""), - set1("bar", this), - set2("baz", this) - { - } + SameNamesTestMetricSet(); + ~SameNamesTestMetricSet(); }; +SameNamesTestMetricSet::SameNamesTestMetricSet() + : MetricSet("outer", {{"fancy", "stuff"}}, ""), + set1("bar", this), + set2("baz", this) +{ } +SameNamesTestMetricSet::~SameNamesTestMetricSet() { } + } // anon ns void diff --git a/metrics/src/tests/snapshottest.cpp b/metrics/src/tests/snapshottest.cpp index 253b7b4f2de..2527a048df6 100644 --- a/metrics/src/tests/snapshottest.cpp +++ b/metrics/src/tests/snapshottest.cpp @@ -38,63 +38,71 @@ struct SubSubMetricSet : public MetricSet { LoadMetric<DoubleAverageMetric> loadAverage; SumMetric<DoubleAverageMetric> averageSum; - SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, - MetricSet* owner = 0) - : MetricSet(name, "", "", owner), - loadTypes(loadTypes_), - incVal(1), - count1("count1", "", "", this), - count2("count2", "", "", this), - loadCount(loadTypes, LongCountMetric("loadCount", "", ""), this), - countSum("countSum", "", "", this), - value1("value1", "", "", this), - value2("value2", "", "", this), - loadValue(loadTypes, DoubleValueMetric("loadValue", "", ""), this), - valueSum("valueSum", "", "", this), - average1("average1", "", "", this), - average2("average2", "", "", this), - loadAverage(loadTypes, DoubleAverageMetric("loadAverage", "", ""), - this), - averageSum("averageSum", "", "", this) - { - countSum.addMetricToSum(count1); - countSum.addMetricToSum(count2); - valueSum.addMetricToSum(value1); - valueSum.addMetricToSum(value2); - averageSum.addMetricToSum(average1); - averageSum.addMetricToSum(average2); - } + SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0); + ~SubSubMetricSet(); + virtual MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + metrics::MetricSet* owner, bool includeUnused) const; + void incValues(); +}; - virtual MetricSet* clone(std::vector<Metric::LP>& ownerList, - CopyType copyType, metrics::MetricSet* owner, - bool includeUnused) const - { - if (copyType == INACTIVE) { - return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused); - } - return (SubSubMetricSet*) (new SubSubMetricSet( - getName(), loadTypes, owner)) - ->assignValues(*this); +SubSubMetricSet::SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner) + : MetricSet(name, "", "", owner), + loadTypes(loadTypes_), + incVal(1), + count1("count1", "", "", this), + count2("count2", "", "", this), + loadCount(loadTypes, LongCountMetric("loadCount", "", ""), this), + countSum("countSum", "", "", this), + value1("value1", "", "", this), + value2("value2", "", "", this), + loadValue(loadTypes, DoubleValueMetric("loadValue", "", ""), this), + valueSum("valueSum", "", "", this), + average1("average1", "", "", this), + average2("average2", "", "", this), + loadAverage(loadTypes, DoubleAverageMetric("loadAverage", "", ""), this), + averageSum("averageSum", "", "", this) +{ + countSum.addMetricToSum(count1); + countSum.addMetricToSum(count2); + valueSum.addMetricToSum(value1); + valueSum.addMetricToSum(value2); + averageSum.addMetricToSum(average1); + averageSum.addMetricToSum(average2); +} +SubSubMetricSet::~SubSubMetricSet() { } + +MetricSet* +SubSubMetricSet::clone(std::vector<Metric::LP>& ownerList, + CopyType copyType, metrics::MetricSet* owner, + bool includeUnused) const +{ + if (copyType == INACTIVE) { + return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused); } + return (SubSubMetricSet*) (new SubSubMetricSet( + getName(), loadTypes, owner)) + ->assignValues(*this); +} - void incValues() { - count1.inc(incVal); - count2.inc(incVal); - for (uint32_t i=0; i<loadTypes.size(); ++i) { - loadCount[loadTypes[i]].inc(incVal); - } - value1.set(incVal); - value2.set(incVal); - for (uint32_t i=0; i<loadTypes.size(); ++i) { - loadValue[loadTypes[i]].set(incVal); - } - average1.set(incVal); - average2.set(incVal); - for (uint32_t i=0; i<loadTypes.size(); ++i) { - loadAverage[loadTypes[i]].set(incVal); - } +void +SubSubMetricSet::incValues() { + count1.inc(incVal); + count2.inc(incVal); + for (uint32_t i=0; i<loadTypes.size(); ++i) { + loadCount[loadTypes[i]].inc(incVal); } -}; + value1.set(incVal); + value2.set(incVal); + for (uint32_t i=0; i<loadTypes.size(); ++i) { + loadValue[loadTypes[i]].set(incVal); + } + average1.set(incVal); + average2.set(incVal); + for (uint32_t i=0; i<loadTypes.size(); ++i) { + loadAverage[loadTypes[i]].set(incVal); + } +} + struct SubMetricSet : public MetricSet { const LoadTypeSet& loadTypes; @@ -103,39 +111,47 @@ struct SubMetricSet : public MetricSet { LoadMetric<SubSubMetricSet> loadSet; SumMetric<SubSubMetricSet> setSum; - SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, - MetricSet* owner = 0) - : MetricSet(name, "", "", owner), - loadTypes(loadTypes_), - set1("set1", loadTypes, this), - set2("set2", loadTypes, this), - loadSet(loadTypes, *std::unique_ptr<SubSubMetricSet>( - new SubSubMetricSet("loadSet", loadTypes)), this), - setSum("setSum", "", "", this) - { - setSum.addMetricToSum(set1); - setSum.addMetricToSum(set2); - } + SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0); + ~SubMetricSet(); - virtual MetricSet* clone(std::vector<Metric::LP>& ownerList, - CopyType copyType, metrics::MetricSet* owner, - bool includeUnused) const - { - if (copyType == INACTIVE) { - return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused); - } - return (SubMetricSet*) (new SubMetricSet(getName(), loadTypes, owner)) - ->assignValues(*this); + MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + metrics::MetricSet* owner, bool includeUnused) const override; + + void incValues(); +}; + +SubMetricSet::SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner) + : MetricSet(name, "", "", owner), + loadTypes(loadTypes_), + set1("set1", loadTypes, this), + set2("set2", loadTypes, this), + loadSet(loadTypes, *std::unique_ptr<SubSubMetricSet>(new SubSubMetricSet("loadSet", loadTypes)), this), + setSum("setSum", "", "", this) +{ + setSum.addMetricToSum(set1); + setSum.addMetricToSum(set2); +} +SubMetricSet::~SubMetricSet() { } + +MetricSet* +SubMetricSet::clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + metrics::MetricSet* owner, bool includeUnused) const +{ + if (copyType == INACTIVE) { + return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused); } + return (SubMetricSet*) (new SubMetricSet(getName(), loadTypes, owner)) + ->assignValues(*this); +} - void incValues() { - set1.incValues(); - set2.incValues(); - for (uint32_t i=0; i<loadTypes.size(); ++i) { - loadSet[loadTypes[i]].incValues(); - } +void +SubMetricSet::incValues() { + set1.incValues(); + set2.incValues(); + for (uint32_t i=0; i<loadTypes.size(); ++i) { + loadSet[loadTypes[i]].incValues(); } -}; +} struct TestMetricSet : public MetricSet { const LoadTypeSet& loadTypes; @@ -144,29 +160,35 @@ struct TestMetricSet : public MetricSet { LoadMetric<SubMetricSet> loadSet; SumMetric<SubMetricSet> setSum; - TestMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, - MetricSet* owner = 0) - : MetricSet(name, "", "", owner), - loadTypes(loadTypes_), - set1("set1", loadTypes, this), - set2("set2", loadTypes, this), - loadSet(loadTypes, *std::unique_ptr<SubMetricSet>( - new SubMetricSet("loadSet", loadTypes)), this), - setSum("setSum", "", "", this) - { - setSum.addMetricToSum(set1); - setSum.addMetricToSum(set2); - } + TestMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0); + ~TestMetricSet(); - void incValues() { - set1.incValues(); - set2.incValues(); - for (uint32_t i=0; i<loadTypes.size(); ++i) { - loadSet[loadTypes[i]].incValues(); - } - } + void incValues(); }; + +TestMetricSet::TestMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner) + : MetricSet(name, "", "", owner), + loadTypes(loadTypes_), + set1("set1", loadTypes, this), + set2("set2", loadTypes, this), + loadSet(loadTypes, *std::unique_ptr<SubMetricSet>(new SubMetricSet("loadSet", loadTypes)), this), + setSum("setSum", "", "", this) +{ + setSum.addMetricToSum(set1); + setSum.addMetricToSum(set2); +} +TestMetricSet::~TestMetricSet() { } + +void +TestMetricSet::incValues() { + set1.incValues(); + set2.incValues(); + for (uint32_t i=0; i<loadTypes.size(); ++i) { + loadSet[loadTypes[i]].incValues(); + } +} + struct FakeTimer : public MetricManager::Timer { uint32_t _timeInSecs; diff --git a/metrics/src/tests/stresstest.cpp b/metrics/src/tests/stresstest.cpp index a0e56289d4d..9eb13e00a79 100644 --- a/metrics/src/tests/stresstest.cpp +++ b/metrics/src/tests/stresstest.cpp @@ -22,58 +22,72 @@ struct StressTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE_REGISTRATION(StressTest); namespace { - struct InnerMetricSet : public MetricSet { - const LoadTypeSet& _loadTypes; - LongCountMetric _count; - LongAverageMetric _value1; - LongAverageMetric _value2; - SumMetric<LongAverageMetric> _valueSum; - LoadMetric<LongAverageMetric> _load; - - InnerMetricSet(const char* name, const LoadTypeSet& lt, - MetricSet* owner = 0) - : MetricSet(name, "", "", owner), - _loadTypes(lt), - _count("count", "", "", this), - _value1("value1", "", "", this), - _value2("value2", "", "", this), - _valueSum("valuesum", "", "", this), - _load(lt, LongAverageMetric("load", "", ""), this) - { - _valueSum.addMetricToSum(_value1); - _valueSum.addMetricToSum(_value2); - } +struct InnerMetricSet : public MetricSet { + const LoadTypeSet& _loadTypes; + LongCountMetric _count; + LongAverageMetric _value1; + LongAverageMetric _value2; + SumMetric<LongAverageMetric> _valueSum; + LoadMetric<LongAverageMetric> _load; + + InnerMetricSet(const char* name, const LoadTypeSet& lt, MetricSet* owner = 0); + ~InnerMetricSet(); + + MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + MetricSet* owner, bool includeUnused) const override; +}; + +InnerMetricSet::InnerMetricSet(const char* name, const LoadTypeSet& lt, MetricSet* owner) + : MetricSet(name, "", "", owner), + _loadTypes(lt), + _count("count", "", "", this), + _value1("value1", "", "", this), + _value2("value2", "", "", this), + _valueSum("valuesum", "", "", this), + _load(lt, LongAverageMetric("load", "", ""), this) +{ + _valueSum.addMetricToSum(_value1); + _valueSum.addMetricToSum(_value2); +} +InnerMetricSet::~InnerMetricSet() { } + + MetricSet* + InnerMetricSet::clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + MetricSet* owner, bool includeUnused) const +{ + if (copyType != CLONE) { + return MetricSet::clone(ownerList, copyType, owner, includeUnused); +} + InnerMetricSet * myset = new InnerMetricSet(getName().c_str(), _loadTypes, owner); + myset->assignValues(*this); + return myset; +} + +struct OuterMetricSet : public MetricSet { + InnerMetricSet _inner1; + InnerMetricSet _inner2; + SumMetric<InnerMetricSet> _innerSum; + InnerMetricSet _tmp; + LoadMetric<InnerMetricSet> _load; + + OuterMetricSet(const LoadTypeSet& lt, MetricSet* owner = 0); + ~OuterMetricSet(); +}; + +OuterMetricSet::OuterMetricSet(const LoadTypeSet& lt, MetricSet* owner) + : MetricSet("outer", "", "", owner), + _inner1("inner1", lt, this), + _inner2("inner2", lt, this), + _innerSum("innersum", "", "", this), + _tmp("innertmp", lt, 0), + _load(lt, _tmp, this) +{ + _innerSum.addMetricToSum(_inner1); + _innerSum.addMetricToSum(_inner2); +} + +OuterMetricSet::~OuterMetricSet() { } - MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType, - MetricSet* owner, bool includeUnused) const override - { - if (copyType != CLONE) { - return MetricSet::clone(ownerList, copyType, owner, includeUnused); - } - InnerMetricSet * myset = new InnerMetricSet(getName().c_str(), _loadTypes, owner); - myset->assignValues(*this); - return myset; - } - }; - struct OuterMetricSet : public MetricSet { - InnerMetricSet _inner1; - InnerMetricSet _inner2; - SumMetric<InnerMetricSet> _innerSum; - InnerMetricSet _tmp; - LoadMetric<InnerMetricSet> _load; - - OuterMetricSet(const LoadTypeSet& lt, MetricSet* owner = 0) - : MetricSet("outer", "", "", owner), - _inner1("inner1", lt, this), - _inner2("inner2", lt, this), - _innerSum("innersum", "", "", this), - _tmp("innertmp", lt, 0), - _load(lt, _tmp, this) - { - _innerSum.addMetricToSum(_inner1); - _innerSum.addMetricToSum(_inner2); - } - }; struct Hammer : public document::Runnable { typedef vespalib::LinkedPtr<Hammer> LP; diff --git a/metrics/src/vespa/metrics/CMakeLists.txt b/metrics/src/vespa/metrics/CMakeLists.txt index cd5a5ba4629..f93c1fb63c8 100644 --- a/metrics/src/vespa/metrics/CMakeLists.txt +++ b/metrics/src/vespa/metrics/CMakeLists.txt @@ -13,6 +13,7 @@ vespa_add_library(metrics metrictimer.cpp metricvalueset.cpp namehash.cpp + printutils.cpp state_api_adapter.cpp summetric.cpp textwriter.cpp diff --git a/metrics/src/vespa/metrics/printutils.cpp b/metrics/src/vespa/metrics/printutils.cpp new file mode 100644 index 00000000000..74db31de1ad --- /dev/null +++ b/metrics/src/vespa/metrics/printutils.cpp @@ -0,0 +1,277 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "printutils.h" + +namespace metrics { +namespace printutils { + +typedef std::pair<int64_t, bool> LongValue; +typedef std::pair<double, bool> DoubleValue; + +MetricSource::MetricSource(const MetricSnapshot& s, + const String& metricsPrefix, + std::map<String, Metric::SP>* metricsAccessed) + : _snapshot(s), + _metricsPrefix(metricsPrefix), + _metricsAccessedOwner(), + _metricsAccessed(metricsAccessed == 0 ? _metricsAccessedOwner + : *metricsAccessed) +{ +} + +MetricSource::~MetricSource() {} + +Metric::String +MetricSource::createAbsoluteMetricName(const String& name) const { + String prefix = _metricsPrefix; + String addition = name; + while (addition.find("../") == 0) { + String::size_type pos1 = prefix.rfind('.'); + if (pos1 == String::npos) + throw vespalib::IllegalArgumentException( + "Cannot go back anymore in path " + prefix, + VESPA_STRLOC); + prefix = prefix.substr(0, pos1); + addition = addition.substr(3); + } + return (prefix.empty() ? addition : prefix + "." + addition); +} + +MetricSource::SourceMetricVisitor::SourceMetricVisitor(const String& path, bool prefixMatch) + : _stringPath(path), + _path(vespalib::StringTokenizer(path, ".").getTokens()), + _pathIndex(-1), + _resultMetric(), + _prefixMatch(prefixMatch), + _prefixMatches() +{ +} + +MetricSource::SourceMetricVisitor::~SourceMetricVisitor() { } + +void +MetricSource::SourceMetricVisitor::checkForPrefixMatch(const Metric& metric) { + if (metric.getName().size() >= _path[_pathIndex].size()) { + if (metric.getName().find(_path[_pathIndex]) == 0) { + _prefixMatches.push_back(metric.getName()); + } + } +} + +bool +MetricSource::SourceMetricVisitor::visitMetricSet(const MetricSet& set, bool) { + if (_pathIndex == -1) { + _pathIndex = 0; + return true; + } + if (_prefixMatch + && static_cast<size_t>(_pathIndex + 1) == _path.size()) + { + for (const Metric * entry : set.getRegisteredMetrics()) { + checkForPrefixMatch(*entry); + } + return false; + } + if (set.getName() != _path[_pathIndex]) return false; + if (static_cast<size_t>(++_pathIndex) >= _path.size()) { + throw vespalib::IllegalArgumentException( + "Path " + _stringPath + " points to a metric set. " + "Only primitive metrics can be retrieved.", + VESPA_STRLOC); + } + return true; +} +bool +MetricSource::SourceMetricVisitor::visitMetric(const Metric& metric, bool) { + if (_prefixMatch) { + checkForPrefixMatch(metric); + } + if (_path[_pathIndex] != metric.getName()) { + return true; + } + if (_prefixMatch) { + throw vespalib::IllegalArgumentException( + "Cannot find existing entries with prefix " + + _stringPath + " since element " + metric.getName() + + " is not a metric set", VESPA_STRLOC); + } + if (static_cast<size_t>(_pathIndex + 1) < _path.size()) { + throw vespalib::IllegalArgumentException( + "Path " + _stringPath + " cannot exist since element " + + _path[_pathIndex] + " is not a metric set: " + + metric.toString(), + VESPA_STRLOC); + } + std::vector<Metric::LP> ownerList; + _resultMetric.reset(metric.clone(ownerList, Metric::INACTIVE, 0)); + if (!ownerList.empty()) { + throw vespalib::IllegalArgumentException( + "Metric " + metric.getName() + " added entries to " + "owners list when cloning. This should not happen " + "for primitive metrics.", VESPA_STRLOC); + } + return false; +} + +const Metric* +MetricSource::getMetric(const String& name) { + String path = createAbsoluteMetricName(name); + std::map<String, Metric::SP>::const_iterator it( + _metricsAccessed.find(path)); + if (it != _metricsAccessed.end()) { + return it->second.get(); + } + SourceMetricVisitor visitor(path, false); + _snapshot.getMetrics().visit(visitor); + if (visitor._resultMetric.get() == 0) { + throw vespalib::IllegalArgumentException( + "Metric " + path + " was not found.", VESPA_STRLOC); + } + Metric::SP metric(visitor._resultMetric.release()); + _metricsAccessed[path] = metric; + return metric.get(); +} + +std::vector<Metric::String> +MetricSource::getPathsMatchingPrefix(const String& prefix) const +{ + String path = createAbsoluteMetricName(prefix); + SourceMetricVisitor visitor(path, true); + _snapshot.getMetrics().visit(visitor); + return visitor._prefixMatches; +} + +// Addition functions. Ensure that if floating point value is used, +// result ends up as floating point too. +LongValue operator+(LongValue addend1, LongValue addend2) +{ + return LongValue(addend1.first + addend2.first, + addend1.second && addend2.second); +} + +// Subtraction functions. Ensure that if floating point value is used, +// result ends up as floating point too. +LongValue operator-(LongValue minuend, LongValue subtrahend) +{ + return LongValue(minuend.first - subtrahend.first, + minuend.second && subtrahend.second); +} + +// Multiplication functions. Ensure that if floating point value is used, +// result ends up as floating point too. + +LongValue operator*(LongValue factor1, LongValue factor2) +{ + return std::pair<int64_t, bool>(factor1.first * factor2.first, + factor1.second && factor2.second); +} + +// Division functions. Ensure that if floating point value is used, +// result ends up as floating point too. + +LongValue operator/(LongValue dividend, LongValue divisor) +{ + if (dividend.first == 0) return LongValue( + 0, dividend.second && divisor.second); + if (divisor.first == 0) return LongValue( + std::numeric_limits<int64_t>().max(), + dividend.second && divisor.second); + return LongValue(dividend.first / divisor.first, + dividend.second && divisor.second); +} + +/** Get metric with given name from source. Set bool true if existing. */ +LongValue getLongMetric(const std::string& name, MetricSource& source) +{ + std::string::size_type pos = name.rfind('.'); + const Metric* metric = (pos == std::string::npos + ? 0 : source.getMetric(name.substr(0, pos))); + try{ + return LongValue(metric == 0 + ? 0 : metric->getLongValue(name.substr(pos+1)), metric != 0); + } catch (vespalib::IllegalArgumentException& e) { + return LongValue(0, false); + } +} + +/** Get metric with given name from source. Set bool true if existing. */ +DoubleValue getDoubleMetric(const std::string& name, MetricSource& source) +{ + std::string::size_type pos = name.rfind('.'); + const Metric* metric = (pos == std::string::npos + ? 0 : source.getMetric(name.substr(0, pos))); + try{ + return DoubleValue(metric == 0 + ? 0.0 : metric->getDoubleValue(name.substr(pos+1)), metric != 0); + } catch (vespalib::IllegalArgumentException& e) { + return DoubleValue(0, false); + } +} + +std::string getValueString(LongValue value, const char* format) +{ + if (!value.second) return "na"; + std::vector<char> buffer(30); + snprintf(&buffer[0], 30, format, value.first); + return std::string(&buffer[0]); +} + +std::string getValueString(DoubleValue value, const char* format) +{ + if (!value.second) return "na"; + std::vector<char> buffer(30); + snprintf(&buffer[0], 30, format, value.first); + return std::string(&buffer[0]); +} + +HttpTable::HttpTable(const std::string& title_, const std::string& topLeftText_) + : title(title_), topLeftText(topLeftText_) +{} +HttpTable::~HttpTable() { } + +HttpTable::Row& +HttpTable::operator[](uint32_t i) { + if (i >= cells.size()) cells.resize(i + 1); + return cells[i]; +} + +void +HttpTable::fillInEmptyHoles() { + if (rowNames.size() < cells.size()) rowNames.resize(cells.size()); + if (rowNames.size() > cells.size()) cells.resize(rowNames.size()); + for (uint32_t i=0; i<cells.size(); ++i) { + if (colNames.size() < cells[i].cells.size()) + colNames.resize(cells[i].cells.size()); + if (colNames.size() > cells[i].cells.size()) + cells[i].cells.resize(colNames.size()); + } +} + +void +HttpTable::print(std::ostream& out) { + out << "<h3>" << title << "</h3>\n"; + out << "<table border=\"1\">\n"; + fillInEmptyHoles(); + for (uint32_t i=0; i<=rowNames.size(); ++i) { + if (i == 0) { + out << "<tr><th>" << topLeftText << "</th>"; + for (uint32_t j=0; j<colNames.size(); ++j) { + out << "<th>" << colNames[j] << "</th>"; + } + out << "</tr>\n"; + } else { + out << "<tr><td>" << rowNames[i - 1] << "</td>"; + for (uint32_t j=0; j<colNames.size(); ++j) { + out << "<td align=\"right\">" + << (cells[i - 1][j].set ? cells[i - 1][j].value : "-") + << "</td>"; + } + out << "</tr>\n"; + } + } + out << "</table>\n"; +} + +} // printutils +} // metrics + diff --git a/metrics/src/vespa/metrics/printutils.h b/metrics/src/vespa/metrics/printutils.h index 10925864824..17562e7e064 100644 --- a/metrics/src/vespa/metrics/printutils.h +++ b/metrics/src/vespa/metrics/printutils.h @@ -32,29 +32,9 @@ struct MetricSource { MetricSource(const MetricSnapshot& s, const String& metricsPrefix, - std::map<String, Metric::SP>* metricsAccessed = 0) - : _snapshot(s), - _metricsPrefix(metricsPrefix), - _metricsAccessedOwner(), - _metricsAccessed(metricsAccessed == 0 ? _metricsAccessedOwner - : *metricsAccessed) - { - } - - String createAbsoluteMetricName(const String& name) const { - String prefix = _metricsPrefix; - String addition = name; - while (addition.find("../") == 0) { - String::size_type pos1 = prefix.rfind('.'); - if (pos1 == String::npos) - throw vespalib::IllegalArgumentException( - "Cannot go back anymore in path " + prefix, - VESPA_STRLOC); - prefix = prefix.substr(0, pos1); - addition = addition.substr(3); - } - return (prefix.empty() ? addition : prefix + "." + addition); - } + std::map<String, Metric::SP>* metricsAccessed = 0); + ~MetricSource(); + String createAbsoluteMetricName(const String& name) const; struct SourceMetricVisitor : public metrics::MetricVisitor { String _stringPath; @@ -64,115 +44,25 @@ struct MetricSource { bool _prefixMatch; std::vector<String> _prefixMatches; - SourceMetricVisitor(const String& path, bool prefixMatch) - : _stringPath(path), - _path(vespalib::StringTokenizer(path, ".").getTokens()), - _pathIndex(-1), - _resultMetric(), - _prefixMatch(prefixMatch), - _prefixMatches() - { - } + SourceMetricVisitor(const String& path, bool prefixMatch); + ~SourceMetricVisitor(); - void checkForPrefixMatch(const Metric& metric) { - if (metric.getName().size() >= _path[_pathIndex].size()) { - if (metric.getName().find(_path[_pathIndex]) == 0) { - _prefixMatches.push_back(metric.getName()); - } - } - } + void checkForPrefixMatch(const Metric& metric); - bool visitMetricSet(const MetricSet& set, bool) { - if (_pathIndex == -1) { - _pathIndex = 0; - return true; - } - if (_prefixMatch - && static_cast<size_t>(_pathIndex + 1) == _path.size()) - { - for (const Metric * entry : set.getRegisteredMetrics()) { - checkForPrefixMatch(*entry); - } - return false; - } - if (set.getName() != _path[_pathIndex]) return false; - if (static_cast<size_t>(++_pathIndex) >= _path.size()) { - throw vespalib::IllegalArgumentException( - "Path " + _stringPath + " points to a metric set. " - "Only primitive metrics can be retrieved.", - VESPA_STRLOC); - } - return true; - } + bool visitMetricSet(const MetricSet& set, bool); void doneVisitingMetricSet(const MetricSet&) { --_pathIndex; } - bool visitMetric(const Metric& metric, bool) { - if (_prefixMatch) { - checkForPrefixMatch(metric); - } - if (_path[_pathIndex] != metric.getName()) { - return true; - } - if (_prefixMatch) { - throw vespalib::IllegalArgumentException( - "Cannot find existing entries with prefix " - + _stringPath + " since element " + metric.getName() - + " is not a metric set", VESPA_STRLOC); - } - if (static_cast<size_t>(_pathIndex + 1) < _path.size()) { - throw vespalib::IllegalArgumentException( - "Path " + _stringPath + " cannot exist since element " - + _path[_pathIndex] + " is not a metric set: " - + metric.toString(), - VESPA_STRLOC); - } - std::vector<Metric::LP> ownerList; - _resultMetric.reset(metric.clone(ownerList, Metric::INACTIVE, 0)); - if (!ownerList.empty()) { - throw vespalib::IllegalArgumentException( - "Metric " + metric.getName() + " added entries to " - "owners list when cloning. This should not happen " - "for primitive metrics.", VESPA_STRLOC); - } - return false; - } - + bool visitMetric(const Metric& metric, bool); }; - const Metric* getMetric(const String& name) { - String path = createAbsoluteMetricName(name); - std::map<String, Metric::SP>::const_iterator it( - _metricsAccessed.find(path)); - if (it != _metricsAccessed.end()) { - return it->second.get(); - } - SourceMetricVisitor visitor(path, false); - _snapshot.getMetrics().visit(visitor); - if (visitor._resultMetric.get() == 0) { - throw vespalib::IllegalArgumentException( - "Metric " + path + " was not found.", VESPA_STRLOC); - } - Metric::SP metric(visitor._resultMetric.release()); - _metricsAccessed[path] = metric; - return metric.get(); - } + const Metric* getMetric(const String& name); std::vector<String> - getPathsMatchingPrefix(const String& prefix) const - { - String path = createAbsoluteMetricName(prefix); - SourceMetricVisitor visitor(path, true); - _snapshot.getMetrics().visit(visitor); - return visitor._prefixMatches; - } + getPathsMatchingPrefix(const String& prefix) const; }; // Addition functions. Ensure that if floating point value is used, // result ends up as floating point too. -LongValue operator+(LongValue addend1, LongValue addend2) -{ - return LongValue(addend1.first + addend2.first, - addend1.second && addend2.second); -} +LongValue operator+(LongValue addend1, LongValue addend2); template<typename ValueType1, typename ValueType2> DoubleValue operator+(std::pair<ValueType1, bool> addend1, @@ -184,11 +74,7 @@ DoubleValue operator+(std::pair<ValueType1, bool> addend1, // Subtraction functions. Ensure that if floating point value is used, // result ends up as floating point too. -LongValue operator-(LongValue minuend, LongValue subtrahend) -{ - return LongValue(minuend.first - subtrahend.first, - minuend.second && subtrahend.second); -} +LongValue operator-(LongValue minuend, LongValue subtrahend); template<typename ValueType1, typename ValueType2> DoubleValue operator-(std::pair<ValueType1, bool> minuend, @@ -201,11 +87,7 @@ DoubleValue operator-(std::pair<ValueType1, bool> minuend, // Multiplication functions. Ensure that if floating point value is used, // result ends up as floating point too. -LongValue operator*(LongValue factor1, LongValue factor2) -{ - return std::pair<int64_t, bool>(factor1.first * factor2.first, - factor1.second && factor2.second); -} +LongValue operator*(LongValue factor1, LongValue factor2); template<typename ValueType1, typename ValueType2> DoubleValue operator*(std::pair<ValueType1, bool> factor1, @@ -218,16 +100,7 @@ DoubleValue operator*(std::pair<ValueType1, bool> factor1, // Division functions. Ensure that if floating point value is used, // result ends up as floating point too. -LongValue operator/(LongValue dividend, LongValue divisor) -{ - if (dividend.first == 0) return LongValue( - 0, dividend.second && divisor.second); - if (divisor.first == 0) return LongValue( - std::numeric_limits<int64_t>().max(), - dividend.second && divisor.second); - return LongValue(dividend.first / divisor.first, - dividend.second && divisor.second); -} +LongValue operator/(LongValue dividend, LongValue divisor); template<typename ValueType1, typename ValueType2> DoubleValue operator/(std::pair<ValueType1, bool> dividend, @@ -276,49 +149,10 @@ typedef VW<int64_t> LVW; typedef VW<double> DVW; -/** Get metric with given name from source. Set bool true if existing. */ -LongValue getLongMetric(const std::string& name, MetricSource& source) -{ - std::string::size_type pos = name.rfind('.'); - const Metric* metric = (pos == std::string::npos - ? 0 : source.getMetric(name.substr(0, pos))); - try{ - return LongValue(metric == 0 - ? 0 : metric->getLongValue(name.substr(pos+1)), metric != 0); - } catch (vespalib::IllegalArgumentException& e) { - return LongValue(0, false); - } -} - -/** Get metric with given name from source. Set bool true if existing. */ -DoubleValue getDoubleMetric(const std::string& name, MetricSource& source) -{ - std::string::size_type pos = name.rfind('.'); - const Metric* metric = (pos == std::string::npos - ? 0 : source.getMetric(name.substr(0, pos))); - try{ - return DoubleValue(metric == 0 - ? 0.0 : metric->getDoubleValue(name.substr(pos+1)), metric != 0); - } catch (vespalib::IllegalArgumentException& e) { - return DoubleValue(0, false); - } -} - -std::string getValueString(LongValue value, const char* format = "%'lld") -{ - if (!value.second) return "na"; - std::vector<char> buffer(30); - snprintf(&buffer[0], 30, format, value.first); - return std::string(&buffer[0]); -} - -std::string getValueString(DoubleValue value, const char* format = "%'f") -{ - if (!value.second) return "na"; - std::vector<char> buffer(30); - snprintf(&buffer[0], 30, format, value.first); - return std::string(&buffer[0]); -} +LongValue getLongMetric(const std::string& name, MetricSource& source); +DoubleValue getDoubleMetric(const std::string& name, MetricSource& source); +std::string getValueString(LongValue value, const char* format = "%'lld"); +std::string getValueString(DoubleValue value, const char* format = "%'f"); template<typename ValueType> std::string getByteValueString(std::pair<ValueType, bool> val) @@ -367,48 +201,12 @@ struct HttpTable { }; std::vector<Row> cells; - HttpTable(const std::string& title_, const std::string& topLeftText_) - : title(title_), topLeftText(topLeftText_) {} - - Row& operator[](uint32_t i) { - if (i >= cells.size()) cells.resize(i + 1); - return cells[i]; - } - - void fillInEmptyHoles() { - if (rowNames.size() < cells.size()) rowNames.resize(cells.size()); - if (rowNames.size() > cells.size()) cells.resize(rowNames.size()); - for (uint32_t i=0; i<cells.size(); ++i) { - if (colNames.size() < cells[i].cells.size()) - colNames.resize(cells[i].cells.size()); - if (colNames.size() > cells[i].cells.size()) - cells[i].cells.resize(colNames.size()); - } - } + HttpTable(const std::string& title_, const std::string& topLeftText_); + ~HttpTable(); - void print(std::ostream& out) { - out << "<h3>" << title << "</h3>\n"; - out << "<table border=\"1\">\n"; - fillInEmptyHoles(); - for (uint32_t i=0; i<=rowNames.size(); ++i) { - if (i == 0) { - out << "<tr><th>" << topLeftText << "</th>"; - for (uint32_t j=0; j<colNames.size(); ++j) { - out << "<th>" << colNames[j] << "</th>"; - } - out << "</tr>\n"; - } else { - out << "<tr><td>" << rowNames[i - 1] << "</td>"; - for (uint32_t j=0; j<colNames.size(); ++j) { - out << "<td align=\"right\">" - << (cells[i - 1][j].set ? cells[i - 1][j].value : "-") - << "</td>"; - } - out << "</tr>\n"; - } - } - out << "</table>\n"; - } + Row& operator[](uint32_t i); + void fillInEmptyHoles(); + void print(std::ostream& out); }; } // printutils diff --git a/persistence/src/vespa/persistence/spi/CMakeLists.txt b/persistence/src/vespa/persistence/spi/CMakeLists.txt index dd0478c0c6a..798084f1abe 100644 --- a/persistence/src/vespa/persistence/spi/CMakeLists.txt +++ b/persistence/src/vespa/persistence/spi/CMakeLists.txt @@ -12,6 +12,7 @@ vespa_add_library(persistence_spi OBJECT metricpersistenceprovider.cpp read_consistency.cpp result + selection.cpp docentry DEPENDS ) diff --git a/persistence/src/vespa/persistence/spi/result.cpp b/persistence/src/vespa/persistence/spi/result.cpp index 511a73134f0..86564d69630 100644 --- a/persistence/src/vespa/persistence/spi/result.cpp +++ b/persistence/src/vespa/persistence/spi/result.cpp @@ -8,6 +8,8 @@ namespace storage { namespace spi { +Result::~Result() { } + vespalib::string Result::toString() const { vespalib::asciistream os; diff --git a/persistence/src/vespa/persistence/spi/result.h b/persistence/src/vespa/persistence/spi/result.h index 3cda34f33e0..df2a2a55454 100644 --- a/persistence/src/vespa/persistence/spi/result.h +++ b/persistence/src/vespa/persistence/spi/result.h @@ -36,7 +36,7 @@ public: : _errorCode(error), _errorMessage(errorMessage) {} - virtual ~Result() { } + virtual ~Result(); bool operator==(const Result& o) const { return _errorCode == o._errorCode diff --git a/persistence/src/vespa/persistence/spi/selection.cpp b/persistence/src/vespa/persistence/spi/selection.cpp new file mode 100644 index 00000000000..2f29c2c93c2 --- /dev/null +++ b/persistence/src/vespa/persistence/spi/selection.cpp @@ -0,0 +1,19 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "selection.h" + +namespace storage { +namespace spi { + +Selection::Selection(const DocumentSelection& docSel) + : _documentSelection(docSel), + _fromTimestamp(0), + _toTimestamp(INT64_MAX), + _timestampSubset() +{ } + +Selection::~Selection() { } + +} // spi +} // storage + diff --git a/persistence/src/vespa/persistence/spi/selection.h b/persistence/src/vespa/persistence/spi/selection.h index 84408d63517..0501475e802 100644 --- a/persistence/src/vespa/persistence/spi/selection.h +++ b/persistence/src/vespa/persistence/spi/selection.h @@ -27,12 +27,8 @@ private: TimestampSubset _timestampSubset; public: - Selection(const DocumentSelection& docSel) - : _documentSelection(docSel), - _fromTimestamp(0), - _toTimestamp(INT64_MAX), - _timestampSubset() - { } + Selection(const DocumentSelection& docSel); + ~Selection(); const DocumentSelection& getDocumentSelection() const { return _documentSelection; diff --git a/searchcommon/src/vespa/searchcommon/common/schema.cpp b/searchcommon/src/vespa/searchcommon/common/schema.cpp index 334fb424e77..f2e64cd943e 100644 --- a/searchcommon/src/vespa/searchcommon/common/schema.cpp +++ b/searchcommon/src/vespa/searchcommon/common/schema.cpp @@ -239,6 +239,10 @@ Schema::Schema() { } +Schema::Schema(const Schema & rhs) = default; +Schema & Schema::operator=(const Schema & rhs) = default; +Schema::Schema(Schema && rhs) = default; +Schema & Schema::operator=(Schema && rhs) = default; Schema::~Schema() { } bool diff --git a/searchcommon/src/vespa/searchcommon/common/schema.h b/searchcommon/src/vespa/searchcommon/common/schema.h index 0870cb43f8c..f40fb3d12ac 100644 --- a/searchcommon/src/vespa/searchcommon/common/schema.h +++ b/searchcommon/src/vespa/searchcommon/common/schema.h @@ -2,11 +2,11 @@ #pragma once +#include "datatype.h" #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/stllike/hash_map.h> #include <vespa/vespalib/util/ptrholder.h> #include <vector> -#include "datatype.h" namespace vespalib { class asciistream; @@ -169,6 +169,10 @@ public: * Create an initially empty schema **/ Schema(); + Schema(const Schema & rhs); + Schema & operator=(const Schema & rhs); + Schema(Schema && rhs); + Schema & operator=(Schema && rhs); ~Schema(); /** diff --git a/searchcore/src/apps/proton/proton.cpp b/searchcore/src/apps/proton/proton.cpp index d8ae874c652..cf22158071f 100644 --- a/searchcore/src/apps/proton/proton.cpp +++ b/searchcore/src/apps/proton/proton.cpp @@ -20,8 +20,11 @@ struct Params std::string identity; std::string serviceidentity; uint64_t subscribeTimeout; + ~Params(); }; +Params::~Params() {} + class App : public FastOS_Application { private: 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<DocumenttypesConfig>:: - getConfig("", config::DirSpec(configDir)).release()), - docTypeRepo(*docTypeCfg) - { - } + DocTypeRepo(const std::string &configDir); + ~DocTypeRepo(); }; +DocTypeRepo::DocTypeRepo(const std::string &configDir) + : docTypeCfg(config::ConfigGetter<DocumenttypesConfig>::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<BaseOptions> 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<proton::AttributeManager> - (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<proton::AttributeManager>(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<AttributeManager::SP> mgr; AttributeManagerInitializer::SP initializer; - ParallelAttributeManager(search::SerialNum configSerialNum, - AttributeManager::SP baseAttrMgr, - const AttributesConfig &attrCfg, - uint32_t docIdLimit) - : documentMetaStoreInitTask(std::make_shared<DummyInitializerTask>()), - bucketDbOwner(std::make_shared<BucketDBOwner>()), - documentMetaStore(std::make_shared<DocumentMetaStore>(bucketDbOwner)), - attributeGrow(), - attributeGrowNumDocs(1), - fastAccessAttributesOnly(false), - mgr(std::make_shared<AttributeManager::SP>()), - initializer(std::make_shared<AttributeManagerInitializer> - (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<DummyInitializerTask>()), + bucketDbOwner(std::make_shared<BucketDBOwner>()), + documentMetaStore(std::make_shared<DocumentMetaStore>(bucketDbOwner)), + attributeGrow(), + attributeGrowNumDocs(1), + fastAccessAttributesOnly(false), + mgr(std::make_shared<AttributeManager::SP>()), + initializer(std::make_shared<AttributeManagerInitializer>(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<AttributeManager> - (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<AttributeManager>(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/docsummary/summaryfieldconverter_test.cpp b/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp index 5159f5b6061..f3f495925f0 100644 --- a/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp +++ b/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp @@ -110,21 +110,26 @@ struct FieldBlock { search::RawBuf binary; vespalib::string json; - explicit FieldBlock(const vespalib::string &jsonInput) - : input(jsonInput), slime(), binary(1024), json() + explicit FieldBlock(const vespalib::string &jsonInput); + ~FieldBlock(); +}; + +FieldBlock::FieldBlock(const vespalib::string &jsonInput) + : input(jsonInput), slime(), binary(1024), json() +{ + size_t used = vespalib::slime::JsonFormat::decode(jsonInput, slime); + EXPECT_EQUAL(jsonInput.size(), used); { - size_t used = vespalib::slime::JsonFormat::decode(jsonInput, slime); - EXPECT_EQUAL(jsonInput.size(), used); - { - search::SlimeOutputRawBufAdapter adapter(binary); - vespalib::slime::JsonFormat::encode(slime, adapter, true); - json.assign(binary.GetDrainPos(), binary.GetUsedLen()); - binary.reset(); - } search::SlimeOutputRawBufAdapter adapter(binary); - vespalib::slime::BinaryFormat::encode(slime, adapter); + vespalib::slime::JsonFormat::encode(slime, adapter, true); + json.assign(binary.GetDrainPos(), binary.GetUsedLen()); + binary.reset(); } -}; + search::SlimeOutputRawBufAdapter adapter(binary); + vespalib::slime::BinaryFormat::encode(slime, adapter); +} + +FieldBlock::~FieldBlock() {} class Test : public vespalib::TestApp { std::unique_ptr<Schema> _schema; diff --git a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp index b4bf103bf65..95c444860b9 100644 --- a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp +++ b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp @@ -108,13 +108,10 @@ struct UnitDR : DocumentRetrieverBaseForTest { DocumentIdT docid; DocumentIdT docIdLimit; - UnitDR() - : repo(), document(new Document(*DataType::DOCUMENT, DocumentId())), - timestamp(0), bucket(), removed(false), docid(0), docIdLimit(std::numeric_limits<uint32_t>::max()) {} - UnitDR(document::Document::UP d, Timestamp t, Bucket b, bool r) - : repo(), document(std::move(d)), timestamp(t), bucket(b), removed(r), docid(++_docidCnt), docIdLimit(std::numeric_limits<uint32_t>::max()) {} - UnitDR(const document::DocumentType &dt, document::Document::UP d, Timestamp t, Bucket b, bool r) - : repo(dt), document(std::move(d)), timestamp(t), bucket(b), removed(r), docid(++_docidCnt), docIdLimit(std::numeric_limits<uint32_t>::max()) {} + UnitDR(); + UnitDR(document::Document::UP d, Timestamp t, Bucket b, bool r); + UnitDR(const document::DocumentType &dt, document::Document::UP d, Timestamp t, Bucket b, bool r); + ~UnitDR(); const document::DocumentTypeRepo &getDocumentTypeRepo() const override { return repo; @@ -151,6 +148,21 @@ struct UnitDR : DocumentRetrieverBaseForTest { static void reset() { _docidCnt = 2; } }; +UnitDR::UnitDR() + : repo(), document(new Document(*DataType::DOCUMENT, DocumentId())), timestamp(0), + bucket(), removed(false), docid(0), docIdLimit(std::numeric_limits<uint32_t>::max()) +{} +UnitDR::UnitDR(document::Document::UP d, Timestamp t, Bucket b, bool r) + : repo(), document(std::move(d)), timestamp(t), bucket(b), removed(r), docid(++_docidCnt), + docIdLimit(std::numeric_limits<uint32_t>::max()) +{} +UnitDR::UnitDR(const document::DocumentType &dt, document::Document::UP d, Timestamp t, Bucket b, bool r) + : repo(dt), document(std::move(d)), timestamp(t), bucket(b), removed(r), docid(++_docidCnt), + docIdLimit(std::numeric_limits<uint32_t>::max()) +{} +UnitDR::~UnitDR() {} + + struct VisitRecordingUnitDR : UnitDR { using VisitedLIDs = std::unordered_set<DocumentIdT>; VisitedLIDs& visited_lids; diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index 669d5084902..de2ec3e9e4c 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::SP> searchView; VarHolder<SearchableFeedView::SP> 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<ErrorConstantValue>(); @@ -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<BucketDBOwner> 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<BucketDBOwner> bucketDB, + IBucketDBHandlerInitializer & + bucketDBHandlerInitializer); + ~MyStoreOnlyContext(); const MySubDBOwner &getOwner() const { return _owner; } }; +MyStoreOnlyContext::MyStoreOnlyContext(IThreadingService &writeService, ThreadStackExecutorBase &summaryExecutor, + std::shared_ptr<BucketDBOwner> 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 <bool FastAccessAttributesOnly> struct MyFastAccessConfig { @@ -187,18 +179,9 @@ struct MyFastAccessContext FastAccessContext _ctx; MyFastAccessContext(IThreadingService &writeService, ThreadStackExecutorBase &summaryExecutor, - std::shared_ptr<BucketDBOwner> 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<BucketDBOwner> 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<BucketDBOwner> 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<BucketDBOwner> bucketDB, - IBucketDBHandlerInitializer & - bucketDBHandlerInitializer) - : _fastUpdCtx(writeService, executor, bucketDB, - bucketDBHandlerInitializer), - _queryLimiter(), - _clock(), - _ctx(_fastUpdCtx._ctx, - _queryLimiter, - _clock, - executor) - { - } + std::shared_ptr<BucketDBOwner> 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<BucketDBOwner> 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 <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP("documentbucketmover_test"); + #include <vespa/searchcore/proton/common/bucketfactory.h> #include <vespa/searchcore/proton/feedoperation/moveoperation.h> #include <vespa/searchcore/proton/server/bucketmovejob.h> @@ -112,23 +110,9 @@ struct MySubDb MaintenanceDocumentSubDB _subDb; test::UserDocuments _docs; bucketdb::BucketDBHandler _bucketDBHandler; - MySubDb(const DocumentTypeRepo::SP &repo, - std::shared_ptr<BucketDBOwner> bucketDB, - uint32_t subDbId, - SubDbType subDbType) - : _metaStoreSP(std::make_shared<DocumentMetaStore>(bucketDB, - DocumentMetaStore::getFixedName(), - search::GrowStrategy(), - documentmetastore::IGidCompare::SP(new documentmetastore::DefaultGidCompare), - subDbType)), - _metaStore(*_metaStoreSP), - _realRetriever(std::make_shared<MyDocumentRetriever>(repo)), - _retriever(_realRetriever), - _subDb(_metaStoreSP, _retriever, subDbId), _docs(), - _bucketDBHandler(*bucketDB) - { - _bucketDBHandler.addDocumentMetaStore(_metaStoreSP.get(), 0); - } + MySubDb(const DocumentTypeRepo::SP &repo, std::shared_ptr<BucketDBOwner> 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<BucketDBOwner> bucketDB, + uint32_t subDbId, SubDbType subDbType) + : _metaStoreSP(std::make_shared<DocumentMetaStore>(bucketDB, + DocumentMetaStore::getFixedName(), + search::GrowStrategy(), + documentmetastore::IGidCompare::SP(new documentmetastore::DefaultGidCompare), + subDbType)), + _metaStore(*_metaStoreSP), + _realRetriever(std::make_shared<MyDocumentRetriever>(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<BucketDBOwner> _bucketDB; MySubDb _ready; MySubDb _notReady; - ScanFixtureBase() - : _builder(), - _bucketDB(std::make_shared<BucketDBOwner>()), - _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<BucketDBOwner>()), + _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<BucketDBOwner>()), - _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<BucketDBOwner>()), + _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<DocumentDBReferenceRegistry> _registry; - MyDBOwner() - : DummyDBOwner(), - _registry(std::make_shared<DocumentDBReferenceRegistry>()) - { - } + MyDBOwner(); + ~MyDBOwner(); std::shared_ptr<IDocumentDBReferenceRegistry> getDocumentDBReferenceRegistry() const override { return _registry; } }; +MyDBOwner::MyDBOwner() + : DummyDBOwner(), + _registry(std::make_shared<DocumentDBReferenceRegistry>()) +{} +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 <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP("feedview_test"); + #include <vespa/documentapi/messagebus/documentprotocol.h> #include <vespa/documentapi/messagebus/messages/documentreply.h> #include <vespa/documentapi/messagebus/messages/removedocumentreply.h> @@ -33,7 +31,8 @@ LOG_SETUP("feedview_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/blockingthreadstackexecutor.h> #include <mutex> - +#include <vespa/log/log.h> +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<MyDocumentStore &>(_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<vespalib::string, - std::shared_ptr<AttributeVector>>; + using AttrMap = std::map<vespalib::string, std::shared_ptr<AttributeVector>>; AttrMap _attrMap; std::set<vespalib::string> _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<AttributeVector *> getWritableAttributes() const override { return std::vector<AttributeVector *>(); @@ -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<DocBuilder> _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<DocumentContext> 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<FeedTokenContext> SP; typedef std::vector<SP> 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<MyGidToLidChangeHandler> _gidToLidChangeHandler; - FixtureBase(TimeStamp visibilityDelay) : - _tracer(), - iw(new MyIndexWriter(_tracer)), - sa(new MySummaryAdapter), - aw(new MyAttributeWriter(_tracer)), - miw(static_cast<MyIndexWriter&>(*iw)), - msa(static_cast<MySummaryAdapter&>(*sa)), - maw(static_cast<MyAttributeWriter&>(*aw)), - sc(), - _docIdLimit(0u), - _dmscReal(new DocumentMetaStoreContext(std::make_shared<BucketDBOwner>())), - _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<MyGidToLidChangeHandler>()) - { - _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<MyIndexWriter&>(*iw)), + msa(static_cast<MySummaryAdapter&>(*sa)), + maw(static_cast<MyAttributeWriter&>(*aw)), + sc(), + _docIdLimit(0u), + _dmscReal(new DocumentMetaStoreContext(std::make_shared<BucketDBOwner>())), + _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<MyGidToLidChangeHandler>()) +{ + _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<BucketDBOwner> bucketDB) - : test::DummyDocumentSubDb(bucketDB, SUBDB_ID), - _repo(repo) - { - _summaryManager.reset(new MySummaryManager()); - } + MySubDb(const DocumentTypeRepo::SP &repo, std::shared_ptr<BucketDBOwner> bucketDB); + ~MySubDb(); virtual IFeedView::SP getFeedView() const { return IFeedView::SP(new MyFeedView(_repo)); } }; + +MySubDb::MySubDb(const DocumentTypeRepo::SP &repo, std::shared_ptr<BucketDBOwner> 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<BucketDBOwner> bucketDB, - const DocTypeName &docTypeName) - : _docs(), - _subDBId(subDBId), - _metaStoreSP(std::make_shared<DocumentMetaStore>(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<BucketDBOwner> 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<BucketDBOwner> bucketDB, const DocTypeName &docTypeName) + : _docs(), + _subDBId(subDBId), + _metaStoreSP(std::make_shared<DocumentMetaStore>( + 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<BucketId, GlobalIdVector> 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/initializer/task_runner_test.cpp b/searchcore/src/tests/proton/initializer/task_runner_test.cpp index afa807fd0e6..ef18130c1a8 100644 --- a/searchcore/src/tests/proton/initializer/task_runner_test.cpp +++ b/searchcore/src/tests/proton/initializer/task_runner_test.cpp @@ -52,11 +52,9 @@ struct TestJob { TestLog::UP _log; InitializerTask::SP _root; - TestJob(TestLog::UP log, InitializerTask::SP root) - : _log(std::move(log)), - _root(std::move(root)) - { - } + TestJob(TestLog::UP log, InitializerTask::SP root); + TestJob(TestJob &&) = default; + ~TestJob(); static TestJob setupCDependsOnAandB() { @@ -84,6 +82,12 @@ struct TestJob { } }; +TestJob::TestJob(TestLog::UP log, InitializerTask::SP root) + : _log(std::move(log)), + _root(std::move(root)) +{ } +TestJob::~TestJob() {} + struct Fixture { diff --git a/searchcore/src/tests/proton/matchengine/matchengine.cpp b/searchcore/src/tests/proton/matchengine/matchengine.cpp index 9d6f3ad0c6f..b739e9954aa 100644 --- a/searchcore/src/tests/proton/matchengine/matchengine.cpp +++ b/searchcore/src/tests/proton/matchengine/matchengine.cpp @@ -41,6 +41,8 @@ private: SearchReply::UP _reply; public: + LocalSearchClient(); + ~LocalSearchClient(); void searchDone(SearchReply::UP reply) { vespalib::MonitorGuard guard(_monitor); _reply = std::move(reply); @@ -57,6 +59,9 @@ public: } }; +LocalSearchClient::LocalSearchClient() {} +LocalSearchClient::~LocalSearchClient() {} + TEST("requireThatSearchesExecute") { int numMatcherThreads = 16; 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<BucketDBOwner>()), - 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<BucketDBOwner>()), + matchingStats(), + clock(), + queryLimiter() +{} +MyWorld::~MyWorld() {} //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- diff --git a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp index f73cfaf0e9d..2710c1bc0fd 100644 --- a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp +++ b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp @@ -334,14 +334,17 @@ struct HandlerSet { IPersistenceHandler::SP phandler2; MyHandler &handler1; MyHandler &handler2; - HandlerSet() : - phandler1(new MyHandler()), - phandler2(new MyHandler()), - handler1(static_cast<MyHandler &>(*phandler1.get())), - handler2(static_cast<MyHandler &>(*phandler2.get())) - {} + HandlerSet(); + ~HandlerSet(); }; +HandlerSet::HandlerSet() + : phandler1(new MyHandler()), + phandler2(new MyHandler()), + handler1(static_cast<MyHandler &>(*phandler1.get())), + handler2(static_cast<MyHandler &>(*phandler2.get())) +{} +HandlerSet::~HandlerSet() {} DocumentType type1(createDocType("type1", 1)); DocumentType type2(createDocType("type2", 2)); diff --git a/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp b/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp index 5d0056981ed..36319ae77d5 100644 --- a/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp +++ b/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp @@ -57,17 +57,8 @@ struct MyConfig AttributeManager::SP _mgr; search::index::Schema _schema; MyDocTypeInspector::SP _inspector; - MyConfig() - : _fileHeaderContext(), - _attributeFieldWriter(), - _hwInfo(), - _mgr(new AttributeManager(TEST_DIR, "test.subdb", TuneFileAttributes(), - _fileHeaderContext, - _attributeFieldWriter, _hwInfo)), - _schema(), - _inspector(new MyDocTypeInspector()) - { - } + MyConfig(); + ~MyConfig(); void addFields(const StringVector &fields) { for (auto field : fields) { _inspector->_fields.insert(field); @@ -92,6 +83,18 @@ struct MyConfig } }; +MyConfig::MyConfig() + : _fileHeaderContext(), + _attributeFieldWriter(), + _hwInfo(), + _mgr(new AttributeManager(TEST_DIR, "test.subdb", TuneFileAttributes(), + _fileHeaderContext, + _attributeFieldWriter, _hwInfo)), + _schema(), + _inspector(new MyDocTypeInspector()) +{} +MyConfig::~MyConfig() {} + struct Fixture { test::DirectoryHandler _dirHandler; diff --git a/searchcore/src/tests/proton/reprocessing/document_reprocessing_handler/document_reprocessing_handler_test.cpp b/searchcore/src/tests/proton/reprocessing/document_reprocessing_handler/document_reprocessing_handler_test.cpp index f22762a56bb..483c1c3b977 100644 --- a/searchcore/src/tests/proton/reprocessing/document_reprocessing_handler/document_reprocessing_handler_test.cpp +++ b/searchcore/src/tests/proton/reprocessing/document_reprocessing_handler/document_reprocessing_handler_test.cpp @@ -34,16 +34,19 @@ struct FixtureBase { DocumentReprocessingHandler _handler; DocBuilder _docBuilder; - FixtureBase(uint32_t docIdLimit) - : _handler(docIdLimit), - _docBuilder(Schema()) - { - } + FixtureBase(uint32_t docIdLimit); + ~FixtureBase(); Document::UP createDoc() { return _docBuilder.startDocument(DOC_ID).endDocument(); } }; +FixtureBase::FixtureBase(uint32_t docIdLimit) + : _handler(docIdLimit), + _docBuilder(Schema()) +{ } +FixtureBase::~FixtureBase() {} + struct ReaderFixture : public FixtureBase { MyReader::SP _reader1; 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> 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/tests/proton/summaryengine/summaryengine.cpp b/searchcore/src/tests/proton/summaryengine/summaryengine.cpp index 8cd98da51eb..d618bb65f84 100644 --- a/searchcore/src/tests/proton/summaryengine/summaryengine.cpp +++ b/searchcore/src/tests/proton/summaryengine/summaryengine.cpp @@ -82,6 +82,8 @@ private: DocsumReply::UP _reply; public: + MyDocsumClient(); + ~MyDocsumClient(); void getDocsumsDone(DocsumReply::UP reply) { vespalib::MonitorGuard guard(_monitor); _reply = std::move(reply); @@ -98,6 +100,9 @@ public: } }; +MyDocsumClient::MyDocsumClient() {} +MyDocsumClient::~MyDocsumClient() {} + class Test : public vespalib::TestApp { private: bool assertDocsumReply(SummaryEngine & engine, @@ -297,16 +302,8 @@ protected: }; class Server : public BaseServer { public: - Server() : - BaseServer(), - engine(2), - handler(new MySearchHandler("slime", stringref(buf.GetDrainPos(), buf.GetUsedLen()))), - docsumBySlime(engine), - docsumByRPC(docsumBySlime) - { - DocTypeName dtnvfoo("foo"); - engine.putSearchHandler(dtnvfoo, handler); - }; + Server(); + ~Server(); private: SummaryEngine engine; ISearchHandler::SP handler; @@ -315,6 +312,18 @@ public: DocsumByRPC docsumByRPC; }; +Server::Server() + : BaseServer(), + engine(2), + handler(new MySearchHandler("slime", stringref(buf.GetDrainPos(), buf.GetUsedLen()))), + docsumBySlime(engine), + docsumByRPC(docsumBySlime) +{ + DocTypeName dtnvfoo("foo"); + engine.putSearchHandler(dtnvfoo, handler); +} +Server::~Server() {} + vespalib::string getAnswer(size_t num) { diff --git a/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp b/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp index 5d56966c920..fcbf4e3c241 100644 --- a/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp +++ b/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp @@ -51,9 +51,8 @@ struct Model { std::map<std::string,std::string> constants; std::vector<bool> extra_profiles; std::vector<std::string> imported_attributes; - Model() : indexes(), attributes(), properties(), extra_profiles(), imported_attributes() { - verify_dir(); - } + Model(); + ~Model(); void index(const std::string &name, schema::DataType data_type, schema::CollectionType collection_type) { @@ -170,6 +169,16 @@ struct Model { } }; +Model::Model() + : indexes(), + attributes(), + properties(), + extra_profiles() +{ + verify_dir(); +} +Model::~Model() {} + //----------------------------------------------------------------------------- struct EmptyModel : Model {}; diff --git a/searchcore/src/vespa/searchcore/proton/attribute/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/attribute/CMakeLists.txt index 6e85cc79638..a82fb1f3928 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/attribute/CMakeLists.txt @@ -3,6 +3,7 @@ vespa_add_library(searchcore_attribute STATIC SOURCES address_space_usage_stats.cpp attribute_collection_spec_factory.cpp + attribute_collection_spec.cpp attribute_factory.cpp attribute_initializer.cpp attribute_manager_explorer.cpp diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.cpp new file mode 100644 index 00000000000..aba6ab99ce1 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.cpp @@ -0,0 +1,37 @@ +// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "attribute_collection_spec.h" + +namespace proton { + +AttributeCollectionSpec::Attribute::Attribute(const vespalib::string &name, + const search::attribute::Config &cfg) + : _name(name), + _cfg(cfg) +{ +} + +AttributeCollectionSpec::Attribute::Attribute(const Attribute &) = default; + +AttributeCollectionSpec::Attribute & +AttributeCollectionSpec::Attribute::operator=(const Attribute &) = default; + +AttributeCollectionSpec::Attribute::Attribute(Attribute &&) = default; + +AttributeCollectionSpec::Attribute & +AttributeCollectionSpec::Attribute::operator=(Attribute &&) = default; + +AttributeCollectionSpec::Attribute::~Attribute() { } + +AttributeCollectionSpec::AttributeCollectionSpec(const AttributeList &attributes, + uint32_t docIdLimit, + SerialNum currentSerialNum) + : _attributes(attributes), + _docIdLimit(docIdLimit), + _currentSerialNum(currentSerialNum) +{ +} + +AttributeCollectionSpec::~AttributeCollectionSpec() { } + +} diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h index 7e1b65da197..ee5f913cb88 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_collection_spec.h @@ -24,11 +24,12 @@ public: search::attribute::Config _cfg; public: Attribute(const vespalib::string &name, - const search::attribute::Config &cfg) - : _name(name), - _cfg(cfg) - { - } + const search::attribute::Config &cfg); + Attribute(const Attribute &); + Attribute & operator=(const Attribute &); + Attribute(Attribute &&); + Attribute & operator=(Attribute &&); + ~Attribute(); const vespalib::string &getName() const { return _name; } const search::attribute::Config &getConfig() const { return _cfg; } }; @@ -45,12 +46,8 @@ private: public: AttributeCollectionSpec(const AttributeList &attributes, uint32_t docIdLimit, - SerialNum currentSerialNum) - : _attributes(attributes), - _docIdLimit(docIdLimit), - _currentSerialNum(currentSerialNum) - { - } + SerialNum currentSerialNum); + ~AttributeCollectionSpec(); const AttributeList &getAttributes() const { return _attributes; } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp index c1e4077d82d..2f657637740 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp @@ -100,6 +100,8 @@ AttributeInitializer::AttributeHeader::AttributeHeader() { } +AttributeInitializer::AttributeHeader::~AttributeHeader() {} + AttributeVector::SP AttributeInitializer::tryLoadAttribute(const IndexMetaInfo &info) const { @@ -187,6 +189,8 @@ AttributeInitializer::AttributeInitializer(const vespalib::string &baseDir, { } +AttributeInitializer::~AttributeInitializer() {} + search::AttributeVector::SP AttributeInitializer::init() const { diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.h index bfcb9ad5225..b1f973fe72b 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.h @@ -24,6 +24,7 @@ public: vespalib::string _btString; vespalib::string _ctString; AttributeHeader(); + ~AttributeHeader(); }; private: @@ -52,6 +53,7 @@ public: const search::attribute::Config &cfg, uint64_t currentSerialNum, const IAttributeFactory &factory); + ~AttributeInitializer(); search::AttributeVector::SP init() const; uint64_t getCurrentSerialNum() const { return _currentSerialNum; } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_initializer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_initializer.cpp index 98509cb5315..073c1c5110d 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_initializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_manager_initializer.cpp @@ -56,22 +56,33 @@ public: AttributeInitializerTasksBuilder(InitializerTask &attrMgrInitTask, InitializerTask::SP documentMetaStoreInitTask, DocumentMetaStore::SP documentMetaStore, - InitializedAttributesResult &attributesResult) - : _attrMgrInitTask(attrMgrInitTask), - _documentMetaStoreInitTask(documentMetaStoreInitTask), - _documentMetaStore(documentMetaStore), - _attributesResult(attributesResult) - {} - virtual void add(AttributeInitializer::UP initializer) override { - InitializerTask::SP attributeInitTask = - std::make_shared<AttributeInitializerTask>(std::move(initializer), - _documentMetaStore, - _attributesResult); - attributeInitTask->addDependency(_documentMetaStoreInitTask); - _attrMgrInitTask.addDependency(attributeInitTask); - } + InitializedAttributesResult &attributesResult); + ~AttributeInitializerTasksBuilder(); + void add(AttributeInitializer::UP initializer) override; }; +AttributeInitializerTasksBuilder::AttributeInitializerTasksBuilder(InitializerTask &attrMgrInitTask, + InitializerTask::SP documentMetaStoreInitTask, + DocumentMetaStore::SP documentMetaStore, + InitializedAttributesResult &attributesResult) + : _attrMgrInitTask(attrMgrInitTask), + _documentMetaStoreInitTask(documentMetaStoreInitTask), + _documentMetaStore(documentMetaStore), + _attributesResult(attributesResult) +{ } + +AttributeInitializerTasksBuilder::~AttributeInitializerTasksBuilder() {} + +void +AttributeInitializerTasksBuilder::add(AttributeInitializer::UP initializer) { + InitializerTask::SP attributeInitTask = + std::make_shared<AttributeInitializerTask>(std::move(initializer), + _documentMetaStore, + _attributesResult); + attributeInitTask->addDependency(_documentMetaStoreInitTask); + _attrMgrInitTask.addDependency(attributeInitTask); +} + } AttributeCollectionSpec::UP diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp index 3ab81dadc96..b19792bef61 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.cpp @@ -195,6 +195,8 @@ AttributeWriter::AttributeWriter(const proton::IAttributeManager::SP &mgr) { } +AttributeWriter::~AttributeWriter() {} + std::vector<search::AttributeVector *> AttributeWriter::getWritableAttributes() const { diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.h index e0db78bcbcd..32b23d93e4c 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_writer.h @@ -35,6 +35,7 @@ private: public: AttributeWriter(const proton::IAttributeManager::SP &mgr); + ~AttributeWriter(); /** * Implements IAttributeWriter. diff --git a/searchcore/src/vespa/searchcore/proton/common/schemautil.cpp b/searchcore/src/vespa/searchcore/proton/common/schemautil.cpp index da7e89d8f59..e28fe0d2290 100644 --- a/searchcore/src/vespa/searchcore/proton/common/schemautil.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/schemautil.cpp @@ -1,5 +1,4 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include "schemautil.h" #include <vespa/log/log.h> @@ -9,8 +8,7 @@ using namespace search::index; namespace proton { -namespace -{ +namespace { class FieldQuad { @@ -23,13 +21,8 @@ public: FieldQuad(const vespalib::string &name, const vespalib::string &dataType, const vespalib::string &collectionType, - const vespalib::string &location) - : _name(name), - _dataType(dataType), - _collectionType(collectionType), - _location(location) - { - } + const vespalib::string &location); + ~FieldQuad(); bool operator<(const FieldQuad &rhs) const @@ -44,6 +37,18 @@ public: } }; +FieldQuad::FieldQuad(const vespalib::string &name, + const vespalib::string &dataType, + const vespalib::string &collectionType, + const vespalib::string &location) + : _name(name), + _dataType(dataType), + _collectionType(collectionType), + _location(location) +{ +} +FieldQuad::~FieldQuad() {} + } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp index 37735d42e8c..27e5dda1358 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp @@ -46,6 +46,8 @@ LidAllocator::LidAllocator(uint32_t size, } +LidAllocator::~LidAllocator() {} + LidAllocator::DocId LidAllocator::getFreeLid(DocId lidLimit) { diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h index 49e8b0624a6..eddb010250a 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h @@ -37,6 +37,7 @@ public: uint32_t capacity, vespalib::GenerationHolder &genHolder, const search::GrowStrategy & grow); + ~LidAllocator(); DocId getFreeLid(DocId lidLimit); DocId peekFreeLid(DocId lidLimit); diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp index 7b1b8d967b5..d2df187deb6 100644 --- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp @@ -34,12 +34,21 @@ findOldestFlushedSerial(const IFlushTarget::List &lst, } +FlushEngine::FlushMeta::FlushMeta(const vespalib::string & name, fastos::TimeStamp start, uint32_t id) : + _name(name), + _start(start), + _id(id) +{ } +FlushEngine::FlushMeta::~FlushMeta() { } + FlushEngine::FlushInfo::FlushInfo() : FlushMeta("", fastos::ClockSystem::now(), 0), _target() { } +FlushEngine::FlushInfo::~FlushInfo() { } + FlushEngine::FlushInfo::FlushInfo(uint32_t taskId, const IFlushTarget::SP &target, diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h index e76ec5e7e0c..8f6c8faeea5 100644 --- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h +++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h @@ -18,11 +18,8 @@ class FlushEngine : public FastOS_Runnable public: class FlushMeta { public: - FlushMeta(const vespalib::string & name, fastos::TimeStamp start, uint32_t id) : - _name(name), - _start(start), - _id(id) - { } + FlushMeta(const vespalib::string & name, fastos::TimeStamp start, uint32_t id); + ~FlushMeta(); const vespalib::string & getName() const { return _name; } fastos::TimeStamp getStart() const { return _start; } uint32_t getId() const { return _id; } @@ -40,6 +37,7 @@ private: FlushInfo(uint32_t taskId, const IFlushTarget::SP &target, const vespalib::string &destination); + ~FlushInfo(); IFlushTarget::SP _target; }; diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_loop_communicator.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_loop_communicator.cpp index 52af7fa0f39..626305c7877 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_loop_communicator.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_loop_communicator.cpp @@ -6,6 +6,13 @@ namespace proton { namespace matching { +MatchLoopCommunicator::MatchLoopCommunicator(size_t threads, size_t topN) + : _estimate_match_frequency(threads), + _selectBest(threads, topN), + _rangeCover(threads) +{} +MatchLoopCommunicator::~MatchLoopCommunicator() {} + void MatchLoopCommunicator::EstimateMatchFrequency::mingle() { diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_loop_communicator.h b/searchcore/src/vespa/searchcore/proton/matching/match_loop_communicator.h index 61ec70c2a96..08ac92d6f04 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_loop_communicator.h +++ b/searchcore/src/vespa/searchcore/proton/matching/match_loop_communicator.h @@ -42,8 +42,8 @@ private: RangeCover _rangeCover; public: - MatchLoopCommunicator(size_t threads, size_t topN) - : _estimate_match_frequency(threads), _selectBest(threads, topN), _rangeCover(threads) {} + MatchLoopCommunicator(size_t threads, size_t topN); + ~MatchLoopCommunicator(); virtual double estimate_match_frequency(const Matches &matches) { return _estimate_match_frequency.rendezvous(matches); diff --git a/searchcore/src/vespa/searchcore/proton/metrics/content_proton_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/content_proton_metrics.cpp index ba86b563f61..208be7df405 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/content_proton_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/content_proton_metrics.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 <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".proton.metrics.content_proton_metrics"); #include "content_proton_metrics.h" namespace proton { @@ -14,4 +11,6 @@ ContentProtonMetrics::ContentProtonMetrics() { } +ContentProtonMetrics::~ContentProtonMetrics() {} + } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/content_proton_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/content_proton_metrics.h index bf720d59a36..55c0bacc2cf 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/content_proton_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/content_proton_metrics.h @@ -22,6 +22,7 @@ struct ContentProtonMetrics : metrics::MetricSet ResourceUsageMetrics resourceUsage; ContentProtonMetrics(); + ~ContentProtonMetrics(); }; diff --git a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp index 213c869a8e4..a61ab0cb7c7 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp @@ -1,13 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".proton.metrics.documentdb_tagged_metrics"); #include "documentdb_tagged_metrics.h" #include <vespa/vespalib/util/stringfmt.h> -using vespalib::make_string; - namespace proton { DocumentDBTaggedMetrics::JobMetrics::JobMetrics(metrics::MetricSet* parent) @@ -25,17 +20,18 @@ DocumentDBTaggedMetrics::JobMetrics::JobMetrics(metrics::MetricSet* parent) removedDocumentsPrune("removed_documents_prune", "", "Pruning of removed documents in 'removed' sub database", this), total("total", "", "The job load average total of all job metrics", this) -{ -} +{ } -DocumentDBTaggedMetrics::SubDBMetrics::SubDBMetrics(const vespalib::string &name, - MetricSet *parent) +DocumentDBTaggedMetrics::JobMetrics::~JobMetrics() { } + +DocumentDBTaggedMetrics::SubDBMetrics::SubDBMetrics(const vespalib::string &name, MetricSet *parent) : MetricSet(name, "", "Sub database metrics", parent), lidSpace(this), documentStore(this), attributes(this) -{ -} +{ } + +DocumentDBTaggedMetrics::SubDBMetrics::~SubDBMetrics() { } DocumentDBTaggedMetrics::SubDBMetrics::LidSpaceMetrics::LidSpaceMetrics(MetricSet *parent) : MetricSet("lid_space", "", "Local document id (lid) space metrics for this document sub DB", parent), @@ -48,8 +44,9 @@ DocumentDBTaggedMetrics::SubDBMetrics::LidSpaceMetrics::LidSpaceMetrics(MetricSe lidFragmentationFactor("lid_fragmentation_factor", "", "The fragmentation factor of this lid space, indicating the amount of holes in the currently used part of the lid space " "((highest_used_lid - used_lids) / highest_used_lid)", this) -{ -} +{ } + +DocumentDBTaggedMetrics::SubDBMetrics::LidSpaceMetrics::~LidSpaceMetrics() { } DocumentDBTaggedMetrics::SubDBMetrics::DocumentStoreMetrics::DocumentStoreMetrics(MetricSet *parent) : MetricSet("document_store", "", "document store metrics for this document sub DB", parent), @@ -57,14 +54,16 @@ DocumentDBTaggedMetrics::SubDBMetrics::DocumentStoreMetrics::DocumentStoreMetric diskBloat("disk_bloat", "", "Disk space bloat in bytes", this), maxBucketSpread("max_bucket_spread", "", "Max bucket spread in underlying files (sum(unique buckets in each chunk)/unique buckets in file)", this), memoryUsage(this) -{ -} +{ } + +DocumentDBTaggedMetrics::SubDBMetrics::DocumentStoreMetrics::~DocumentStoreMetrics() { } DocumentDBTaggedMetrics::AttributeMetrics::AttributeMetrics(MetricSet *parent) : MetricSet("attribute", "", "Attribute vector metrics for this document db", parent), resourceUsage(this) -{ -} +{ } + +DocumentDBTaggedMetrics::AttributeMetrics::~AttributeMetrics() { } DocumentDBTaggedMetrics::AttributeMetrics::ResourceUsageMetrics::ResourceUsageMetrics(MetricSet *parent) : MetricSet("resource_usage", "", "Usage metrics for various attribute vector resources", parent), @@ -76,11 +75,14 @@ DocumentDBTaggedMetrics::AttributeMetrics::ResourceUsageMetrics::ResourceUsageMe { } +DocumentDBTaggedMetrics::AttributeMetrics::ResourceUsageMetrics::~ResourceUsageMetrics() { } + DocumentDBTaggedMetrics::IndexMetrics::IndexMetrics(MetricSet *parent) : MetricSet("index", "", "Index metrics (memory and disk) for this document db", parent), memoryUsage(this) -{ -} +{ } + +DocumentDBTaggedMetrics::IndexMetrics::~IndexMetrics() { } DocumentDBTaggedMetrics::DocumentDBTaggedMetrics(const vespalib::string &docTypeName) : MetricSet("documentdb", {{"documenttype", docTypeName}}, "Document DB metrics", nullptr), @@ -90,7 +92,8 @@ DocumentDBTaggedMetrics::DocumentDBTaggedMetrics(const vespalib::string &docType ready("ready", this), notReady("notready", this), removed("removed", this) -{ -} +{ } + +DocumentDBTaggedMetrics::~DocumentDBTaggedMetrics() { } } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.h index 323d0766e6f..e9cd00e7553 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.h @@ -27,6 +27,7 @@ struct DocumentDBTaggedMetrics : metrics::MetricSet metrics::DoubleAverageMetric total; JobMetrics(metrics::MetricSet *parent); + ~JobMetrics(); }; struct SubDBMetrics : metrics::MetricSet @@ -41,6 +42,7 @@ struct DocumentDBTaggedMetrics : metrics::MetricSet metrics::DoubleValueMetric lidFragmentationFactor; LidSpaceMetrics(metrics::MetricSet *parent); + ~LidSpaceMetrics(); }; struct DocumentStoreMetrics : metrics::MetricSet @@ -51,6 +53,7 @@ struct DocumentDBTaggedMetrics : metrics::MetricSet MemoryUsageMetrics memoryUsage; DocumentStoreMetrics(metrics::MetricSet *parent); + ~DocumentStoreMetrics(); }; LidSpaceMetrics lidSpace; @@ -58,6 +61,7 @@ struct DocumentDBTaggedMetrics : metrics::MetricSet proton::AttributeMetrics attributes; SubDBMetrics(const vespalib::string &name, metrics::MetricSet *parent); + ~SubDBMetrics(); }; struct AttributeMetrics : metrics::MetricSet @@ -69,11 +73,13 @@ struct DocumentDBTaggedMetrics : metrics::MetricSet metrics::LongValueMetric feedingBlocked; ResourceUsageMetrics(metrics::MetricSet *parent); + ~ResourceUsageMetrics(); }; ResourceUsageMetrics resourceUsage; AttributeMetrics(metrics::MetricSet *parent); + ~AttributeMetrics(); }; struct IndexMetrics : metrics::MetricSet @@ -81,6 +87,7 @@ struct DocumentDBTaggedMetrics : metrics::MetricSet MemoryUsageMetrics memoryUsage; IndexMetrics(metrics::MetricSet *parent); + ~IndexMetrics(); }; JobMetrics job; @@ -91,6 +98,7 @@ struct DocumentDBTaggedMetrics : metrics::MetricSet SubDBMetrics removed; DocumentDBTaggedMetrics(const vespalib::string &docTypeName); + ~DocumentDBTaggedMetrics(); }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.cpp index 30be90d637a..99583afbbca 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.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 <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".proton.server.executormetrics"); #include "executor_metrics.h" namespace proton { @@ -23,4 +20,6 @@ ExecutorMetrics::ExecutorMetrics(const std::string &name, metrics::MetricSet *pa { } +ExecutorMetrics::~ExecutorMetrics() {} + } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.h index 526c4fd6985..e0514edf39e 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.h @@ -15,6 +15,7 @@ struct ExecutorMetrics : metrics::MetricSet void update(const vespalib::ThreadStackExecutorBase::Stats &stats); ExecutorMetrics(const std::string &name, metrics::MetricSet *parent); + ~ExecutorMetrics(); }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/feed_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/feed_metrics.cpp index bb6e1fdf50d..9f60951393c 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/feed_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/feed_metrics.cpp @@ -17,6 +17,8 @@ FeedMetrics::FeedMetrics() { } +FeedMetrics::~FeedMetrics() {} + PerDocTypeFeedMetrics::PerDocTypeFeedMetrics(MetricSet *parent) : MetricSet("feedmetrics", "", "Feed metrics", parent), _update_lock(), @@ -31,6 +33,8 @@ PerDocTypeFeedMetrics::PerDocTypeFeedMetrics(MetricSet *parent) { } +PerDocTypeFeedMetrics::~PerDocTypeFeedMetrics() {} + void PerDocTypeFeedMetrics::RegisterPut(const FastOS_Time &start_time) { LockGuard lock(_update_lock); _puts.inc(1); diff --git a/searchcore/src/vespa/searchcore/proton/metrics/feed_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/feed_metrics.h index 541a9cec548..aee2647c681 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/feed_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/feed_metrics.h @@ -14,6 +14,7 @@ struct FeedMetrics : metrics::MetricSet metrics::DoubleAverageMetric latency; FeedMetrics(); + ~FeedMetrics(); }; class PerDocTypeFeedMetrics : metrics::MetricSet { @@ -29,6 +30,7 @@ class PerDocTypeFeedMetrics : metrics::MetricSet { public: PerDocTypeFeedMetrics(metrics::MetricSet *parent); + ~PerDocTypeFeedMetrics(); void RegisterPut(const FastOS_Time &start_time); void RegisterUpdate(const FastOS_Time &start_time); void RegisterRemove(const FastOS_Time &start_time); diff --git a/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.cpp index aa5a637dee0..c56cc3f3223 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.cpp @@ -63,6 +63,8 @@ LegacyAttributeMetrics::List::List(metrics::MetricSet *parent) { } +LegacyAttributeMetrics::List::~List() {} + LegacyAttributeMetrics::LegacyAttributeMetrics(metrics::MetricSet *parent) : metrics::MetricSet("attributes", "", "Attribute metrics", parent), list(this), @@ -71,4 +73,6 @@ LegacyAttributeMetrics::LegacyAttributeMetrics(metrics::MetricSet *parent) { } +LegacyAttributeMetrics::~LegacyAttributeMetrics() {} + } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.h index 05085f758cf..116d0c2b2ea 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.h @@ -28,6 +28,7 @@ struct LegacyAttributeMetrics : metrics::MetricSet { // per attribute metrics will be wired in here (by the metrics engine) List(metrics::MetricSet *parent); + ~List(); private: std::map<std::string, Entry::LP> metrics; @@ -38,6 +39,7 @@ struct LegacyAttributeMetrics : metrics::MetricSet { metrics::LongValueMetric bitVectors; LegacyAttributeMetrics(metrics::MetricSet *parent); + ~LegacyAttributeMetrics(); }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.cpp index 1cc20a95315..f1a65b18084 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.cpp @@ -19,6 +19,8 @@ LegacyDocumentDBMetrics::IndexMetrics::IndexMetrics(MetricSet *parent) diskUsage("diskusage", "", "Disk usage for disk indexes", this) { } +LegacyDocumentDBMetrics::IndexMetrics::~IndexMetrics() {} + LegacyDocumentDBMetrics::DocstoreMetrics::DocstoreMetrics(MetricSet *parent) : MetricSet("docstore", "", "Document store metrics", parent), memoryUsage("memoryusage", "", "Memory usage for docstore", this), @@ -29,6 +31,8 @@ LegacyDocumentDBMetrics::DocstoreMetrics::DocstoreMetrics(MetricSet *parent) cacheMemoryUsed("cachememoryused", "", "Memory used by summary cache", this) { } +LegacyDocumentDBMetrics::DocstoreMetrics::~DocstoreMetrics() {} + void LegacyDocumentDBMetrics::MatchingMetrics::update(const MatchingStats &stats) { @@ -52,6 +56,8 @@ LegacyDocumentDBMetrics::MatchingMetrics::MatchingMetrics(MetricSet *parent) queryLatency("querylatency", "", "Average latency when matching a query", this) { } +LegacyDocumentDBMetrics::MatchingMetrics::~MatchingMetrics() {} + LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMetrics::RankProfileMetrics( const std::string &name, size_t numDocIdPartitions, MetricSet *parent) : MetricSet(name, "", "Rank profile metrics", parent), @@ -67,6 +73,8 @@ LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMetrics::RankProfileMetrics } } +LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMetrics::~RankProfileMetrics() {} + LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMetrics::DocIdPartition::DocIdPartition(const std::string &name, MetricSet *parent) : MetricSet(name, "", "DocId Partition profile metrics", parent), docsMatched("docsmatched", "", "Number of documents matched", this), @@ -76,6 +84,8 @@ LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMetrics::DocIdPartition::Do wait_time("waittime", "", "Time spent waiting for other external threads and resources", this) { } +LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMetrics::DocIdPartition::~DocIdPartition() {} + void LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMetrics::DocIdPartition::update(const MatchingStats::Partition &stats) { @@ -109,8 +119,7 @@ LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMetrics::update(const Match } } -LegacyDocumentDBMetrics::SubDBMetrics::DocumentMetaStoreMetrics:: -DocumentMetaStoreMetrics(MetricSet *parent) +LegacyDocumentDBMetrics::SubDBMetrics::DocumentMetaStoreMetrics::DocumentMetaStoreMetrics(MetricSet *parent) : MetricSet("docmetastore", "", "Document meta store metrics", parent), lidLimit("lidlimit", "", "The size of the allocated lid space", this), usedLids("usedlids", "", "The number of lids used", this), @@ -124,12 +133,16 @@ DocumentMetaStoreMetrics(MetricSet *parent) { } +LegacyDocumentDBMetrics::SubDBMetrics::DocumentMetaStoreMetrics::~DocumentMetaStoreMetrics() {} + LegacyDocumentDBMetrics::SubDBMetrics::SubDBMetrics(const vespalib::string &name, MetricSet *parent) : MetricSet(name, "", "Sub database metrics", parent), attributes(this), docMetaStore(this) { } +LegacyDocumentDBMetrics::SubDBMetrics::~SubDBMetrics() {} + LegacyDocumentDBMetrics::LegacyDocumentDBMetrics(const std::string &docTypeName, size_t maxNumThreads) : MetricSet(make_string("%s", docTypeName.c_str()), "", "Document DB Metrics", 0), index(this), @@ -157,4 +170,6 @@ LegacyDocumentDBMetrics::LegacyDocumentDBMetrics(const std::string &docTypeName, memoryUsage.addMetricToSum(docstore.memoryUsage); } +LegacyDocumentDBMetrics::~LegacyDocumentDBMetrics() { } + } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h index 16cc176e377..dd246443ae4 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h @@ -27,6 +27,7 @@ struct LegacyDocumentDBMetrics : metrics::MetricSet metrics::LongValueMetric diskUsage; IndexMetrics(metrics::MetricSet *parent); + ~IndexMetrics(); }; struct DocstoreMetrics : metrics::MetricSet { @@ -38,6 +39,7 @@ struct LegacyDocumentDBMetrics : metrics::MetricSet metrics::LongValueMetric cacheMemoryUsed; DocstoreMetrics(metrics::MetricSet *parent); + ~DocstoreMetrics(); }; struct MatchingMetrics : metrics::MetricSet { @@ -59,6 +61,7 @@ struct LegacyDocumentDBMetrics : metrics::MetricSet typedef vespalib::LinkedPtr<DocIdPartition> LP; DocIdPartition(const std::string &name, metrics::MetricSet *parent); + ~DocIdPartition(); void update(const matching::MatchingStats::Partition &stats); }; typedef std::vector<DocIdPartition::LP> DocIdPartitions; @@ -75,6 +78,7 @@ struct LegacyDocumentDBMetrics : metrics::MetricSet RankProfileMetrics(const std::string &name, size_t numDocIdPartitions, metrics::MetricSet *parent); + ~RankProfileMetrics(); void update(const matching::MatchingStats &stats); }; @@ -83,6 +87,7 @@ struct LegacyDocumentDBMetrics : metrics::MetricSet void update(const matching::MatchingStats &stats); MatchingMetrics(metrics::MetricSet *parent); + ~MatchingMetrics(); }; struct SubDBMetrics : metrics::MetricSet @@ -97,11 +102,13 @@ struct LegacyDocumentDBMetrics : metrics::MetricSet metrics::DoubleValueMetric lidFragmentationFactor; DocumentMetaStoreMetrics(metrics::MetricSet *parent); + ~DocumentMetaStoreMetrics(); }; LegacyAttributeMetrics attributes; DocumentMetaStoreMetrics docMetaStore; SubDBMetrics(const vespalib::string &name, metrics::MetricSet *parent); + ~SubDBMetrics(); }; IndexMetrics index; @@ -125,6 +132,7 @@ struct LegacyDocumentDBMetrics : metrics::MetricSet size_t _maxNumThreads; LegacyDocumentDBMetrics(const std::string &docTypeName, size_t maxNumThreads); + ~LegacyDocumentDBMetrics(); }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/legacy_proton_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/legacy_proton_metrics.cpp index dc16d324d98..8ae757698eb 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/legacy_proton_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/legacy_proton_metrics.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 <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".proton.metrics.legacy_proton_metrics"); #include "legacy_proton_metrics.h" namespace proton { @@ -12,6 +9,8 @@ LegacyProtonMetrics::DocumentTypeMetrics::DocumentTypeMetrics(metrics::MetricSet { } +LegacyProtonMetrics::DocumentTypeMetrics::~DocumentTypeMetrics() { } + LegacyProtonMetrics::LegacyProtonMetrics() : metrics::MetricSet("proton", "", "Search engine metrics", 0), docTypes(this), @@ -44,4 +43,6 @@ LegacyProtonMetrics::LegacyProtonMetrics() numRemovedDocs.setStartValue(start); } +LegacyProtonMetrics::~LegacyProtonMetrics() {} + } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/legacy_proton_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/legacy_proton_metrics.h index 81df510ec18..9591e875139 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/legacy_proton_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/legacy_proton_metrics.h @@ -17,6 +17,7 @@ struct LegacyProtonMetrics : metrics::MetricSet struct DocumentTypeMetrics : metrics::MetricSet { // documentdb metrics will be wired in here (by the metrics engine) DocumentTypeMetrics(metrics::MetricSet *parent); + ~DocumentTypeMetrics(); }; DocumentTypeMetrics docTypes; @@ -35,6 +36,7 @@ struct LegacyProtonMetrics : metrics::MetricSet // transport metrics will be wired in here LegacyProtonMetrics(); + ~LegacyProtonMetrics(); }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/memory_usage_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/memory_usage_metrics.cpp index 8bcb4ee31d6..8a702f0c920 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/memory_usage_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/memory_usage_metrics.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include "memory_usage_metrics.h" #include <vespa/searchlib/util/memoryusage.h> @@ -15,6 +14,8 @@ MemoryUsageMetrics::MemoryUsageMetrics(metrics::MetricSet *parent) { } +MemoryUsageMetrics::~MemoryUsageMetrics() {} + void MemoryUsageMetrics::update(const search::MemoryUsage &usage) { diff --git a/searchcore/src/vespa/searchcore/proton/metrics/memory_usage_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/memory_usage_metrics.h index c63e11ac6df..109d1d66de1 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/memory_usage_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/memory_usage_metrics.h @@ -21,6 +21,7 @@ private: public: MemoryUsageMetrics(metrics::MetricSet *parent); + ~MemoryUsageMetrics(); void update(const search::MemoryUsage &usage); }; diff --git a/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.cpp index 643a9a778ba..9321b6b071d 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include "resource_usage_metrics.h" namespace proton { @@ -15,4 +14,6 @@ ResourceUsageMetrics::ResourceUsageMetrics(metrics::MetricSet *parent) { } +ResourceUsageMetrics::~ResourceUsageMetrics() {} + } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.h index d60b25c247a..a96aee20b06 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.h @@ -18,6 +18,7 @@ struct ResourceUsageMetrics : metrics::MetricSet metrics::LongValueMetric feedingBlocked; ResourceUsageMetrics(metrics::MetricSet *parent); + ~ResourceUsageMetrics(); }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.cpp index 61c1c970b4c..bc7414f828b 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.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 <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".grouping.sessionmanagermetrics"); #include "sessionmanager_metrics.h" namespace search { @@ -20,6 +17,8 @@ SessionManagerMetrics::SessionManagerMetrics(metrics::MetricSet *parent) { } +SessionManagerMetrics::~SessionManagerMetrics() {} + void SessionManagerMetrics::update( const proton::matching::SessionManager::Stats &stats) diff --git a/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.h index 9978db818ec..d142de22498 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.h @@ -18,6 +18,7 @@ struct SessionManagerMetrics : metrics::MetricSet void update(const proton::matching::SessionManager::Stats &stats); SessionManagerMetrics(metrics::MetricSet *parent); + ~SessionManagerMetrics(); }; } // namespace grouping diff --git a/searchcore/src/vespa/searchcore/proton/metrics/trans_log_server_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/trans_log_server_metrics.cpp index 06a20e8da78..392342bdd07 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/trans_log_server_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/trans_log_server_metrics.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include "trans_log_server_metrics.h" using search::transactionlog::DomainInfo; @@ -17,6 +16,8 @@ TransLogServerMetrics::DomainMetrics::DomainMetrics(metrics::MetricSet *parent, { } +TransLogServerMetrics::DomainMetrics::~DomainMetrics() {} + void TransLogServerMetrics::DomainMetrics::update(const DomainInfo &stats) { @@ -62,6 +63,8 @@ TransLogServerMetrics::TransLogServerMetrics(metrics::MetricSet *parent) { } +TransLogServerMetrics::~TransLogServerMetrics() { } + void TransLogServerMetrics::update(const DomainStats &stats) { diff --git a/searchcore/src/vespa/searchcore/proton/metrics/trans_log_server_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/trans_log_server_metrics.h index 4a7241bbef7..c5a4c569e95 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/trans_log_server_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/trans_log_server_metrics.h @@ -20,6 +20,7 @@ public: typedef std::unique_ptr<DomainMetrics> UP; DomainMetrics(metrics::MetricSet *parent, const vespalib::string &documentType); + ~DomainMetrics(); void update(const search::transactionlog::DomainInfo &stats); }; @@ -33,6 +34,7 @@ private: public: TransLogServerMetrics(metrics::MetricSet *parent); + ~TransLogServerMetrics(); void update(const search::transactionlog::DomainStats &stats); }; diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp index 8370010272d..289f51ac195 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.cpp @@ -40,10 +40,16 @@ protected: vespalib::Lock _lock; vespalib::CountDownLatch _latch; public: - ResultHandlerBase(uint32_t waitCnt) : _lock(), _latch(waitCnt) {} + ResultHandlerBase(uint32_t waitCnt); + ~ResultHandlerBase(); void await() { _latch.await(); } }; +ResultHandlerBase::ResultHandlerBase(uint32_t waitCnt) + : _lock(), + _latch(waitCnt) +{} +ResultHandlerBase::~ResultHandlerBase() { } class GenericResultHandler : public ResultHandlerBase, public IGenericResultHandler { private: @@ -53,7 +59,8 @@ public: ResultHandlerBase(waitCnt), _result() { } - virtual void handle(const Result &result) { + ~GenericResultHandler(); + void handle(const Result &result) override { if (result.hasError()) { vespalib::LockGuard guard(_lock); if (_result.hasError()) { @@ -67,6 +74,7 @@ public: const Result &getResult() const { return _result; } }; +GenericResultHandler::~GenericResultHandler() {} class BucketIdListResultHandler : public IBucketIdListResultHandler { @@ -77,6 +85,7 @@ public: BucketIdListResultHandler() : _bucketSet() { } + ~BucketIdListResultHandler(); virtual void handle(const BucketIdListResult &result) { const BucketIdListResult::List &buckets = result.getList(); for (size_t i = 0; i < buckets.size(); ++i) { @@ -94,6 +103,8 @@ public: }; +BucketIdListResultHandler::~BucketIdListResultHandler() {} + class SynchronizedBucketIdListResultHandler : public ResultHandlerBase, public BucketIdListResultHandler { @@ -102,6 +113,7 @@ public: : ResultHandlerBase(waitCnt), BucketIdListResultHandler() { } + ~SynchronizedBucketIdListResultHandler(); virtual void handle(const BucketIdListResult &result) { { vespalib::LockGuard guard(_lock); @@ -111,6 +123,7 @@ public: } }; +SynchronizedBucketIdListResultHandler::~SynchronizedBucketIdListResultHandler() {} class BucketInfoResultHandler : public IBucketInfoResultHandler { private: @@ -122,6 +135,7 @@ public: _first(true) { } + ~BucketInfoResultHandler(); virtual void handle(const BucketInfoResult &result) { if (_first) { _result = result; @@ -147,6 +161,8 @@ public: const BucketInfoResult &getResult() const { return _result; } }; +BucketInfoResultHandler::~BucketInfoResultHandler() {} + } #define NOT_YET throw vespalib::IllegalArgumentException("Not implemented yet") diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.cpp b/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.cpp index 55062b3c201..78eb1cfb3f6 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.cpp +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.cpp @@ -1,9 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".proton.persistenceengine.transportlatch"); - #include "transport_latch.h" using storage::spi::Result; @@ -16,6 +12,8 @@ TransportLatch::TransportLatch(uint32_t cnt) _result() {} +TransportLatch::~TransportLatch() {} + void TransportLatch::send(mbus::Reply::UP reply, ResultUP result, diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h b/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h index 49b721edd23..fcc9c362306 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h @@ -19,6 +19,7 @@ private: public: TransportLatch(uint32_t cnt); + ~TransportLatch(); virtual void send(mbus::Reply::UP reply, ResultUP result, bool documentWasFound, diff --git a/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt index 59bd592da93..09a635034f5 100644 --- a/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt @@ -17,6 +17,7 @@ vespa_add_library(searchcore_server STATIC docstorevalidator.cpp document_db_explorer.cpp document_db_maintenance_config.cpp + document_meta_store_read_guards.cpp document_scan_iterator.cpp document_subdb_collection_explorer.cpp document_subdb_collection_initializer.cpp @@ -56,6 +57,7 @@ vespa_add_library(searchcore_server STATIC maintenance_controller_explorer.cpp maintenance_jobs_injector.cpp maintenancecontroller.cpp + maintenancedocumentsubdb.cpp maintenancejobrunner.cpp matchers.cpp matchview.cpp diff --git a/searchcore/src/vespa/searchcore/proton/server/data_directory_upgrader.cpp b/searchcore/src/vespa/searchcore/proton/server/data_directory_upgrader.cpp index 7efd3b0e0dc..d33845f2b0f 100644 --- a/searchcore/src/vespa/searchcore/proton/server/data_directory_upgrader.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/data_directory_upgrader.cpp @@ -101,6 +101,8 @@ DataDirectoryUpgrader::RowColDir::RowColDir(const vespalib::string &row_, { } +DataDirectoryUpgrader::RowColDir::~RowColDir() { } + DataDirectoryUpgrader::ScanResult::ScanResult() : _rowColDirs(), _destDirExisting(false) diff --git a/searchcore/src/vespa/searchcore/proton/server/data_directory_upgrader.h b/searchcore/src/vespa/searchcore/proton/server/data_directory_upgrader.h index f36cafdbdcf..ccb4bc45eb9 100644 --- a/searchcore/src/vespa/searchcore/proton/server/data_directory_upgrader.h +++ b/searchcore/src/vespa/searchcore/proton/server/data_directory_upgrader.h @@ -22,6 +22,7 @@ public: public: RowColDir(const vespalib::string &row_, const vespalib::string &col_); + ~RowColDir(); const vespalib::string &row() const { return _row; } const vespalib::string &col() const { return _col; } vespalib::string dir() const { return row() + "/" + col(); } diff --git a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.cpp b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.cpp index 5612b5d70c6..eacab26edd0 100644 --- a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.cpp @@ -1,9 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include "disk_mem_usage_filter.h" #include "i_disk_mem_usage_listener.h" -#include <sstream> namespace proton { @@ -108,9 +106,9 @@ DiskMemUsageFilter::DiskMemUsageFilter(uint64_t physicalMemory_in) _acceptWrite(true), _dmstate(), _listeners() -{ -} +{ } +DiskMemUsageFilter::~DiskMemUsageFilter() { } void DiskMemUsageFilter::setMemoryStats(vespalib::ProcessMemoryStats memoryStats_in) diff --git a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.h b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.h index b10a28b6ff0..07e1587d171 100644 --- a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.h +++ b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.h @@ -2,13 +2,14 @@ #pragma once -#include <experimental/filesystem> -#include <vespa/vespalib/util/process_memory_stats.h> +#include "i_disk_mem_usage_notifier.h" +#include "disk_mem_usage_state.h" #include <vespa/searchcore/proton/persistenceengine/i_resource_write_filter.h> +#include <vespa/vespalib/util/process_memory_stats.h> #include <mutex> #include <atomic> -#include "i_disk_mem_usage_notifier.h" -#include "disk_mem_usage_state.h" +#include <experimental/filesystem> + namespace proton { @@ -29,28 +30,23 @@ public: double _memoryLimit; double _diskLimit; - Config() - : _memoryLimit(1.0), - _diskLimit(1.0) - { - } + Config() : Config(1.0, 1.0) { } Config(double memoryLimit_in, double diskLimit_in) : _memoryLimit(memoryLimit_in), _diskLimit(diskLimit_in) - { - } + { } }; private: mutable Mutex _lock; // protect _memoryStats, _diskStats, _config, _state vespalib::ProcessMemoryStats _memoryStats; - uint64_t _physicalMemory; - space_info _diskStats; - Config _config; - State _state; - std::atomic<bool> _acceptWrite; - DiskMemUsageState _dmstate; + uint64_t _physicalMemory; + space_info _diskStats; + Config _config; + State _state; + std::atomic<bool> _acceptWrite; + DiskMemUsageState _dmstate; std::vector<IDiskMemUsageListener *> _listeners; void recalcState(const Guard &guard); // called with _lock held @@ -60,6 +56,7 @@ private: public: DiskMemUsageFilter(uint64_t physicalMememory_in); + ~DiskMemUsageFilter(); void setMemoryStats(vespalib::ProcessMemoryStats memoryStats_in); void setDiskStats(space_info diskStats_in); void setConfig(Config config); @@ -69,10 +66,10 @@ public: uint64_t getPhysicalMemory() const { return _physicalMemory; } double getMemoryUsedRatio() const; double getDiskUsedRatio() const; - virtual bool acceptWriteOperation() const override; - virtual State getAcceptState() const override; - virtual void addDiskMemUsageListener(IDiskMemUsageListener *listener) override; - virtual void removeDiskMemUsageListener(IDiskMemUsageListener *listener) override; + bool acceptWriteOperation() const override; + State getAcceptState() const override; + void addDiskMemUsageListener(IDiskMemUsageListener *listener) override; + void removeDiskMemUsageListener(IDiskMemUsageListener *listener) override; }; diff --git a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp index abd05ed8783..2c1768b6548 100644 --- a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include "disk_mem_usage_sampler.h" #include <vespa/vespalib/util/timer.h> #include <vespa/searchlib/common/lambdatask.h> diff --git a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp new file mode 100644 index 00000000000..680dadda5dd --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp @@ -0,0 +1,16 @@ +// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "document_meta_store_read_guards.h" +#include "documentsubdbcollection.h" + +namespace proton { + +DocumentMetaStoreReadGuards::DocumentMetaStoreReadGuards(DocumentSubDBCollection &subDBs) + : readydms(subDBs.getReadySubDB()->getDocumentMetaStoreContext().getReadGuard()), + notreadydms(subDBs.getNotReadySubDB()->getDocumentMetaStoreContext().getReadGuard()), + remdms(subDBs.getRemSubDB()->getDocumentMetaStoreContext().getReadGuard()) +{ } + +DocumentMetaStoreReadGuards::~DocumentMetaStoreReadGuards() { } + +} diff --git a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h index b2e845d221a..54acb03d54d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h +++ b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h @@ -2,11 +2,12 @@ #pragma once -#include "documentsubdbcollection.h" #include <vespa/searchcore/proton/documentmetastore/i_document_meta_store_context.h> namespace proton { +class DocumentSubDBCollection; + /** * Class that takes and owns read guards of the document meta stores of the 3 sub databases. * Provides stats regarding the number of documents in the sub databases. @@ -16,12 +17,10 @@ struct DocumentMetaStoreReadGuards IDocumentMetaStoreContext::IReadGuard::UP readydms; IDocumentMetaStoreContext::IReadGuard::UP notreadydms; IDocumentMetaStoreContext::IReadGuard::UP remdms; - DocumentMetaStoreReadGuards(DocumentSubDBCollection &subDBs) - : readydms(subDBs.getReadySubDB()->getDocumentMetaStoreContext().getReadGuard()), - notreadydms(subDBs.getNotReadySubDB()->getDocumentMetaStoreContext().getReadGuard()), - remdms(subDBs.getRemSubDB()->getDocumentMetaStoreContext().getReadGuard()) - { - } + + DocumentMetaStoreReadGuards(DocumentSubDBCollection &subDBs); + ~DocumentMetaStoreReadGuards(); + uint32_t numActiveDocs() const { return readydms->get().getNumActiveLids(); } 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/fileconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp index 31c1756f9d2..07d8ffabb62 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp @@ -130,29 +130,29 @@ class ConfigFile std::vector<char> _content; public: - ConfigFile(void); + ConfigFile(); + ~ConfigFile(); ConfigFile(const vespalib::string &name, const vespalib::string &fullName); - nbostream & - serialize(nbostream &stream) const; + nbostream &serialize(nbostream &stream) const; - nbostream & - deserialize(nbostream &stream); + nbostream &deserialize(nbostream &stream); - void - save(const vespalib::string &snapDir) const; + void save(const vespalib::string &snapDir) const; }; -ConfigFile::ConfigFile(void) +ConfigFile::ConfigFile() : _name(), _modTime(0), _content() { } +ConfigFile::~ConfigFile() {} + ConfigFile::ConfigFile(const vespalib::string &name, const vespalib::string &fullName) diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.cpp new file mode 100644 index 00000000000..85e906d621d --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.cpp @@ -0,0 +1,30 @@ +// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "maintenancedocumentsubdb.h" + +namespace proton { + +MaintenanceDocumentSubDB::MaintenanceDocumentSubDB() + : _metaStore(), + _retriever(), + _subDbId(0u) +{ } + +MaintenanceDocumentSubDB::~MaintenanceDocumentSubDB() { } + +MaintenanceDocumentSubDB::MaintenanceDocumentSubDB(const IDocumentMetaStore::SP & metaStore, + const IDocumentRetriever::SP & retriever, + uint32_t subDbId) + : _metaStore(metaStore), + _retriever(retriever), + _subDbId(subDbId) +{ } + +void +MaintenanceDocumentSubDB::clear() { + _metaStore.reset(); + _retriever.reset(); + _subDbId = 0u; +} + +} // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.h b/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.h index 9154299b6f5..2a44b3ea390 100644 --- a/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.h @@ -5,8 +5,7 @@ #include <vespa/searchcore/proton/documentmetastore/i_document_meta_store.h> #include <vespa/searchcore/proton/persistenceengine/i_document_retriever.h> -namespace proton -{ +namespace proton { /** * The view of a document sub db as seen from the maintenance controller @@ -19,30 +18,16 @@ public: IDocumentRetriever::SP _retriever; uint32_t _subDbId; - MaintenanceDocumentSubDB(void) - : _metaStore(), - _retriever(), - _subDbId(0u) - { - } + MaintenanceDocumentSubDB(); + ~MaintenanceDocumentSubDB(); MaintenanceDocumentSubDB(const IDocumentMetaStore::SP & metaStore, const IDocumentRetriever::SP & retriever, - uint32_t subDbId) - : _metaStore(metaStore), - _retriever(retriever), - _subDbId(subDbId) - { - } + uint32_t subDbId); bool valid() const { return bool(_metaStore); } - void clear() { - _metaStore.reset(); - _retriever.reset(); - _subDbId = 0u; - } + void clear(); }; - -} // namespace proton +} diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index c2f798eebd5..ef377ce1eb5 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -104,6 +104,7 @@ Proton::ProtonFileHeaderContext::ProtonFileHeaderContext(const Proton &proton_, assert(!_hostName.empty()); } +Proton::ProtonFileHeaderContext::~ProtonFileHeaderContext() { } void Proton::ProtonFileHeaderContext::addTags(vespalib::GenericHeader &header, diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h index bba01ee8843..a1ec14dcfd1 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton.h @@ -86,6 +86,7 @@ private: public: ProtonFileHeaderContext(const Proton &proton_, const vespalib::string &creator); + ~ProtonFileHeaderContext(); virtual void addTags(vespalib::GenericHeader &header, diff --git a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp index 2c375fce6d5..7761ec59913 100644 --- a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp @@ -24,8 +24,11 @@ struct Pair { value(v) { } + ~Pair(); }; +Pair::~Pair() {} + } namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp b/searchcore/src/vespa/searchcore/proton/server/searchable_feed_view.cpp index 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 <vespa/searchcore/proton/common/bucketfactory.h> #include <vespa/searchcore/proton/metrics/feed_metrics.h> -#include <vespa/searchcore/proton/matching/match_context.h> #include <vespa/searchcore/proton/documentmetastore/ilidreusedelayer.h> #include <vespa/searchcore/proton/reference/i_gid_to_lid_change_handler.h> -#include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/text/stringtokenizer.h> #include <vespa/vespalib/util/closuretask.h> -#include <vespa/searchlib/common/lambdatask.h> #include <vespa/vespalib/util/exceptions.h> + #include <vespa/log/log.h> 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<IGidToLidChangeHandler> &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<IGidToLidChangeHandler> &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 <vespa/fastos/fastos.h> #include "searchcontext.h" #include "searchview.h" #include <vespa/searchcore/proton/docsummary/docsumcontext.h> -#include <vespa/searchcore/proton/matching/match_context.h> #include <vespa/searchlib/engine/searchreply.h> #include <vespa/log/log.h> 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<SearchView> 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/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp index 586d7cfdf83..35ae864b7e1 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp @@ -57,6 +57,49 @@ IIndexWriter::SP nullIndexWriter; } + +StoreOnlyDocSubDB::Config::Config(const DocTypeName &docTypeName, + const vespalib::string &subName, + const vespalib::string &baseDir, + const search::GrowStrategy &attributeGrow, + size_t attributeGrowNumDocs, + uint32_t subDbId, + SubDbType subDbType) + : _docTypeName(docTypeName), + _subName(subName), + _baseDir(baseDir + "/" + subName), + _attributeGrow(attributeGrow), + _attributeGrowNumDocs(attributeGrowNumDocs), + _subDbId(subDbId), + _subDbType(subDbType) +{ } +StoreOnlyDocSubDB::Config::~Config() { } + +StoreOnlyDocSubDB::Context::Context(IDocumentSubDB::IOwner &owner, + search::transactionlog::SyncProxy &tlSyncer, + const IGetSerialNum &getSerialNum, + const search::common::FileHeaderContext &fileHeaderContext, + searchcorespi::index::IThreadingService &writeService, + vespalib::ThreadStackExecutorBase &summaryExecutor, + std::shared_ptr<BucketDBOwner> bucketDB, + bucketdb::IBucketDBHandlerInitializer & bucketDBHandlerInitializer, + LegacyDocumentDBMetrics &metrics, + std::mutex &configMutex, + const HwInfo &hwInfo) + : _owner(owner), + _tlSyncer(tlSyncer), + _getSerialNum(getSerialNum), + _fileHeaderContext(fileHeaderContext), + _writeService(writeService), + _summaryExecutor(summaryExecutor), + _bucketDB(bucketDB), + _bucketDBHandlerInitializer(bucketDBHandlerInitializer), + _metrics(metrics), + _configMutex(configMutex), + _hwInfo(hwInfo) +{ } +StoreOnlyDocSubDB::Context::~Context() { } + StoreOnlyDocSubDB::StoreOnlyDocSubDB(const Config &cfg, const Context &ctx) : DocSubDB(ctx._owner, ctx._tlSyncer), _docTypeName(cfg._docTypeName), @@ -470,6 +513,25 @@ StoreOnlyDocSubDB::getDocumentDBReference() return std::shared_ptr<IDocumentDBReference>(); } +StoreOnlySubDBFileHeaderContext:: +StoreOnlySubDBFileHeaderContext(StoreOnlyDocSubDB &owner, + const search::common::FileHeaderContext & parentFileHeaderContext, + const DocTypeName &docTypeName, + const vespalib::string &baseDir) + : search::common::FileHeaderContext(), + _owner(owner), + _parentFileHeaderContext(parentFileHeaderContext), + _docTypeName(docTypeName), + _subDB() +{ + size_t pos = baseDir.rfind('/'); + if (pos != vespalib::string::npos) + _subDB = baseDir.substr(pos + 1); + else + _subDB = baseDir; +} +StoreOnlySubDBFileHeaderContext::~StoreOnlySubDBFileHeaderContext() {} + void StoreOnlyDocSubDB::tearDownReferences(IDocumentDBReferenceResolver &resolver) { diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h index 3136edcb34f..69b46cd4ead 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h @@ -71,19 +71,8 @@ public: StoreOnlySubDBFileHeaderContext(StoreOnlyDocSubDB &owner, const search::common::FileHeaderContext & parentFileHeaderContext, const DocTypeName &docTypeName, - const vespalib::string &baseDir) - : search::common::FileHeaderContext(), - _owner(owner), - _parentFileHeaderContext(parentFileHeaderContext), - _docTypeName(docTypeName), - _subDB() - { - size_t pos = baseDir.rfind('/'); - if (pos != vespalib::string::npos) - _subDB = baseDir.substr(pos + 1); - else - _subDB = baseDir; - } + const vespalib::string &baseDir); + ~StoreOnlySubDBFileHeaderContext(); void addTags(vespalib::GenericHeader &header, const vespalib::string &name) const override; }; @@ -113,15 +102,8 @@ public: const search::GrowStrategy &attributeGrow, size_t attributeGrowNumDocs, uint32_t subDbId, - SubDbType subDbType) - : _docTypeName(docTypeName), - _subName(subName), - _baseDir(baseDir + "/" + subName), - _attributeGrow(attributeGrow), - _attributeGrowNumDocs(attributeGrowNumDocs), - _subDbId(subDbId), - _subDbType(subDbType) - { } + SubDbType subDbType); + ~Config(); }; struct Context { @@ -148,19 +130,8 @@ public: bucketDBHandlerInitializer, LegacyDocumentDBMetrics &metrics, std::mutex &configMutex, - const HwInfo &hwInfo) - : _owner(owner), - _tlSyncer(tlSyncer), - _getSerialNum(getSerialNum), - _fileHeaderContext(fileHeaderContext), - _writeService(writeService), - _summaryExecutor(summaryExecutor), - _bucketDB(bucketDB), - _bucketDBHandlerInitializer(bucketDBHandlerInitializer), - _metrics(metrics), - _configMutex(configMutex), - _hwInfo(hwInfo) - { } + const HwInfo &hwInfo); + ~Context(); }; @@ -188,7 +159,7 @@ protected: LegacyDocumentDBMetrics &_metrics; vespalib::VarHolder<ISearchHandler::SP> _iSearchView; vespalib::VarHolder<IFeedView::SP> _iFeedView; - std::mutex &_configMutex; + std::mutex &_configMutex; HwInfo _hwInfo; private: const IGetSerialNum &_getSerialNum; diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp index 7659a428fa3..5d16b0ba331 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp +++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp @@ -92,6 +92,7 @@ public: : _caller(std::move(closure)), _index(index) { } + ~DiskIndexWithDestructorClosure(); const IDiskIndex &getWrapped() const { return *_index; } /** @@ -129,6 +130,8 @@ public: }; +DiskIndexWithDestructorClosure::~DiskIndexWithDestructorClosure() {} + } // namespace uint32_t @@ -409,6 +412,33 @@ IndexMaintainer::createNewSourceCollection(const LockGuard &newSearchLock) return ISearchableIndexCollection::UP(new IndexCollection(_selector, *currentLeaf)); } +IndexMaintainer::FlushArgs::FlushArgs() + : old_index(), + old_absolute_id(0), + old_source_list(), + save_info(), + flush_serial_num(), + stats(NULL), + _skippedEmptyLast(false), + _extraIndexes(), + _changeGens(), + _wtSchema() +{ +} +IndexMaintainer::FlushArgs::~FlushArgs() { } +IndexMaintainer::FlushArgs::FlushArgs(FlushArgs &&) = default; +IndexMaintainer::FlushArgs & IndexMaintainer::FlushArgs::operator=(FlushArgs &&) = default; + +IndexMaintainer::WipeHistoryArgs::WipeHistoryArgs() + : _old_source_list(), + _new_source_list() +{ } + +IndexMaintainer::WipeHistoryArgs::WipeHistoryArgs(WipeHistoryArgs &&) = default; +IndexMaintainer::WipeHistoryArgs & IndexMaintainer::WipeHistoryArgs::operator=(WipeHistoryArgs &&) = default; + +IndexMaintainer::WipeHistoryArgs::~WipeHistoryArgs() { } + bool IndexMaintainer::doneInitFlush(FlushArgs *args, IMemoryIndex::SP *new_index) { diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h index c7e0a304db6..dbab3e40028 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h +++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h @@ -211,19 +211,12 @@ class IndexMaintainer : public IIndexManager, ChangeGens _changeGens; Schema::SP _wtSchema; - FlushArgs(void) - : old_index(), - old_absolute_id(0), - old_source_list(), - save_info(), - flush_serial_num(), - stats(NULL), - _skippedEmptyLast(false), - _extraIndexes(), - _changeGens(), - _wtSchema() - { - } + FlushArgs(); + FlushArgs(const FlushArgs &) = delete; + FlushArgs & operator=(const FlushArgs &) = delete; + FlushArgs(FlushArgs &&); + FlushArgs & operator=(FlushArgs &&); + ~FlushArgs(); }; bool doneInitFlush(FlushArgs *args, IMemoryIndex::SP *new_index); @@ -288,17 +281,18 @@ class IndexMaintainer : public IIndexManager, ISearchableIndexCollection::SP _old_source_list; ISearchableIndexCollection::SP _new_source_list; - WipeHistoryArgs() - : _old_source_list(), - _new_source_list() - { } + WipeHistoryArgs(); + WipeHistoryArgs(WipeHistoryArgs &&); + WipeHistoryArgs & operator=(WipeHistoryArgs &&); + + ~WipeHistoryArgs(); }; bool doneWipeHistory(WipeHistoryArgs &args); Schema getSchema(void) const; - Schema::SP getActiveFusionWipeTimeSchema(void) const; - search::TuneFileAttributes getAttrTune(void); - ChangeGens getChangeGens(void); + Schema::SP getActiveFusionWipeTimeSchema() const; + search::TuneFileAttributes getAttrTune(); + ChangeGens getChangeGens(); /* * Schedule document db executor task to use reconfigurer to diff --git a/searchlib/src/apps/fileheaderinspect/fileheaderinspect.cpp b/searchlib/src/apps/fileheaderinspect/fileheaderinspect.cpp index 0d6f8c6baf9..3f0801a3a3f 100644 --- a/searchlib/src/apps/fileheaderinspect/fileheaderinspect.cpp +++ b/searchlib/src/apps/fileheaderinspect/fileheaderinspect.cpp @@ -27,6 +27,7 @@ private: public: Application(); + ~Application(); int Main(); }; @@ -34,9 +35,9 @@ Application::Application() : _fileName(""), _delimiter(';'), _quiet(false) -{ - // empty -} +{ } + +Application::~Application() {} void diff --git a/searchlib/src/apps/tests/biglogtest.cpp b/searchlib/src/apps/tests/biglogtest.cpp index 5e81b02493e..3b943d9fd17 100644 --- a/searchlib/src/apps/tests/biglogtest.cpp +++ b/searchlib/src/apps/tests/biglogtest.cpp @@ -124,19 +124,23 @@ struct factory<LogDataStore> : DioTune vespalib::ThreadStackExecutor _executor; transactionlog::NoSyncProxy _noTlSyncer; LogDataStore _datastore; - factory(std::string dir) - : DioTune(), - _fileHeaderContext(), - _config(), - _executor(_config.getNumThreads(), 128*1024), - _noTlSyncer(), - _datastore(_executor, dir, _config, GrowStrategy(), tuning, - _fileHeaderContext, _noTlSyncer, NULL) - {} + factory(std::string dir); + ~factory(); IDataStore & operator() () { return _datastore; } }; +factory<LogDataStore>::factory(std::string dir) + : DioTune(), + _fileHeaderContext(), + _config(), + _executor(_config.getNumThreads(), 128*1024), + _noTlSyncer(), + _datastore(_executor, dir, _config, GrowStrategy(), tuning, _fileHeaderContext, _noTlSyncer, NULL) +{} + +factory<LogDataStore>::~factory() {} + template <typename DS> void Test::testDIO() diff --git a/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp b/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp index 872664b9f9f..7409ad4abbd 100644 --- a/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp +++ b/searchlib/src/apps/vespa-ranking-expression-analyzer/vespa-ranking-expression-analyzer.cpp @@ -263,19 +263,8 @@ struct State { std::vector<vespalib::string> options; std::vector<double> options_us; - explicit State(const vespalib::string &file_name, - vespalib::string expression_in) - : name(strip_name(file_name)), - expression(std::move(expression_in)), - function(Function::parse(expression, FeatureNameExtractor())), - fun_info(function), - compiled_function(), - llvm_compile_s(0.0), - llvm_execute_us(0.0), - options(), - options_us() - { - } + State(const vespalib::string &file_name, vespalib::string expression_in); + ~State(); void benchmark_llvm_compile() { BenchmarkTimer timer(1.0); @@ -323,6 +312,21 @@ struct State { } }; +State::State(const vespalib::string &file_name, vespalib::string expression_in) + : name(strip_name(file_name)), + expression(std::move(expression_in)), + function(Function::parse(expression, FeatureNameExtractor())), + fun_info(function), + compiled_function(), + llvm_compile_s(0.0), + llvm_execute_us(0.0), + options(), + options_us() +{ +} + +State::~State() {} + //----------------------------------------------------------------------------- struct MyApp : public FastOS_Application { diff --git a/searchlib/src/tests/attribute/attributeupdater.h b/searchlib/src/tests/attribute/attributeupdater.h index 5193ca0f873..2e5b1cc2622 100644 --- a/searchlib/src/tests/attribute/attributeupdater.h +++ b/searchlib/src/tests/attribute/attributeupdater.h @@ -122,12 +122,8 @@ protected: public: AttributeUpdater(const AttributePtr & attrPtr, const std::vector<T> & values, RandomGenerator & rndGen, bool validate, uint32_t commitFreq, - uint32_t minValueCount, uint32_t maxValueCount) : - _attrPtr(attrPtr), _attrVec(*(static_cast<Vector *>(attrPtr.get()))), - _values(values), _buffer(), _getBuffer(), _rndGen(rndGen), _expected(), _timer(), _status(), _validator(), - _validate(validate), _commitFreq(commitFreq), _minValueCount(minValueCount), _maxValueCount(maxValueCount) - { - } + uint32_t minValueCount, uint32_t maxValueCount); + ~AttributeUpdater(); void resetStatus() { _status.reset(); } @@ -142,6 +138,18 @@ public: }; template <typename Vector, typename T, typename BT> +AttributeUpdater<Vector, T, BT>::AttributeUpdater(const AttributePtr & attrPtr, const std::vector<T> & values, + RandomGenerator & rndGen, bool validate, uint32_t commitFreq, + uint32_t minValueCount, uint32_t maxValueCount) + :_attrPtr(attrPtr), _attrVec(*(static_cast<Vector *>(attrPtr.get()))), _values(values), _buffer(), + _getBuffer(), _rndGen(rndGen), _expected(), _timer(), _status(), _validator(), _validate(validate), + _commitFreq(commitFreq), _minValueCount(minValueCount), _maxValueCount(maxValueCount) +{} + +template <typename Vector, typename T, typename BT> +AttributeUpdater<Vector, T, BT>::~AttributeUpdater() {} + +template <typename Vector, typename T, typename BT> class AttributeUpdaterThread : public AttributeUpdater<Vector, T, BT>, public Runnable { private: @@ -150,13 +158,22 @@ private: public: AttributeUpdaterThread(const AttributePtr & attrPtr, const std::vector<T> & values, RandomGenerator & rndGen, bool validate, uint32_t commitFreq, - uint32_t minValueCount, uint32_t maxValueCount) : - AttributeUpdater<Vector, T, BT>(attrPtr, values, rndGen, validate, commitFreq, minValueCount, maxValueCount), - Runnable(0) {} + uint32_t minValueCount, uint32_t maxValueCount); + ~AttributeUpdaterThread(); virtual void doRun(); }; +template <typename Vector, typename T, typename BT> +AttributeUpdaterThread<Vector, T, BT>::AttributeUpdaterThread(const AttributePtr & attrPtr, const std::vector<T> & values, + RandomGenerator & rndGen, bool validate, uint32_t commitFreq, + uint32_t minValueCount, uint32_t maxValueCount) + : AttributeUpdater<Vector, T, BT>(attrPtr, values, rndGen, validate, commitFreq, minValueCount, maxValueCount), + Runnable(0) +{} +template <typename Vector, typename T, typename BT> +AttributeUpdaterThread<Vector, T, BT>::~AttributeUpdaterThread() { } + template <typename Vector, typename T, typename BT> void diff --git a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp index f3983a4900f..1c2ca360bd8 100644 --- a/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp +++ b/searchlib/src/tests/attribute/bitvector/bitvector_test.cpp @@ -611,11 +611,8 @@ TEST_F("Test bitvectors with weighted set value string", BitVectorTest) class Verifier : public search::test::SearchIteratorVerifier { public: - Verifier() : _bv(BitVector::create(getDocIdLimit())) { - for (uint32_t docId: getExpectedDocIds()) { - _bv->setBit(docId); - } - } + Verifier(); + ~Verifier(); SearchIterator::UP create(bool strict) const override { return BitVectorIterator::create(_bv.get(), getDocIdLimit(), _tfmd, strict); @@ -626,6 +623,15 @@ private: BitVector::UP _bv; }; +Verifier::Verifier() + : _bv(BitVector::create(getDocIdLimit())) +{ + for (uint32_t docId: getExpectedDocIds()) { + _bv->setBit(docId); + } +} +Verifier::~Verifier() {} + TEST("Test that bitvector iterators adheres to SearchIterator requirements") { Verifier searchIteratorVerifier; searchIteratorVerifier.verify(); diff --git a/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp b/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp index 62bdbd9bf51..120c471de48 100644 --- a/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp +++ b/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp @@ -169,16 +169,8 @@ TEST_F("require that string iterators are created correctly", StringFixture) { class Verifier : public search::test::SearchIteratorVerifier { public: - Verifier() : - _attr(make_attribute(BasicType::INT64, CollectionType::WSET, true)) - { - add_docs(_attr, getDocIdLimit()); - auto docids = getExpectedDocIds(); - IntegerAttribute *int_attr = static_cast<IntegerAttribute *>(_attr.get()); - for (auto docid: docids) { - set_doc(int_attr, docid, int64_t(123), 1); - } - } + Verifier(); + ~Verifier(); SearchIterator::UP create(bool strict) const override { (void) strict; const IDocumentWeightAttribute *api(_attr->asDocumentWeightAttribute()); @@ -191,6 +183,19 @@ private: mutable fef::TermFieldMatchData _tfmd; AttributeVector::SP _attr; }; + +Verifier::Verifier() + : _attr(make_attribute(BasicType::INT64, CollectionType::WSET, true)) +{ + add_docs(_attr, getDocIdLimit()); + auto docids = getExpectedDocIds(); + IntegerAttribute *int_attr = static_cast<IntegerAttribute *>(_attr.get()); + for (auto docid: docids) { + set_doc(int_attr, docid, int64_t(123), 1); + } +} +Verifier::~Verifier() {} + TEST("verify document weight search iterator") { Verifier verifier; verifier.verify(); diff --git a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp index df0a406aebb..c57bf0ba87c 100644 --- a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp +++ b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp @@ -102,13 +102,8 @@ private: public: typedef std::shared_ptr<MemAttr> SP; - MemAttr(void) - : _datWriter(), - _idxWriter(), - _weightWriter(), - _udatWriter() - { - } + MemAttr(); + ~MemAttr(); // Implements IAttributeSaveTarget virtual bool setup() { return true; } @@ -127,6 +122,14 @@ public: operator==(const MemAttr &rhs) const; }; +MemAttr::MemAttr() + : _datWriter(), + _idxWriter(), + _weightWriter(), + _udatWriter() +{ } +MemAttr::~MemAttr() {} + class EnumeratedSaveTest { private: diff --git a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp index b9c2279995e..63d12aaf242 100644 --- a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp +++ b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp @@ -89,8 +89,8 @@ private: IndexVector _indices; ExpectedVector _expected; Reader(uint32_t generation, const IndexVector & indices, - const ExpectedVector & expected) : - _generation(generation), _indices(indices), _expected(expected) {} + const ExpectedVector & expected); + ~Reader(); }; void @@ -103,6 +103,11 @@ public: int Main(); }; +EnumStoreTest::Reader::Reader(uint32_t generation, const IndexVector & indices, const ExpectedVector & expected) + : _generation(generation), _indices(indices), _expected(expected) +{} +EnumStoreTest::Reader::~Reader() { } + void EnumStoreTest::testIndex() { 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<ImportedAttributeVector> imported_attr; std::shared_ptr<MockGidToLidMapperFactory> mapper_factory; - Fixture() - : target_attr(create_single_attribute<IntegerAttribute>(BasicType::INT32)), - reference_attr(create_reference_attribute()), - imported_attr(create_attribute_vector_from_members()), - mapper_factory(std::make_shared<MockGidToLidMapperFactory>()) - { - 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<IntegerAttribute>(BasicType::INT32)), + reference_attr(create_reference_attribute()), + imported_attr(create_attribute_vector_from_members()), + mapper_factory(std::make_shared<MockGidToLidMapperFactory>()) +{ + reference_attr->setGidToLidMapperFactory(mapper_factory); +} + +Fixture::~Fixture() {} + template <typename AttrValueType, typename PredicateType> 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<Hit> 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<const MinMaxPostingInfo *>(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<uint32_t> { public: - DocSet() : std::set<uint32_t>() {} + DocSet(); + ~DocSet(); DocSet(const uint32_t *b, const uint32_t *e) : std::set<uint32_t>(b, e) {} DocSet & put(const uint32_t &v) { insert(v); @@ -69,6 +70,9 @@ public: } }; +DocSet::DocSet() : std::set<uint32_t>() {} +DocSet::~DocSet() {} + template <typename V, typename T> 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 <typename V, typename T> +PostingList<V, T>::PostingList(V & vec, T value) : _vec(&vec), _value(value), _hits() {} + +template <typename V, typename T> +PostingList<V, T>::~PostingList() {} + class DocRange { public: @@ -608,20 +619,8 @@ void SearchContextTest::testSearch(const ConfigMap & cfgs) { template<typename T, typename A> 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<A *>(_attribute.get())); - EXPECT_TRUE(dynamic_cast<A *>(_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); } @@ -632,6 +631,25 @@ private: }; template<typename T, typename A> +Verifier<T, A>::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<A *>(_attribute.get())); + EXPECT_TRUE(dynamic_cast<A *>(_attribute.get())->update(doc, key)); + } + _attribute->commit(true); + _sc = SearchContextTest::getSearch(*_attribute, keyAsString); + ASSERT_TRUE(_sc->valid()); + _sc->fetchPostings(true); +} + +template<typename T, typename A> +Verifier<T, A>::~Verifier() {} + +template<typename T, typename A> void SearchContextTest::testSearchIterator(T key, const vespalib::string &keyAsString, const ConfigMap &cfgs) { for (const auto & cfg : 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<uint32_t> 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<uint32_t> 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<uint32_t> 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 <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP("termfieldmodel_test"); + #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/searchlib/fef/fef.h> #include <vespa/searchlib/queryeval/searchiterator.h> @@ -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<uint32_t> _data; public: - MyTerm(const std::set<uint32_t> &doc, - const std::set<uint32_t> &pos) - : _docs(doc), - _data(pos) - { - } + MyTerm(const std::set<uint32_t> &doc, const std::set<uint32_t> &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<uint32_t> &doc, const std::set<uint32_t> &pos) + : _docs(doc), + _data(pos) +{} +MyTerm::~MyTerm() {} + class MyQuery { private: std::vector<MyTerm*> _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<BooleanMatchIteratorWrapper>(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 <typename HeapType> +WandTestSpec<HeapType>::WandTestSpec(uint32_t scoresToTrack, uint32_t scoresAdjustFrequency, + score_t scoreThreshold, double thresholdBoostFactor) + : WandSpec(), + heap(scoresToTrack), + rootMatchData(), + matchParams(heap, scoreThreshold, thresholdBoostFactor, scoresAdjustFrequency) +{} + +template <typename HeapType> +WandTestSpec<HeapType>::~WandTestSpec() {} + typedef WandTestSpec<TestHeap> WandSpecWithTestHeap; typedef WandTestSpec<SharedWeakAndPriorityQueue> 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<int64_t>::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<int64_t>::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 <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP("ranksetup_test"); + #include <vespa/vespalib/testkit/testapp.h> #include <map> @@ -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<SubscriberAgent> - (new SubscriberAgent(tlsSpec, domain, generator, 0, i, true))); - } - - for (uint32_t i = 0; i < numVisitors; ++i) { - _visitors.push_back(std::shared_ptr<VisitorAgent>(new VisitorAgent(tlsSpec, domain, generator, i, true))); - } - } + uint64_t visitorInterval, uint64_t pruneInterval); + ~ControllerThread(); void startSubscribers(); uint32_t runningVisitors(); std::vector<std::shared_ptr<SubscriberAgent> > & 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<SubscriberAgent>(tlsSpec, domain, generator, 0, i, true)); + } + + for (uint32_t i = 0; i < numVisitors; ++i) { + _visitors.push_back(std::make_shared<VisitorAgent>(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 <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP("bufferwriter_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/searchlib/util/bufferwriter.h> @@ -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<char> 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/attribute/CMakeLists.txt b/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt index 35303d03b91..66a614379a8 100644 --- a/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt +++ b/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt @@ -29,6 +29,7 @@ vespa_add_library(searchlib_attribute OBJECT createsinglefastsearch.cpp createsinglestd.cpp defines.cpp + diversity.cpp dociditerator.cpp enumattribute.cpp enumattributesaver.cpp diff --git a/searchlib/src/vespa/searchlib/attribute/attributeguard.cpp b/searchlib/src/vespa/searchlib/attribute/attributeguard.cpp index 531efd66d83..3726a26733f 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributeguard.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributeguard.cpp @@ -30,6 +30,8 @@ AttributeEnumGuard::AttributeEnumGuard(const AttributeGuard & attr) : takeLock(); } +AttributeEnumGuard::~AttributeEnumGuard() { } + void AttributeEnumGuard::takeLock() { if (valid()) { std::shared_lock<std::shared_timed_mutex> take(get()->getEnumLock(), diff --git a/searchlib/src/vespa/searchlib/attribute/attributeguard.h b/searchlib/src/vespa/searchlib/attribute/attributeguard.h index 74f8be78628..9e83ac65b28 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributeguard.h +++ b/searchlib/src/vespa/searchlib/attribute/attributeguard.h @@ -33,6 +33,7 @@ public: AttributeEnumGuard & operator = (const AttributeEnumGuard &) = delete; explicit AttributeEnumGuard(const AttributeVectorSP & attribute); explicit AttributeEnumGuard(const AttributeGuard & attribute); + ~AttributeEnumGuard(); private: mutable std::shared_lock<std::shared_timed_mutex> _lock; void takeLock(); diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp index 318eab5d96e..8d4b437e8b5 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp @@ -70,6 +70,8 @@ AttributeVector::BaseName::BaseName(const vespalib::stringref &base, append(name); } +AttributeVector::BaseName::~BaseName() { } + AttributeVector::BaseName::string AttributeVector::BaseName::getIndexName() const diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index b01c06e7c75..496b6cdfbf5 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -136,6 +136,7 @@ public: BaseName(const vespalib::stringref &base, const vespalib::stringref &snap, const vespalib::stringref &name); + ~BaseName(); string getIndexName() const; string getSnapshotName() const; diff --git a/searchlib/src/vespa/searchlib/attribute/createarraystd.cpp b/searchlib/src/vespa/searchlib/attribute/createarraystd.cpp index b47b27db729..29ea819f71d 100644 --- a/searchlib/src/vespa/searchlib/attribute/createarraystd.cpp +++ b/searchlib/src/vespa/searchlib/attribute/createarraystd.cpp @@ -1,17 +1,16 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/searchlib/attribute/attributefactory.h> +#include "attributefactory.h" #include "defines.h" +#include "attributevector.hpp" +#include "multivalueattribute.hpp" +#include "multinumericattribute.hpp" +#include "multistringattribute.h" + #include <vespa/log/log.h> LOG_SETUP(".createarraystd"); -#include <vespa/searchlib/attribute/attributevector.hpp> -#include <vespa/searchlib/attribute/multivalueattribute.hpp> -#include <vespa/searchlib/attribute/multinumericattribute.hpp> -#include <vespa/searchlib/attribute/multistringattribute.h> - namespace search { using attribute::BasicType; diff --git a/searchlib/src/vespa/searchlib/attribute/diversity.cpp b/searchlib/src/vespa/searchlib/attribute/diversity.cpp new file mode 100644 index 00000000000..93b8fa5ee83 --- /dev/null +++ b/searchlib/src/vespa/searchlib/attribute/diversity.cpp @@ -0,0 +1,11 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "diversity.hpp" + +namespace search { +namespace attribute { +namespace diversity { + +} +} +} diff --git a/searchlib/src/vespa/searchlib/attribute/diversity.h b/searchlib/src/vespa/searchlib/attribute/diversity.h index e1914b344a7..9fd0e7c31ad 100644 --- a/searchlib/src/vespa/searchlib/attribute/diversity.h +++ b/searchlib/src/vespa/searchlib/attribute/diversity.h @@ -34,7 +34,9 @@ public: const ITR &get() const { return _lower; } ~Next() { ++_lower; } }; - ForwardRange(const ITR &lower, const ITR &upper) : _lower(lower), _upper(upper) {} + ForwardRange(const ForwardRange &); + ForwardRange(const ITR &lower, const ITR &upper); + ~ForwardRange(); bool has_next() const { return _lower != _upper; } }; @@ -53,7 +55,9 @@ public: explicit Next(ReverseRange &range) : _upper(range._upper) { --_upper; } const ITR &get() const { return _upper; } }; - ReverseRange(const ITR &lower, const ITR &upper) : _lower(lower), _upper(upper) {} + ReverseRange(const ReverseRange &); + ReverseRange(const ITR &lower, const ITR &upper); + ~ReverseRange(); bool has_next() const { return _lower != _upper; } }; diff --git a/searchlib/src/vespa/searchlib/attribute/diversity.hpp b/searchlib/src/vespa/searchlib/attribute/diversity.hpp new file mode 100644 index 00000000000..e857ac8eb73 --- /dev/null +++ b/searchlib/src/vespa/searchlib/attribute/diversity.hpp @@ -0,0 +1,38 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include "diversity.h" + +namespace search { +namespace attribute { +namespace diversity { + +template <typename ITR> +ForwardRange<ITR>::ForwardRange(const ForwardRange &) = default; + +template <typename ITR> +ForwardRange<ITR>::ForwardRange(const ITR &lower, const ITR &upper) + : _lower(lower), + _upper(upper) +{} + +template <typename ITR> +ForwardRange<ITR>::~ForwardRange() { } + +template <typename ITR> +ReverseRange<ITR>::ReverseRange(const ReverseRange &) = default; + +template <typename ITR> +ReverseRange<ITR>::ReverseRange(const ITR &lower, const ITR &upper) + : _lower(lower), + _upper(upper) +{} + + +template <typename ITR> +ReverseRange<ITR>::~ReverseRange() { } + +} +} +} diff --git a/searchlib/src/vespa/searchlib/attribute/integerbase.cpp b/searchlib/src/vespa/searchlib/attribute/integerbase.cpp index 34c73737825..c41600803f2 100644 --- a/searchlib/src/vespa/searchlib/attribute/integerbase.cpp +++ b/searchlib/src/vespa/searchlib/attribute/integerbase.cpp @@ -2,7 +2,6 @@ #include "integerbase.hpp" #include "attributevector.hpp" -#include <vespa/searchlib/common/sort.h> #include <vespa/document/fieldvalue/fieldvalue.h> namespace search { @@ -15,6 +14,8 @@ IntegerAttribute::IntegerAttribute(const vespalib::string & name, const Config & { } +IntegerAttribute::~IntegerAttribute() { } + uint32_t IntegerAttribute::clearDoc(DocId doc) { uint32_t removed(0); diff --git a/searchlib/src/vespa/searchlib/attribute/integerbase.h b/searchlib/src/vespa/searchlib/attribute/integerbase.h index aef139fe8a3..e5a9dbe1e48 100644 --- a/searchlib/src/vespa/searchlib/attribute/integerbase.h +++ b/searchlib/src/vespa/searchlib/attribute/integerbase.h @@ -15,6 +15,7 @@ class NumericEntryType; class IntegerAttribute : public NumericAttribute { public: + ~IntegerAttribute(); DECLARE_IDENTIFIABLE_ABSTRACT(IntegerAttribute); bool update(DocId doc, largeint_t v) { return AttributeVector::update(_changes, doc, NumericChangeData<largeint_t>(v)); diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h index 3189b452476..73429baf4a2 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h @@ -60,7 +60,7 @@ protected: } public: - virtual uint32_t getRawValues(DocId doc, const WType * & values) const { return get(doc, values); } + virtual uint32_t getRawValues(DocId doc, const WType * & values) const final; /* * Specialization of SearchContext for weighted set type */ diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp index f287be4db29..d28945b20ed 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp @@ -193,6 +193,12 @@ MultiValueNumericAttribute<B, M>::onInitSave() } template <typename B, typename M> +uint32_t +MultiValueNumericAttribute<B, M>::getRawValues(DocId doc, const WType * & values) const { + return get(doc, values); +} + +template <typename B, typename M> bool MultiValueNumericAttribute<B, M>::SetSearchContext::valid() const { return this->isValid(); } template <typename B, typename M> diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp index 6108060ed70..3d03bedab50 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp +++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp @@ -2,9 +2,10 @@ #include "postinglistsearchcontext.h" #include "postinglistsearchcontext.hpp" -#include <vespa/searchlib/btree/btreeiterator.hpp> -#include <vespa/searchlib/btree/btreenode.hpp> #include "attributeiterators.hpp" +#include "diversity.hpp" +#include <vespa/searchlib/btree/btreeiterator.hpp> + namespace search { @@ -41,7 +42,7 @@ PostingListSearchContext(const Dictionary &dictionary, } -PostingListSearchContext::~PostingListSearchContext(void) +PostingListSearchContext::~PostingListSearchContext() { } @@ -72,7 +73,7 @@ PostingListSearchContext::lookupRange(const EnumStoreComparator &low, void -PostingListSearchContext::lookupSingle(void) +PostingListSearchContext::lookupSingle() { if (_lowerDictItr.valid()) { _pidx = _lowerDictItr.getData(); diff --git a/searchlib/src/vespa/searchlib/bitcompression/compression.cpp b/searchlib/src/vespa/searchlib/bitcompression/compression.cpp index 49be44c33b0..968f3916c7e 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/compression.cpp +++ b/searchlib/src/vespa/searchlib/bitcompression/compression.cpp @@ -430,6 +430,30 @@ getParams(PostingListParams ¶ms) const params.clear(); } +template <> +void +EncodeContext64EBase<true>::writeBits(uint64_t data, uint32_t length) +{ + // While there are enough bits remaining in "data", + // fill the cacheInt and flush it to vector + if (length >= _cacheFree) { + // Shift new bits into cacheInt + _cacheInt |= ((data >> (length - _cacheFree)) & + CodingTables::_intMask64[_cacheFree]); + *_valI++ = bswap(_cacheInt); + + // Initialize variables for receiving new bits + length -= _cacheFree; + _cacheInt = 0; + _cacheFree = 64; + } + + if (length > 0) { + uint64_t dataFragment = (data & CodingTables::_intMask64[length]); + _cacheInt |= (dataFragment << (_cacheFree - length)); + _cacheFree -= length; + } +} template class FeatureDecodeContext<true>; template class FeatureDecodeContext<false>; diff --git a/searchlib/src/vespa/searchlib/bitcompression/compression.h b/searchlib/src/vespa/searchlib/bitcompression/compression.h index 08b9547f740..7975c2724f9 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/compression.h +++ b/searchlib/src/vespa/searchlib/bitcompression/compression.h @@ -892,7 +892,7 @@ public: * @param data The bits to be written to file. * @param length The number of bits to be written to file. */ - void inline + void writeBits(uint64_t data, uint32_t length); /** @@ -961,32 +961,6 @@ EncodeContext64EBase<true>::bswap(uint64_t val) template <> -inline void -EncodeContext64EBase<true>::writeBits(uint64_t data, uint32_t length) -{ - // While there are enough bits remaining in "data", - // fill the cacheInt and flush it to vector - if (length >= _cacheFree) { - // Shift new bits into cacheInt - _cacheInt |= ((data >> (length - _cacheFree)) & - CodingTables::_intMask64[_cacheFree]); - *_valI++ = bswap(_cacheInt); - - // Initialize variables for receiving new bits - length -= _cacheFree; - _cacheInt = 0; - _cacheFree = 64; - } - - if (length > 0) { - uint64_t dataFragment = (data & CodingTables::_intMask64[length]); - _cacheInt |= (dataFragment << (_cacheFree - length)); - _cacheFree -= length; - } -} - - -template <> inline uint64_t EncodeContext64EBase<false>::bswap(uint64_t val) { diff --git a/searchlib/src/vespa/searchlib/bitcompression/countcompression.h b/searchlib/src/vespa/searchlib/bitcompression/countcompression.h index 284b441aa3b..3dfb16b6250 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/countcompression.h +++ b/searchlib/src/vespa/searchlib/bitcompression/countcompression.h @@ -4,16 +4,15 @@ #pragma once -#include <limits> +#include "compression.h" #include <vespa/searchlib/index/postinglistcounts.h> +#include <limits> #define K_VALUE_COUNTFILE_POSOCCBITS 6 -namespace search -{ +namespace search { -namespace bitcompression -{ +namespace bitcompression { class PostingListCountFileDecodeContext : public FeatureDecodeContext<true> { diff --git a/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp b/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp index bef3f276b55..2fc1a1a071b 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp +++ b/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp @@ -1,28 +1,21 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> +#include "pagedict4.h" #include "compression.h" #include "countcompression.h" #include <vespa/searchlib/index/postinglistcounts.h> #include <vespa/searchlib/index/dictionaryfile.h> -#include "pagedict4.h" -#include <map> -#include <string> -#include <iostream> -#include <sstream> #include <vespa/vespalib/objects/nbostream.h> +#include <sstream> +#include <vespa/log/log.h> LOG_SETUP(".pagedict4"); -namespace search -{ +namespace search { -namespace bitcompression -{ +namespace bitcompression { -namespace -{ +namespace { void setDecoderPositionHelper(PostingListCountFileDecodeContext &ctx, diff --git a/searchlib/src/vespa/searchlib/common/fslimits.h b/searchlib/src/vespa/searchlib/common/fslimits.h index 64de5e3be37..b252e16277c 100644 --- a/searchlib/src/vespa/searchlib/common/fslimits.h +++ b/searchlib/src/vespa/searchlib/common/fslimits.h @@ -1,6 +1,4 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// Copyright (C) 1999-2003 Fast Search & Transfer ASA -// Copyright (C) 2003 Overture Services Norway AS #pragma once diff --git a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp index a12fb219b91..9bc5f473e27 100644 --- a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp @@ -37,6 +37,13 @@ DiskIndex::LookupResult::LookupResult() { } +DiskIndex::Key::Key() : _indexes() { } +DiskIndex::Key::Key(const IndexList & indexes, vespalib::stringref word) : + _word(word), + _indexes(indexes) +{ } +DiskIndex::Key::~Key() { } + DiskIndex::DiskIndex(const vespalib::string &indexDir, size_t cacheSize) : _indexDir(indexDir), _cacheSize(cacheSize), diff --git a/searchlib/src/vespa/searchlib/diskindex/diskindex.h b/searchlib/src/vespa/searchlib/diskindex/diskindex.h index c48a88970e9..552efe35c51 100644 --- a/searchlib/src/vespa/searchlib/diskindex/diskindex.h +++ b/searchlib/src/vespa/searchlib/diskindex/diskindex.h @@ -46,11 +46,9 @@ public: class Key { public: - Key() : _indexes() { } - Key(const IndexList & indexes, vespalib::stringref word) : - _word(word), - _indexes(indexes) - { } + Key(); + Key(const IndexList & indexes, vespalib::stringref word); + ~Key(); uint32_t hash() const { return vespalib::hashValue(_word.c_str(), _word.size()); } diff --git a/searchlib/src/vespa/searchlib/diskindex/fieldwriter.cpp b/searchlib/src/vespa/searchlib/diskindex/fieldwriter.cpp index 7449a946286..ac1f80be6af 100644 --- a/searchlib/src/vespa/searchlib/diskindex/fieldwriter.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/fieldwriter.cpp @@ -36,6 +36,7 @@ FieldWriter::FieldWriter(uint32_t docIdLimit, { } +FieldWriter::~FieldWriter() { } void FieldWriter::earlyOpen(const vespalib::string &prefix, diff --git a/searchlib/src/vespa/searchlib/diskindex/fieldwriter.h b/searchlib/src/vespa/searchlib/diskindex/fieldwriter.h index dfed6036405..46d5ce85383 100644 --- a/searchlib/src/vespa/searchlib/diskindex/fieldwriter.h +++ b/searchlib/src/vespa/searchlib/diskindex/fieldwriter.h @@ -1,25 +1,18 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include "bitvectorfile.h" #include <vespa/searchlib/index/dictionaryfile.h> #include <vespa/searchlib/index/postinglistfile.h> #include <vespa/searchlib/bitcompression/compression.h> #include <vespa/searchlib/bitcompression/countcompression.h> #include <vespa/searchlib/bitcompression/posocccompression.h> -#include "bitvectorfile.h" - -namespace vespalib -{ -class nbostream; +namespace vespalib { class nbostream; } -} +namespace search { -namespace search -{ - -namespace diskindex -{ +namespace diskindex { /* * FieldWriter is used to write a dictionary and posting list file @@ -39,11 +32,7 @@ private: uint64_t _wordNum; uint32_t _prevDocId; - static uint64_t - noWordNum(void) - { - return 0u; - } + static uint64_t noWordNum(void) { return 0u; } public: using DictionaryFileSeqWrite = index::DictionaryFileSeqWrite; @@ -65,22 +54,16 @@ private: uint64_t _compactWordNum; vespalib::string _word; - void - flush(void); + void flush(); public: - FieldWriter(uint32_t docIdLimit, - uint64_t numWordIds); - - void - newWord(uint64_t wordNum, const vespalib::stringref &word); + FieldWriter(uint32_t docIdLimit, uint64_t numWordIds); + ~FieldWriter(); - void - newWord(const vespalib::stringref &word); + void newWord(uint64_t wordNum, const vespalib::stringref &word); + void newWord(const vespalib::stringref &word); - void - add(const DocIdAndFeatures &features) - { + void add(const DocIdAndFeatures &features) { assert(features._docId < _docIdLimit); assert(features._docId > _prevDocId); _posoccfile->writeDocIdAndFeatures(features); @@ -88,48 +71,29 @@ public: _prevDocId = features._docId; } - uint64_t - getSparseWordNum() const - { - return _wordNum; - } + uint64_t getSparseWordNum() const { return _wordNum; } - void - earlyOpen(const vespalib::string &prefix, - uint32_t minSkipDocs, - uint32_t minChunkDocs, - bool dynamicKPosOccFormat, - const Schema &schema, - uint32_t indexId, - const TuneFileSeqWrite &tuneFileWrite); + void earlyOpen(const vespalib::string &prefix, uint32_t minSkipDocs, uint32_t minChunkDocs, + bool dynamicKPosOccFormat, const Schema &schema, uint32_t indexId, + const TuneFileSeqWrite &tuneFileWrite); - bool - lateOpen(const TuneFileSeqWrite &tuneFileWrite, - const search::common::FileHeaderContext &fileHeaderContext); + bool lateOpen(const TuneFileSeqWrite &tuneFileWrite, + const search::common::FileHeaderContext &fileHeaderContext); - bool - close(void); + bool close(); /* * To be called between words, not in the middle of one. */ - void - checkPointWrite(vespalib::nbostream &out); + void checkPointWrite(vespalib::nbostream &out); /* * To be called after earlyOpen() but before afterOpen(). */ - void - checkPointRead(vespalib::nbostream &in); - - void - setFeatureParams(const PostingListParams ¶ms); - - void - getFeatureParams(PostingListParams ¶ms); - - static void - remove(const vespalib::string &prefix); + void checkPointRead(vespalib::nbostream &in); + void setFeatureParams(const PostingListParams ¶ms); + void getFeatureParams(PostingListParams ¶ms); + static void remove(const vespalib::string &prefix); }; } // namespace diskindex diff --git a/searchlib/src/vespa/searchlib/docstore/visitcache.cpp b/searchlib/src/vespa/searchlib/docstore/visitcache.cpp index 9ef7219b661..25875d3621d 100644 --- a/searchlib/src/vespa/searchlib/docstore/visitcache.cpp +++ b/searchlib/src/vespa/searchlib/docstore/visitcache.cpp @@ -76,6 +76,9 @@ CompressedBlobSet::CompressedBlobSet() : { } +CompressedBlobSet::~CompressedBlobSet() { } + + CompressedBlobSet::CompressedBlobSet(const document::CompressionConfig &compression, const BlobSet & uncompressed) : _compression(compression.type), _positions(uncompressed.getPositions()), diff --git a/searchlib/src/vespa/searchlib/docstore/visitcache.h b/searchlib/src/vespa/searchlib/docstore/visitcache.h index 22b20f75355..fd61544ecc5 100644 --- a/searchlib/src/vespa/searchlib/docstore/visitcache.h +++ b/searchlib/src/vespa/searchlib/docstore/visitcache.h @@ -74,6 +74,7 @@ public: CompressedBlobSet & operator=(CompressedBlobSet && rhs) = default; CompressedBlobSet(const CompressedBlobSet & rhs) = default; CompressedBlobSet & operator=(const CompressedBlobSet & rhs) = default; + ~CompressedBlobSet(); size_t size() const; bool empty() const { return _positions.empty(); } BlobSet getBlobSet() const; diff --git a/searchlib/src/vespa/searchlib/engine/docsumrequest.cpp b/searchlib/src/vespa/searchlib/engine/docsumrequest.cpp index affd1655069..5678ca9af38 100644 --- a/searchlib/src/vespa/searchlib/engine/docsumrequest.cpp +++ b/searchlib/src/vespa/searchlib/engine/docsumrequest.cpp @@ -10,6 +10,8 @@ DocsumRequest::DocsumRequest() : DocsumRequest(false) { } +DocsumRequest::~DocsumRequest() {} + DocsumRequest::DocsumRequest(bool useRootSlime_) : _flags(0u), resultClassName(), diff --git a/searchlib/src/vespa/searchlib/engine/docsumrequest.h b/searchlib/src/vespa/searchlib/engine/docsumrequest.h index eb622010e03..2df9c152c56 100644 --- a/searchlib/src/vespa/searchlib/engine/docsumrequest.h +++ b/searchlib/src/vespa/searchlib/engine/docsumrequest.h @@ -81,6 +81,7 @@ public: std::vector<char> sessionId; DocsumRequest(); + ~DocsumRequest(); explicit DocsumRequest(bool useRootSlime_); bool useRootSlime() const { return _useRootSlime; } diff --git a/searchlib/src/vespa/searchlib/engine/searchreply.cpp b/searchlib/src/vespa/searchlib/engine/searchreply.cpp index a86ccf62404..ef668fdf413 100644 --- a/searchlib/src/vespa/searchlib/engine/searchreply.cpp +++ b/searchlib/src/vespa/searchlib/engine/searchreply.cpp @@ -22,6 +22,8 @@ SearchReply::SearchReply() request() { } +SearchReply::~SearchReply() {} + SearchReply::SearchReply(const SearchReply &rhs) : valid (rhs.valid), offset (rhs.offset), diff --git a/searchlib/src/vespa/searchlib/engine/searchreply.h b/searchlib/src/vespa/searchlib/engine/searchreply.h index b10fde5c9da..e259922def1 100644 --- a/searchlib/src/vespa/searchlib/engine/searchreply.h +++ b/searchlib/src/vespa/searchlib/engine/searchreply.h @@ -79,6 +79,7 @@ public: SearchRequest::UP request; SearchReply(); + ~SearchReply(); SearchReply(const SearchReply &rhs); // for test only void setDistributionKey(uint32_t key) { _distributionKey = key; } diff --git a/searchlib/src/vespa/searchlib/engine/searchrequest.cpp b/searchlib/src/vespa/searchlib/engine/searchrequest.cpp index cf9254c025a..f1a3bf8db63 100644 --- a/searchlib/src/vespa/searchlib/engine/searchrequest.cpp +++ b/searchlib/src/vespa/searchlib/engine/searchrequest.cpp @@ -13,8 +13,9 @@ SearchRequest::SearchRequest() sortSpec(), groupSpec(), sessionId() -{ -} +{ } + +SearchRequest::~SearchRequest() {} void SearchRequest::Source::lazyDecode() const { diff --git a/searchlib/src/vespa/searchlib/engine/searchrequest.h b/searchlib/src/vespa/searchlib/engine/searchrequest.h index 799f5e9ca57..5209caabcf6 100644 --- a/searchlib/src/vespa/searchlib/engine/searchrequest.h +++ b/searchlib/src/vespa/searchlib/engine/searchrequest.h @@ -72,6 +72,7 @@ public: std::vector<char> sessionId; SearchRequest(); + ~SearchRequest(); }; } // namespace engine diff --git a/searchlib/src/vespa/searchlib/engine/transport_metrics.cpp b/searchlib/src/vespa/searchlib/engine/transport_metrics.cpp index 7efbf172e4f..9f933180265 100644 --- a/searchlib/src/vespa/searchlib/engine/transport_metrics.cpp +++ b/searchlib/src/vespa/searchlib/engine/transport_metrics.cpp @@ -12,6 +12,8 @@ TransportMetrics::QueryMetrics::QueryMetrics(metrics::MetricSet *parent) { } +TransportMetrics::QueryMetrics::~QueryMetrics() { } + TransportMetrics::DocsumMetrics::DocsumMetrics(metrics::MetricSet *parent) : metrics::MetricSet("docsum", "", "Docsum metrics", parent), count("count", "logdefault", "Docsum requests handled", this), @@ -20,6 +22,8 @@ TransportMetrics::DocsumMetrics::DocsumMetrics(metrics::MetricSet *parent) { } +TransportMetrics::DocsumMetrics::~DocsumMetrics() { } + TransportMetrics::TransportMetrics() : metrics::MetricSet("transport", "", "Transport server metrics", 0), updateLock(), @@ -28,5 +32,7 @@ TransportMetrics::TransportMetrics() { } +TransportMetrics::~TransportMetrics() { } + } // namespace engine } // namespace search diff --git a/searchlib/src/vespa/searchlib/engine/transport_metrics.h b/searchlib/src/vespa/searchlib/engine/transport_metrics.h index fa62460434c..87312a0971c 100644 --- a/searchlib/src/vespa/searchlib/engine/transport_metrics.h +++ b/searchlib/src/vespa/searchlib/engine/transport_metrics.h @@ -15,6 +15,7 @@ struct TransportMetrics : metrics::MetricSet metrics::DoubleAverageMetric latency; QueryMetrics(metrics::MetricSet *parent); + ~QueryMetrics(); }; struct DocsumMetrics : metrics::MetricSet { @@ -23,6 +24,7 @@ struct TransportMetrics : metrics::MetricSet metrics::DoubleAverageMetric latency; DocsumMetrics(metrics::MetricSet *parent); + ~DocsumMetrics(); }; vespalib::Lock updateLock; @@ -30,6 +32,7 @@ struct TransportMetrics : metrics::MetricSet DocsumMetrics docsum; TransportMetrics(); + ~TransportMetrics(); }; } // namespace engine diff --git a/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp b/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp index fafd1955a80..7c1a5f2153c 100644 --- a/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp @@ -1,19 +1,16 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".features.dotproduct"); -#include <vespa/searchcommon/attribute/attributecontent.h> -#include <vespa/searchlib/fef/properties.h> - #include "dotproductfeature.h" -#include "array_parser.hpp" -#include "utils.h" #include "valuefeature.h" #include "weighted_set_parser.hpp" +#include "array_parser.hpp" +#include <vespa/searchlib/fef/properties.h> #include <vespa/searchlib/attribute/integerbase.h> #include <vespa/searchlib/attribute/floatbase.h> +#include <vespa/log/log.h> +LOG_SETUP(".features.dotproduct"); + using namespace search::attribute; using namespace search::fef; using vespalib::hwaccelrated::IAccelrated; @@ -23,6 +20,12 @@ namespace features { namespace dotproduct { namespace wset { +template <typename DimensionVType, typename DimensionHType, typename ComponentType, typename HashMapComparator> +VectorBase<DimensionVType, DimensionHType, ComponentType, HashMapComparator>::VectorBase() { } + +template <typename DimensionVType, typename DimensionHType, typename ComponentType, typename HashMapComparator> +VectorBase<DimensionVType, DimensionHType, ComponentType, HashMapComparator>::~VectorBase() { } + template <typename Vector, typename Buffer> DotProductExecutor<Vector, Buffer>::DotProductExecutor(const IAttributeVector * attribute, const Vector & vector) : FeatureExecutor(), @@ -51,6 +54,8 @@ DotProductExecutor<Vector, Buffer>::execute(uint32_t docId) outputs().set_number(0, val); } +StringVector::~StringVector() { } + } namespace array { @@ -65,6 +70,9 @@ DotProductExecutor<A>::DotProductExecutor(const A * attribute, const V & vector) } template <typename A> +DotProductExecutor<A>::~DotProductExecutor() { } + +template <typename A> size_t DotProductExecutor<A>::getAttributeValues(uint32_t docId, const AT * & values) { @@ -90,6 +98,9 @@ SparseDotProductExecutor<A>::SparseDotProductExecutor(const A * attribute, const } template <typename A> +SparseDotProductExecutor<A>::~SparseDotProductExecutor() { } + +template <typename A> size_t SparseDotProductExecutor<A>::getAttributeValues(uint32_t docId, const AT * & values) { @@ -111,6 +122,9 @@ DotProductByCopyExecutor<A>::DotProductByCopyExecutor(const A * attribute, const } template <typename A> +DotProductByCopyExecutor<A>::~DotProductByCopyExecutor() { } + +template <typename A> size_t DotProductByCopyExecutor<A>::getAttributeValues(uint32_t docId, const AT * & values) { @@ -131,6 +145,9 @@ SparseDotProductByCopyExecutor<A>::SparseDotProductByCopyExecutor(const A * attr } template <typename A> +SparseDotProductByCopyExecutor<A>::~SparseDotProductByCopyExecutor() { } + +template <typename A> size_t SparseDotProductByCopyExecutor<A>::getAttributeValues(uint32_t docId, const AT * & values) { diff --git a/searchlib/src/vespa/searchlib/features/dotproductfeature.h b/searchlib/src/vespa/searchlib/features/dotproductfeature.h index 5550f30bf2d..d374c028c82 100644 --- a/searchlib/src/vespa/searchlib/features/dotproductfeature.h +++ b/searchlib/src/vespa/searchlib/features/dotproductfeature.h @@ -7,6 +7,7 @@ #include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchlib/attribute/multivalue.h> #include <vespa/vespalib/hwaccelrated/iaccelrated.h> +#include <vespa/searchcommon/attribute/attributecontent.h> #include <vespa/vespalib/stllike/hash_map.hpp> namespace search { @@ -39,9 +40,11 @@ public: typedef std::vector<Element> Vector; typedef vespalib::hash_map<DimensionHType, ComponentType, vespalib::hash<DimensionHType>, HashMapComparator> HashMap; protected: + VectorBase(); Vector _vector; HashMap _dimMap; // dimension -> component public: + ~VectorBase(); const Vector & getVector() const { return _vector; } void syncMap() { Converter<DimensionVType, DimensionHType> conv; @@ -69,6 +72,7 @@ public: **/ class StringVector : public VectorBase<vespalib::string, const char *, feature_t, ConstCharComparator> { public: + ~StringVector(); void insert(const vespalib::stringref & label, const vespalib::stringref & value) { _vector.push_back(std::make_pair(label, util::strToNum<feature_t>(value))); } @@ -126,6 +130,7 @@ private: virtual size_t getAttributeValues(uint32_t docid, const AT * & count); public: DotProductExecutor(const A * attribute, const V & vector); + ~DotProductExecutor(); virtual void execute(uint32_t docId); }; @@ -134,6 +139,7 @@ class DotProductByCopyExecutor : public DotProductExecutor<A> { public: typedef typename DotProductExecutor<A>::V V; DotProductByCopyExecutor(const A * attribute, const V & vector); + ~DotProductByCopyExecutor(); private: typedef typename DotProductExecutor<A>::AT AT; virtual size_t getAttributeValues(uint32_t docid, const AT * & count); @@ -146,6 +152,7 @@ public: typedef std::vector<uint32_t> IV; typedef typename DotProductExecutor<A>::V V; SparseDotProductExecutor(const A * attribute, const V & vector, const IV & indexes); + ~SparseDotProductExecutor(); private: typedef typename DotProductExecutor<A>::AT AT; virtual size_t getAttributeValues(uint32_t docid, const AT * & count); @@ -160,6 +167,7 @@ public: typedef std::vector<uint32_t> IV; typedef typename DotProductExecutor<A>::V V; SparseDotProductByCopyExecutor(const A * attribute, const V & vector, const IV & indexes); + ~SparseDotProductByCopyExecutor(); private: typedef typename DotProductExecutor<A>::AT AT; virtual size_t getAttributeValues(uint32_t docid, const AT * & count); diff --git a/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp b/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp index 52e75a33fdf..39ecfe6447a 100644 --- a/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp @@ -115,8 +115,11 @@ struct VectorizedQueryTerms { weights.push_back(terms[i].weight); } } + ~VectorizedQueryTerms(); }; +VectorizedQueryTerms::~VectorizedQueryTerms() { } + //----------------------------------------------------------------------------- struct State { diff --git a/searchlib/src/vespa/searchlib/fef/CMakeLists.txt b/searchlib/src/vespa/searchlib/fef/CMakeLists.txt index 98f254f298e..971fbd542e7 100644 --- a/searchlib/src/vespa/searchlib/fef/CMakeLists.txt +++ b/searchlib/src/vespa/searchlib/fef/CMakeLists.txt @@ -10,6 +10,7 @@ vespa_add_library(searchlib_fef OBJECT featurenamebuilder.cpp featurenameparser.cpp featureoverrider.cpp + feature_resolver.cpp fef.cpp fieldinfo.cpp fieldpositionsiterator.cpp diff --git a/searchlib/src/vespa/searchlib/fef/blueprintresolver.cpp b/searchlib/src/vespa/searchlib/fef/blueprintresolver.cpp index 505d7c102ce..10718b7588a 100644 --- a/searchlib/src/vespa/searchlib/fef/blueprintresolver.cpp +++ b/searchlib/src/vespa/searchlib/fef/blueprintresolver.cpp @@ -1,15 +1,14 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".fef.blueprintresolver"); #include "blueprintresolver.h" #include "blueprintfactory.h" #include "featurenameparser.h" -#include "featurenamebuilder.h" #include <stack> #include <vespa/vespalib/util/stringfmt.h> +#include <vespa/log/log.h> +LOG_SETUP(".fef.blueprintresolver"); + namespace search { namespace fef { @@ -172,6 +171,15 @@ struct Compiler : public Blueprint::DependencyHandler { } // namespace search::fef::<unnamed> +BlueprintResolver::ExecutorSpec::ExecutorSpec(Blueprint::SP blueprint_in) + : blueprint(blueprint_in), + inputs(), + output_types() +{ } + +BlueprintResolver::ExecutorSpec::~ExecutorSpec() { } +BlueprintResolver::~BlueprintResolver() { } + BlueprintResolver::BlueprintResolver(const BlueprintFactory &factory, const IIndexEnvironment &indexEnv) : _factory(factory), diff --git a/searchlib/src/vespa/searchlib/fef/blueprintresolver.h b/searchlib/src/vespa/searchlib/fef/blueprintresolver.h index ceab7125ba8..cde3e9b940d 100644 --- a/searchlib/src/vespa/searchlib/fef/blueprintresolver.h +++ b/searchlib/src/vespa/searchlib/fef/blueprintresolver.h @@ -57,8 +57,8 @@ public: std::vector<FeatureRef> inputs; std::vector<FeatureType> output_types; - ExecutorSpec(Blueprint::SP blueprint_in) - : blueprint(blueprint_in), inputs(), output_types() {} + ExecutorSpec(Blueprint::SP blueprint_in); + ~ExecutorSpec(); }; typedef std::vector<ExecutorSpec> ExecutorSpecList; @@ -82,6 +82,7 @@ private: public: BlueprintResolver(const BlueprintResolver &) = delete; BlueprintResolver &operator=(const BlueprintResolver &) = delete; + ~BlueprintResolver(); /** * Create a new blueprint resolver within the given index diff --git a/searchlib/src/vespa/searchlib/fef/feature_resolver.cpp b/searchlib/src/vespa/searchlib/fef/feature_resolver.cpp new file mode 100644 index 00000000000..8d42e8d8174 --- /dev/null +++ b/searchlib/src/vespa/searchlib/fef/feature_resolver.cpp @@ -0,0 +1,21 @@ +// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "feature_resolver.h" + +namespace search { +namespace fef { + +FeatureResolver::FeatureResolver(size_t size_hint) + : _names(), + _features(), + _is_object() +{ + _names.reserve(size_hint); + _features.reserve(size_hint); + _is_object.reserve(size_hint); +} + +FeatureResolver::~FeatureResolver() { } + +} // namespace fef +} // namespace search diff --git a/searchlib/src/vespa/searchlib/fef/feature_resolver.h b/searchlib/src/vespa/searchlib/fef/feature_resolver.h index 0280106b133..2dd85ecaf74 100644 --- a/searchlib/src/vespa/searchlib/fef/feature_resolver.h +++ b/searchlib/src/vespa/searchlib/fef/feature_resolver.h @@ -22,11 +22,8 @@ private: std::vector<LazyValue> _features; std::vector<bool> _is_object; public: - FeatureResolver(size_t size_hint) : _names(), _features(), _is_object() { - _names.reserve(size_hint); - _features.reserve(size_hint); - _is_object.reserve(size_hint); - } + FeatureResolver(size_t size_hint); + ~FeatureResolver(); void add(const vespalib::string &name, LazyValue feature, bool is_object) { _names.push_back(name); _features.push_back(feature); diff --git a/searchlib/src/vespa/searchlib/fef/featurenameparser.cpp b/searchlib/src/vespa/searchlib/fef/featurenameparser.cpp index 2d646de5a72..fca21041f87 100644 --- a/searchlib/src/vespa/searchlib/fef/featurenameparser.cpp +++ b/searchlib/src/vespa/searchlib/fef/featurenameparser.cpp @@ -495,5 +495,8 @@ FeatureNameParser::FeatureNameParser(const string &input) } } +FeatureNameParser::~FeatureNameParser() { } + + } // namespace fef } // namespace search diff --git a/searchlib/src/vespa/searchlib/fef/featurenameparser.h b/searchlib/src/vespa/searchlib/fef/featurenameparser.h index fea86479d0b..1d40d3a0306 100644 --- a/searchlib/src/vespa/searchlib/fef/featurenameparser.h +++ b/searchlib/src/vespa/searchlib/fef/featurenameparser.h @@ -36,6 +36,7 @@ public: * @param featureName feature name **/ FeatureNameParser(const vespalib::string &featureName); + ~FeatureNameParser(); /** * Does this object represent a valid feature name? diff --git a/searchlib/src/vespa/searchlib/fef/matchdatalayout.cpp b/searchlib/src/vespa/searchlib/fef/matchdatalayout.cpp index c2a258a5210..11e6c4a40c6 100644 --- a/searchlib/src/vespa/searchlib/fef/matchdatalayout.cpp +++ b/searchlib/src/vespa/searchlib/fef/matchdatalayout.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include "matchdatalayout.h" namespace search { @@ -12,6 +11,9 @@ MatchDataLayout::MatchDataLayout() { } +MatchDataLayout::~MatchDataLayout() { } + + MatchData::UP MatchDataLayout::createMatchData() const { diff --git a/searchlib/src/vespa/searchlib/fef/matchdatalayout.h b/searchlib/src/vespa/searchlib/fef/matchdatalayout.h index 227a6611030..cb8523fadbd 100644 --- a/searchlib/src/vespa/searchlib/fef/matchdatalayout.h +++ b/searchlib/src/vespa/searchlib/fef/matchdatalayout.h @@ -23,6 +23,7 @@ public: * Create an empty object. **/ MatchDataLayout(); + ~MatchDataLayout(); /** * Allocate space for a term field match data structure. diff --git a/searchlib/src/vespa/searchlib/fef/parametervalidator.cpp b/searchlib/src/vespa/searchlib/fef/parametervalidator.cpp index 203de1ba8f0..8f6ea9db453 100644 --- a/searchlib/src/vespa/searchlib/fef/parametervalidator.cpp +++ b/searchlib/src/vespa/searchlib/fef/parametervalidator.cpp @@ -44,6 +44,8 @@ ParameterValidator::Result::Result(size_t tag) : { } +ParameterValidator::Result::~Result() { } + void ParameterValidator::validateField(ParameterType::Enum type, ParameterCollection::Enum collection, size_t i, Result & result) diff --git a/searchlib/src/vespa/searchlib/fef/parametervalidator.h b/searchlib/src/vespa/searchlib/fef/parametervalidator.h index e416ea1ecdf..94ad19ddc17 100644 --- a/searchlib/src/vespa/searchlib/fef/parametervalidator.h +++ b/searchlib/src/vespa/searchlib/fef/parametervalidator.h @@ -37,6 +37,7 @@ public: * Creates a result for the parameter description with the given tag. */ Result(size_t tag = 0); + ~Result(); Result & addParameter(const Parameter & param) { _params.push_back(param); return *this; } Result & setError(const vespalib::stringref & str) { _errorStr = str; diff --git a/searchlib/src/vespa/searchlib/fef/test/ftlib.cpp b/searchlib/src/vespa/searchlib/fef/test/ftlib.cpp index 8030d387362..17e405bef7e 100644 --- a/searchlib/src/vespa/searchlib/fef/test/ftlib.cpp +++ b/searchlib/src/vespa/searchlib/fef/test/ftlib.cpp @@ -29,6 +29,8 @@ FtQueryEnvironment::FtQueryEnvironment(search::fef::test::IndexEnvironment &env) // empty } +FtQueryEnvironment::~FtQueryEnvironment() { } + FtDumpFeatureVisitor::FtDumpFeatureVisitor() : _features() { diff --git a/searchlib/src/vespa/searchlib/fef/test/ftlib.h b/searchlib/src/vespa/searchlib/fef/test/ftlib.h index 288f70dbdd5..245d8bb4998 100644 --- a/searchlib/src/vespa/searchlib/fef/test/ftlib.h +++ b/searchlib/src/vespa/searchlib/fef/test/ftlib.h @@ -70,6 +70,7 @@ private: class FtQueryEnvironment : public search::fef::test::QueryEnvironment { public: FtQueryEnvironment(search::fef::test::IndexEnvironment &indexEnv); + ~FtQueryEnvironment(); search::fef::test::QueryEnvironmentBuilder &getBuilder() { return _builder; } search::fef::MatchDataLayout &getLayout() { return _layout; } diff --git a/searchlib/src/vespa/searchlib/fef/test/queryenvironment.cpp b/searchlib/src/vespa/searchlib/fef/test/queryenvironment.cpp index af68e2a5163..f2ce596dbea 100644 --- a/searchlib/src/vespa/searchlib/fef/test/queryenvironment.cpp +++ b/searchlib/src/vespa/searchlib/fef/test/queryenvironment.cpp @@ -1,5 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> + #include "queryenvironment.h" namespace search { @@ -15,6 +15,8 @@ QueryEnvironment::QueryEnvironment(IndexEnvironment *env) { } +QueryEnvironment::~QueryEnvironment() { } + } // namespace test } // namespace fef } // namespace search diff --git a/searchlib/src/vespa/searchlib/fef/test/queryenvironment.h b/searchlib/src/vespa/searchlib/fef/test/queryenvironment.h index acb454bbfa7..047af1152d5 100644 --- a/searchlib/src/vespa/searchlib/fef/test/queryenvironment.h +++ b/searchlib/src/vespa/searchlib/fef/test/queryenvironment.h @@ -33,6 +33,7 @@ public: * @param indexEnv The index environment of this. */ QueryEnvironment(IndexEnvironment *indexEnv = NULL); + ~QueryEnvironment(); // Inherit doc from IQueryEnvironment. virtual const Properties &getProperties() const { return _properties; } diff --git a/searchlib/src/vespa/searchlib/fef/test/queryenvironmentbuilder.cpp b/searchlib/src/vespa/searchlib/fef/test/queryenvironmentbuilder.cpp index 8291a2b7ebd..7db5110e627 100644 --- a/searchlib/src/vespa/searchlib/fef/test/queryenvironmentbuilder.cpp +++ b/searchlib/src/vespa/searchlib/fef/test/queryenvironmentbuilder.cpp @@ -14,6 +14,8 @@ QueryEnvironmentBuilder::QueryEnvironmentBuilder(QueryEnvironment &env, // empty } +QueryEnvironmentBuilder::~QueryEnvironmentBuilder() { } + SimpleTermData & QueryEnvironmentBuilder::addAllFields() { diff --git a/searchlib/src/vespa/searchlib/fef/test/queryenvironmentbuilder.h b/searchlib/src/vespa/searchlib/fef/test/queryenvironmentbuilder.h index 2842e4d8ca5..564c8deed5a 100644 --- a/searchlib/src/vespa/searchlib/fef/test/queryenvironmentbuilder.h +++ b/searchlib/src/vespa/searchlib/fef/test/queryenvironmentbuilder.h @@ -17,6 +17,7 @@ public: * @param layout The layout of match data to simultaneously update. */ QueryEnvironmentBuilder(QueryEnvironment &queryEnv, MatchDataLayout &layout); + ~QueryEnvironmentBuilder(); /** * Add a term node searching all known fields to this query diff --git a/searchlib/src/vespa/searchlib/predicate/predicate_tree_analyzer.cpp b/searchlib/src/vespa/searchlib/predicate/predicate_tree_analyzer.cpp index 543d972e88b..41d754c6649 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_tree_analyzer.cpp +++ b/searchlib/src/vespa/searchlib/predicate/predicate_tree_analyzer.cpp @@ -160,10 +160,15 @@ float PredicateTreeAnalyzer::findMinFeature(const Inspector &in) { return 0.0f; } -PredicateTreeAnalyzer::PredicateTreeAnalyzer(const Inspector &in) : _has_not(false), _negated(false) { +PredicateTreeAnalyzer::PredicateTreeAnalyzer(const Inspector &in) + : _has_not(false), + _negated(false) +{ traverseTree(in); _min_feature = static_cast<int>(std::ceil(float(findMinFeature(in)) + (_has_not? 1.0 : 0.0))); } +PredicateTreeAnalyzer::~PredicateTreeAnalyzer() { } + } // namespace predicate } // namespace search diff --git a/searchlib/src/vespa/searchlib/predicate/predicate_tree_analyzer.h b/searchlib/src/vespa/searchlib/predicate/predicate_tree_analyzer.h index 35e91db718c..123523c8d64 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_tree_analyzer.h +++ b/searchlib/src/vespa/searchlib/predicate/predicate_tree_analyzer.h @@ -32,6 +32,7 @@ class PredicateTreeAnalyzer { public: PredicateTreeAnalyzer(const vespalib::slime::Inspector &in); + ~PredicateTreeAnalyzer(); int getMinFeature() const { return _min_feature; } int getSize() const { return _size; } diff --git a/searchlib/src/vespa/searchlib/query/query.cpp b/searchlib/src/vespa/searchlib/query/query.cpp index 13723fdcd1a..2c42a47ce38 100644 --- a/searchlib/src/vespa/searchlib/query/query.cpp +++ b/searchlib/src/vespa/searchlib/query/query.cpp @@ -31,6 +31,8 @@ QueryConnector::QueryConnector(const char * opName) : { } +QueryConnector::~QueryConnector() { } + const HitList & QueryConnector::evaluateHits(HitList & hl) const { if (evaluate()) { diff --git a/searchlib/src/vespa/searchlib/query/query.h b/searchlib/src/vespa/searchlib/query/query.h index 5da46d3b4b1..401febac202 100644 --- a/searchlib/src/vespa/searchlib/query/query.h +++ b/searchlib/src/vespa/searchlib/query/query.h @@ -17,6 +17,7 @@ class QueryConnector : public QueryNode, public QueryNodeList public: DECLARE_IDENTIFIABLE_ABSTRACT_NS(search, QueryConnector); QueryConnector(const char * opName); + ~QueryConnector(); virtual const HitList & evaluateHits(HitList & hl) const; /// Will clear the results from the querytree. virtual void reset(); diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp index d27e89e6246..c9bdea68c06 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp @@ -1,11 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "blueprint.h" -#include <vespa/vespalib/objects/visit.hpp> -#include <vespa/vespalib/objects/objectdumper.h> #include "leaf_blueprints.h" #include "intermediate_blueprints.h" #include "equiv_blueprint.h" +#include <vespa/vespalib/objects/visit.hpp> +#include <vespa/vespalib/objects/objectdumper.h> #include <vespa/vespalib/util/classname.h> #include <vespa/log/log.h> @@ -61,6 +61,16 @@ Blueprint::min(const std::vector<HitEstimate> &data) return est; } +Blueprint::State::State(const FieldSpecBaseList &fields_in) + : _fields(fields_in), + _estimate(), + _tree_size(1), + _allow_termwise_eval(true) +{ +} + +Blueprint::State::~State() { } + Blueprint::Blueprint() : _parent(0), _sourceId(0xffffffff), @@ -452,6 +462,14 @@ IntermediateBlueprint::calculateUnpackInfo(const fef::MatchData & md) const //----------------------------------------------------------------------------- +LeafBlueprint::LeafBlueprint(const FieldSpecBaseList &fields, bool allow_termwise_eval) + : _state(fields) +{ + _state.allow_termwise_eval(allow_termwise_eval); +} + +LeafBlueprint::~LeafBlueprint() { } + void LeafBlueprint::fetchPostings(bool strict) { diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.h b/searchlib/src/vespa/searchlib/queryeval/blueprint.h index c1b1f1311eb..b317c9094f1 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.h @@ -62,13 +62,8 @@ public: bool _allow_termwise_eval; public: - State(const FieldSpecBaseList &fields_in) - : _fields(fields_in), - _estimate(), - _tree_size(1), - _allow_termwise_eval(true) - { - } + State(const FieldSpecBaseList &fields_in); + ~State(); void swap(State & rhs) { _fields.swap(rhs._fields); std::swap(_estimate, rhs._estimate); @@ -292,11 +287,9 @@ protected: void set_allow_termwise_eval(bool value); void set_tree_size(uint32_t value); - LeafBlueprint(const FieldSpecBaseList &fields, bool allow_termwise_eval) : _state(fields) { - _state.allow_termwise_eval(allow_termwise_eval); - } - + LeafBlueprint(const FieldSpecBaseList &fields, bool allow_termwise_eval); public: + ~LeafBlueprint(); const State &getState() const override final { return _state; } void setDocIdLimit(uint32_t limit) override final { Blueprint::setDocIdLimit(limit); } void fetchPostings(bool strict) override; diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_result.cpp b/searchlib/src/vespa/searchlib/queryeval/fake_result.cpp index 6c152376803..2fd4776749e 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_result.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/fake_result.cpp @@ -1,13 +1,13 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".fakeresult"); #include "fake_result.h" +#include <ostream> namespace search { namespace queryeval { +FakeResult::~FakeResult() { } + std::ostream &operator << (std::ostream &out, const FakeResult &result) { const std::vector<FakeResult::Document> &doc = result.inspect(); if (doc.size() == 0) { diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_result.h b/searchlib/src/vespa/searchlib/queryeval/fake_result.h index d47cbcf8763..93f833f2d9a 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_result.h +++ b/searchlib/src/vespa/searchlib/queryeval/fake_result.h @@ -47,6 +47,7 @@ private: public: FakeResult() : _documents(), _minMaxPostingInfo() {} + ~FakeResult(); FakeResult &doc(uint32_t docId) { _documents.push_back(Document(docId)); diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_searchable.cpp b/searchlib/src/vespa/searchlib/queryeval/fake_searchable.cpp index c9f088f9039..283c15fd970 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_searchable.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/fake_searchable.cpp @@ -1,16 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".searchlib.queryeval.fake_searchable"); - #include "fake_searchable.h" #include "leaf_blueprints.h" #include "termasstring.h" - #include "create_blueprint_visitor_helper.h" -#include <vespa/searchlib/fef/termfieldmatchdata.h> -#include <vespa/searchlib/queryeval/searchiterator.h> #include <vespa/vespalib/objects/visit.h> using search::query::NumberTerm; @@ -54,28 +47,12 @@ class LookupVisitor : public CreateBlueprintVisitorHelper const vespalib::string _tag; public: - LookupVisitor(Searchable &searchable, - const IRequestContext & requestContext, - const Map &map, const vespalib::string &tag, - const FieldSpec &field) - : CreateBlueprintVisitorHelper(searchable, field, requestContext), - _map(map), _tag(tag) {} + LookupVisitor(Searchable &searchable, const IRequestContext & requestContext, + const Map &map, const vespalib::string &tag, const FieldSpec &field); + ~LookupVisitor(); template <class TermNode> - void visitTerm(TermNode &n) { - const vespalib::string term_string = termAsString(n); - - FakeResult result; - typename Map::const_iterator pos = - _map.find(typename Map::key_type(getField().getName(), term_string)); - if (pos != _map.end()) { - result = pos->second; - } - FakeBlueprint *fake = new FakeBlueprint(getField(), result); - Blueprint::UP b(fake); - fake->tag(_tag).term(term_string); - setResult(std::move(b)); - } + void visitTerm(TermNode &n); virtual void visit(NumberTerm &n) { visitTerm(n); } virtual void visit(LocationTerm &n) { visitTerm(n); } @@ -88,6 +65,35 @@ public: virtual void visit(RegExpTerm &n) { visitTerm(n); } }; +template <class Map> +LookupVisitor<Map>::LookupVisitor(Searchable &searchable, const IRequestContext & requestContext, + const Map &map, const vespalib::string &tag, const FieldSpec &field) + : CreateBlueprintVisitorHelper(searchable, field, requestContext), + _map(map), + _tag(tag) +{} + +template <class Map> +LookupVisitor<Map>::~LookupVisitor() { } + +template <class Map> +template <class TermNode> +void +LookupVisitor<Map>::visitTerm(TermNode &n) { + const vespalib::string term_string = termAsString(n); + + FakeResult result; + typename Map::const_iterator pos = + _map.find(typename Map::key_type(getField().getName(), term_string)); + if (pos != _map.end()) { + result = pos->second; + } + FakeBlueprint *fake = new FakeBlueprint(getField(), result); + Blueprint::UP b(fake); + fake->tag(_tag).term(term_string); + setResult(std::move(b)); +} + } // namespace search::queryeval::<unnamed> Blueprint::UP diff --git a/searchlib/src/vespa/searchlib/queryeval/iterator_pack.cpp b/searchlib/src/vespa/searchlib/queryeval/iterator_pack.cpp index 0ed8499a48a..45778bc0cf5 100644 --- a/searchlib/src/vespa/searchlib/queryeval/iterator_pack.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/iterator_pack.cpp @@ -15,7 +15,7 @@ SearchIteratorPack::SearchIteratorPack(SearchIteratorPack &&rhs) : _children(std::move(rhs._children)), _childMatch(std::move(rhs._childMatch)), _md(std::move(rhs._md)) -{ } +{} SearchIteratorPack & SearchIteratorPack::operator=(SearchIteratorPack &&rhs) { @@ -44,7 +44,6 @@ SearchIteratorPack::SearchIteratorPack(const std::vector<SearchIterator*> &child : SearchIteratorPack(children, std::vector<fef::TermFieldMatchData*>(), MatchDataUP()) { } - std::unique_ptr<BitVector> SearchIteratorPack::get_hits(uint32_t begin_id, uint32_t end_id) const { diff --git a/searchlib/src/vespa/searchlib/queryeval/posting_info.h b/searchlib/src/vespa/searchlib/queryeval/posting_info.h index e8d463c45bc..fbdf76e9ad5 100644 --- a/searchlib/src/vespa/searchlib/queryeval/posting_info.h +++ b/searchlib/src/vespa/searchlib/queryeval/posting_info.h @@ -44,4 +44,3 @@ public: } // namespace queryeval } // namespace search - diff --git a/searchlib/src/vespa/searchlib/queryeval/termwise_blueprint_helper.cpp b/searchlib/src/vespa/searchlib/queryeval/termwise_blueprint_helper.cpp index 45d975e5e77..a6ce2c50196 100644 --- a/searchlib/src/vespa/searchlib/queryeval/termwise_blueprint_helper.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/termwise_blueprint_helper.cpp @@ -32,6 +32,8 @@ TermwiseBlueprintHelper::TermwiseBlueprintHelper(const IntermediateBlueprint &se } } +TermwiseBlueprintHelper::~TermwiseBlueprintHelper() { } + void TermwiseBlueprintHelper::insert_termwise(SearchIterator::UP search, bool strict) { diff --git a/searchlib/src/vespa/searchlib/queryeval/termwise_blueprint_helper.h b/searchlib/src/vespa/searchlib/queryeval/termwise_blueprint_helper.h index c99fedd4921..f376520151e 100644 --- a/searchlib/src/vespa/searchlib/queryeval/termwise_blueprint_helper.h +++ b/searchlib/src/vespa/searchlib/queryeval/termwise_blueprint_helper.h @@ -23,6 +23,7 @@ struct TermwiseBlueprintHelper { TermwiseBlueprintHelper(const IntermediateBlueprint &self, const MultiSearch::Children &subSearches, UnpackInfo &unpackInfo); + ~TermwiseBlueprintHelper(); void insert_termwise(SearchIterator::UP search, bool strict); }; diff --git a/searchlib/src/vespa/searchlib/queryeval/wand/wand_parts.cpp b/searchlib/src/vespa/searchlib/queryeval/wand/wand_parts.cpp index 00bb4eda04d..5da3204e2a8 100644 --- a/searchlib/src/vespa/searchlib/queryeval/wand/wand_parts.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/wand/wand_parts.cpp @@ -12,6 +12,10 @@ VectorizedIteratorTerms::visit_members(vespalib::ObjectVisitor &visitor) const { visit(visitor, "children", _terms); } +VectorizedIteratorTerms::VectorizedIteratorTerms(VectorizedIteratorTerms &&) = default; +VectorizedIteratorTerms & VectorizedIteratorTerms::operator=(VectorizedIteratorTerms &&) = default; +VectorizedIteratorTerms::~VectorizedIteratorTerms() { } + } // namespace wand } // namespace queryeval } // namespace search diff --git a/searchlib/src/vespa/searchlib/queryeval/wand/wand_parts.h b/searchlib/src/vespa/searchlib/queryeval/wand/wand_parts.h index ac75047952b..6198b13b38b 100644 --- a/searchlib/src/vespa/searchlib/queryeval/wand/wand_parts.h +++ b/searchlib/src/vespa/searchlib/queryeval/wand/wand_parts.h @@ -158,24 +158,13 @@ private: IteratorPack _iteratorPack; public: - VectorizedState() : _docId(), _weight(), _maxScore(), _iteratorPack() {} + VectorizedState(); + VectorizedState(VectorizedState &&); + VectorizedState & operator=(VectorizedState &&); + ~VectorizedState(); template <typename Scorer, typename Input> - std::vector<ref_t> init_state(const Input &input, uint32_t docIdLimit) { - std::vector<ref_t> order; - std::vector<score_t> max_scores; - order.reserve(input.size()); - max_scores.reserve(input.size()); - for (size_t i = 0; i < input.size(); ++i) { - order.push_back(i); - max_scores.push_back(Scorer::calculate_max_score(input, i)); - } - std::sort(order.begin(), order.end(), MaxSkipOrder<Input>(docIdLimit, input, max_scores)); - _docId = assemble([&input](ref_t ref){ return input.get_initial_docid(ref); }, order); - _weight = assemble([&input](ref_t ref){ return input.get_weight(ref); }, order); - _maxScore = assemble([&max_scores](ref_t ref){ return max_scores[ref]; }, order); - return order; - } + std::vector<ref_t> init_state(const Input &input, uint32_t docIdLimit); docid_t *docId() { return &(_docId[0]); } const int32_t *weight() const { return &(_weight[0]); } @@ -191,16 +180,56 @@ public: uint32_t seek(uint16_t ref, uint32_t docid) { return _iteratorPack.seek(ref, docid); } int32_t get_weight(uint16_t ref, uint32_t docid) { return _iteratorPack.get_weight(ref, docid); } - vespalib::string stringify_docid() const { - auto range = assemble(Ident(), NumericOrder(_docId.size())); - return do_stringify("state{docid}", range.begin(), range.end(), - [this](ref_t ref) - { - return vespalib::make_string("%u:%u/%u", ref, _docId[ref], _iteratorPack.get_docid(ref)); - }); - } + vespalib::string stringify_docid() const; }; +template <typename IteratorPack> +VectorizedState<IteratorPack>::VectorizedState() + : _docId(), + _weight(), + _maxScore(), + _iteratorPack() +{} +template <typename IteratorPack> +VectorizedState<IteratorPack>::~VectorizedState() { } + +template <typename IteratorPack> +VectorizedState<IteratorPack>::VectorizedState(VectorizedState &&) = default; + +template <typename IteratorPack> +VectorizedState<IteratorPack> & +VectorizedState<IteratorPack>::operator=(VectorizedState &&) = default; + +template <typename IteratorPack> +template <typename Scorer, typename Input> +std::vector<ref_t> +VectorizedState<IteratorPack>::init_state(const Input &input, uint32_t docIdLimit) { + std::vector<ref_t> order; + std::vector<score_t> max_scores; + order.reserve(input.size()); + max_scores.reserve(input.size()); + for (size_t i = 0; i < input.size(); ++i) { + order.push_back(i); + max_scores.push_back(Scorer::calculate_max_score(input, i)); + } + std::sort(order.begin(), order.end(), MaxSkipOrder<Input>(docIdLimit, input, max_scores)); + _docId = assemble([&input](ref_t ref){ return input.get_initial_docid(ref); }, order); + _weight = assemble([&input](ref_t ref){ return input.get_weight(ref); }, order); + _maxScore = assemble([&max_scores](ref_t ref){ return max_scores[ref]; }, order); + return order; +} + +template <typename IteratorPack> +vespalib::string +VectorizedState<IteratorPack>::stringify_docid() const { + auto range = assemble(Ident(), NumericOrder(_docId.size())); + return do_stringify("state{docid}", range.begin(), range.end(), + [this](ref_t ref) + { + return vespalib::make_string("%u:%u/%u", ref, _docId[ref], _iteratorPack.get_docid(ref)); + }); +} + //----------------------------------------------------------------------------- class VectorizedIteratorTerms : public VectorizedState<SearchIteratorPack> @@ -211,20 +240,28 @@ private: public: template <typename Scorer> VectorizedIteratorTerms(const Terms &t, const Scorer &, uint32_t docIdLimit, - fef::MatchData::UP childrenMatchData) - : _terms() - { - std::vector<ref_t> order = init_state<Scorer>(TermInput(t), docIdLimit); - _terms = assemble([&t](ref_t ref){ return t[ref]; }, order); - iteratorPack() = SearchIteratorPack(assemble([&t](ref_t ref){ return t[ref].search; }, order), - assemble([&t](ref_t ref){ return t[ref].matchData; }, order), - std::move(childrenMatchData)); - } + fef::MatchData::UP childrenMatchData); + VectorizedIteratorTerms(VectorizedIteratorTerms &&); + VectorizedIteratorTerms & operator=(VectorizedIteratorTerms &&); + + ~VectorizedIteratorTerms(); void unpack(uint16_t ref, uint32_t docid) { iteratorPack().unpack(ref, docid); } void visit_members(vespalib::ObjectVisitor &visitor) const; const Terms &input_terms() const { return _terms; } }; +template <typename Scorer> +VectorizedIteratorTerms::VectorizedIteratorTerms(const Terms &t, const Scorer &, uint32_t docIdLimit, + fef::MatchData::UP childrenMatchData) + : _terms() +{ + std::vector<ref_t> order = init_state<Scorer>(TermInput(t), docIdLimit); + _terms = assemble([&t](ref_t ref){ return t[ref]; }, order); + iteratorPack() = SearchIteratorPack(assemble([&t](ref_t ref){ return t[ref].search; }, order), + assemble([&t](ref_t ref){ return t[ref].matchData; }, order), + std::move(childrenMatchData)); +} + //----------------------------------------------------------------------------- struct VectorizedAttributeTerms : VectorizedState<AttributeIteratorPack> { @@ -278,28 +315,9 @@ private: size_t _size; public: - DualHeap(const DocIdOrder &futureCmp, size_t size) - : _futureCmp(futureCmp), _space(), _future(nullptr), _present(nullptr), _past(nullptr), _trash(nullptr), _size(size) - { - FutureHeap::require_left_heap(); - PastHeap::require_right_heap(); - _space.reserve(size); - init(); - } - void init() { - _space.clear(); - _future = &(_space[0]); - _present = _future; - for (size_t i = 0; i < _size; ++i) { - if (!_futureCmp.at_end(i)) { - _space.push_back(i); - FutureHeap::push(_future, ++_present, _futureCmp); - } - } - _past = _present; - _trash = _past; - assert(_future == &(_space[0])); // space has not moved - } + DualHeap(const DocIdOrder &futureCmp, size_t size); + ~DualHeap(); + void init(); bool has_future() const { return (_future != _present);} bool has_present() const { return (_present != _past);} bool has_past() const { return (_past != _trash);} @@ -320,17 +338,56 @@ public: } ref_t *present_begin() const { return _present; } ref_t *present_end() const { return _past; } - vespalib::string stringify() const { - return "Heaps: " - + do_stringify("future", _future, _present, - [this](ref_t ref){ return vespalib::make_string("%u@%u", ref, _futureCmp.get_pos(ref)); }) - + " " + do_stringify("present", _present, _past, - [this](ref_t ref){ return vespalib::make_string("%u@%u", ref, _futureCmp.get_pos(ref)); }) - + " " + do_stringify("past", _past, _trash, - [this](ref_t ref){ return vespalib::make_string("%u@%u", ref, _futureCmp.get_pos(ref)); }); - } + vespalib::string stringify() const; }; +template <typename FutureHeap, typename PastHeap> +DualHeap<FutureHeap, PastHeap>::DualHeap(const DocIdOrder &futureCmp, size_t size) + : _futureCmp(futureCmp), + _space(), + _future(nullptr), + _present(nullptr), + _past(nullptr), + _trash(nullptr), + _size(size) +{ + FutureHeap::require_left_heap(); + PastHeap::require_right_heap(); + _space.reserve(size); + init(); +} + +template <typename FutureHeap, typename PastHeap> +DualHeap<FutureHeap, PastHeap>::~DualHeap() { } + +template <typename FutureHeap, typename PastHeap> +void +DualHeap<FutureHeap, PastHeap>::init() { + _space.clear(); + _future = &(_space[0]); + _present = _future; + for (size_t i = 0; i < _size; ++i) { + if (!_futureCmp.at_end(i)) { + _space.push_back(i); + FutureHeap::push(_future, ++_present, _futureCmp); + } + } + _past = _present; + _trash = _past; + assert(_future == &(_space[0])); // space has not moved +} + +template <typename FutureHeap, typename PastHeap> +vespalib::string +DualHeap<FutureHeap, PastHeap>::stringify() const { + return "Heaps: " + + do_stringify("future", _future, _present, + [this](ref_t ref){ return vespalib::make_string("%u@%u", ref, _futureCmp.get_pos(ref)); }) + + " " + do_stringify("present", _present, _past, + [this](ref_t ref){ return vespalib::make_string("%u@%u", ref, _futureCmp.get_pos(ref)); }) + + " " + do_stringify("past", _past, _trash, + [this](ref_t ref){ return vespalib::make_string("%u@%u", ref, _futureCmp.get_pos(ref)); }); +} //----------------------------------------------------------------------------- #define TermFrequencyScorer_TERM_SCORE_FACTOR 1000000.0 diff --git a/searchlib/src/vespa/searchlib/queryeval/wand/weak_and_heap.cpp b/searchlib/src/vespa/searchlib/queryeval/wand/weak_and_heap.cpp index e8e149da476..d61019692f8 100644 --- a/searchlib/src/vespa/searchlib/queryeval/wand/weak_and_heap.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/wand/weak_and_heap.cpp @@ -1,9 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".queryeval.weak_and_heap"); + #include "weak_and_heap.h" -#include <limits> namespace search { namespace queryeval { @@ -16,6 +13,8 @@ SharedWeakAndPriorityQueue::SharedWeakAndPriorityQueue(uint32_t scoresToTrack) : _bestScores.reserve(scoresToTrack); } +SharedWeakAndPriorityQueue::~SharedWeakAndPriorityQueue() { } + void SharedWeakAndPriorityQueue::adjust(score_t *begin, score_t *end) { diff --git a/searchlib/src/vespa/searchlib/queryeval/wand/weak_and_heap.h b/searchlib/src/vespa/searchlib/queryeval/wand/weak_and_heap.h index 7208dca2dbe..a5bc894ce0d 100644 --- a/searchlib/src/vespa/searchlib/queryeval/wand/weak_and_heap.h +++ b/searchlib/src/vespa/searchlib/queryeval/wand/weak_and_heap.h @@ -58,6 +58,7 @@ private: public: SharedWeakAndPriorityQueue(uint32_t scoresToTrack); + ~SharedWeakAndPriorityQueue(); Scores &getScores() { return _bestScores; } void adjust(score_t *begin, score_t *end) override; }; diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp index 31e0c547a7a..7a395e04c09 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp @@ -32,48 +32,55 @@ private: size_t _numBoundCells; std::vector<uint32_t> _unboundDimSizes; public: - TensorReader(AttributeVector &attr) - : ReaderBase(attr), - _tensorType(vespalib::eval::ValueType::from_spec(getDatHeader().getTag(tensorTypeTag).asString())), - _numUnboundDims(0), - _numBoundCells(1), - _unboundDimSizes() - { - for (const auto & dim : _tensorType.dimensions()) { - if (dim.is_bound()) { - _numBoundCells *= dim.size; - } else { - ++_numUnboundDims; - } - } - _unboundDimSizes.resize(_numUnboundDims); - } - size_t getNumCells() { - unsigned char detect; - _datFile->ReadBuf(&detect, sizeof(detect)); - if (detect == tensorIsNotPresent) { - return 0u; - } - if (detect != tensorIsPresent) { - abort(); - } - size_t numCells = _numBoundCells; - if (_numUnboundDims != 0) { - _datFile->ReadBuf(&_unboundDimSizes[0], - _numUnboundDims * sizeof(uint32_t)); - for (auto i = 0u; i < _numUnboundDims; ++i) { - assert(_unboundDimSizes[i] != 0u); - numCells *= _unboundDimSizes[i]; - // TODO: sanity check numCells - } - } - return numCells; - } + TensorReader(AttributeVector &attr); + ~TensorReader(); + size_t getNumCells(); const vespalib::eval::ValueType &tensorType() const { return _tensorType; } const std::vector<uint32_t> &getUnboundDimSizes() const { return _unboundDimSizes; } void readTensor(void *buf, size_t len) { _datFile->ReadBuf(buf, len); } }; +TensorReader::TensorReader(AttributeVector &attr) + : ReaderBase(attr), + _tensorType(vespalib::eval::ValueType::from_spec(getDatHeader().getTag(tensorTypeTag).asString())), + _numUnboundDims(0), + _numBoundCells(1), + _unboundDimSizes() +{ + for (const auto & dim : _tensorType.dimensions()) { + if (dim.is_bound()) { + _numBoundCells *= dim.size; + } else { + ++_numUnboundDims; + } + } + _unboundDimSizes.resize(_numUnboundDims); +} +TensorReader::~TensorReader() { } + +size_t +TensorReader::getNumCells() { + unsigned char detect; + _datFile->ReadBuf(&detect, sizeof(detect)); + if (detect == tensorIsNotPresent) { + return 0u; + } + if (detect != tensorIsPresent) { + abort(); + } + size_t numCells = _numBoundCells; + if (_numUnboundDims != 0) { + _datFile->ReadBuf(&_unboundDimSizes[0], + _numUnboundDims * sizeof(uint32_t)); + for (auto i = 0u; i < _numUnboundDims; ++i) { + assert(_unboundDimSizes[i] != 0u); + numCells *= _unboundDimSizes[i]; + // TODO: sanity check numCells + } + } + return numCells; +} + } DenseTensorAttribute::DenseTensorAttribute(const vespalib::stringref &baseFileName, 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 <vespa/searchlib/diskindex/fieldreader.h> #include <vespa/searchlib/diskindex/fieldwriter.h> -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<DocWordPosFeature> 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<DocWordFeature> 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<Randomizer>::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<search::diskindex::FieldReader> &fieldReader, @@ -309,11 +262,8 @@ public: uint32_t checkPointInterval, CheckPointCallback *const checkPointCallback) const; - void - validate(const std::vector<uint32_t> &docIds) const; - - void - validate(const BitVector &bv) const; + void validate(const std::vector<uint32_t> &docIds) const; + void validate(const BitVector &bv) const; bool dump(std::shared_ptr<search::diskindex::FieldWriter> &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 <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP("docsum-pack"); #include <vespa/searchlib/util/rawbuf.h> #include <vespa/searchsummary/docsummary/urlresult.h> #include <vespa/searchsummary/docsummary/resultconfig.h> #include <vespa/searchsummary/docsummary/resultpacker.h> +#include <vespa/fastos/app.h> +#include <vespa/log/log.h> +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<DynamicDocsumWriter> writer; std::unique_ptr<ResultPacker> 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 <unnamed> TEST_FF("require that docsum can be written as slime", DocsumFixture(), Slime()) { diff --git a/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp b/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp index ded7db38fed..0fa34cf2e16 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp @@ -318,10 +318,8 @@ class SummaryFieldValueConverter : protected ConstFieldValueVisitor } public: - SummaryFieldValueConverter(bool tokenize, FieldValueConverter &subConverter) - : _str(), _tokenize(tokenize), - _structuredFieldConverter(subConverter) - {} + SummaryFieldValueConverter(bool tokenize, FieldValueConverter &subConverter); + ~SummaryFieldValueConverter(); FieldValue::UP convert(const FieldValue &input) { input.accept(*this); @@ -332,7 +330,11 @@ public: } }; - +SummaryFieldValueConverter::SummaryFieldValueConverter(bool tokenize, FieldValueConverter &subConverter) + : _str(), _tokenize(tokenize), + _structuredFieldConverter(subConverter) +{} +SummaryFieldValueConverter::~SummaryFieldValueConverter() {} using namespace vespalib::slime::convenience; diff --git a/slobrok/src/vespa/slobrok/server/visible_map.cpp b/slobrok/src/vespa/slobrok/server/visible_map.cpp index 6d9ce1b4c19..b041736a2ed 100644 --- a/slobrok/src/vespa/slobrok/server/visible_map.cpp +++ b/slobrok/src/vespa/slobrok/server/visible_map.cpp @@ -1,12 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> + +#include "visible_map.h" #include <vespa/log/log.h> LOG_SETUP(".vismap"); -#include "visible_map.h" -#include "named_service.h" - namespace slobrok { void @@ -144,7 +142,15 @@ VisibleMap::history(const vespalib::GenCnt& gen) const return retval; } +VisibleMap::MapDiff::MapDiff() {} +VisibleMap::MapDiff::~MapDiff() {} +VisibleMap::VisibleMap() + : _map(NULL), + _waitList(), + _genCnt(1) +{ +} VisibleMap::~VisibleMap() { aborted(); diff --git a/slobrok/src/vespa/slobrok/server/visible_map.h b/slobrok/src/vespa/slobrok/server/visible_map.h index d67cb9ace70..11702ddb92a 100644 --- a/slobrok/src/vespa/slobrok/server/visible_map.h +++ b/slobrok/src/vespa/slobrok/server/visible_map.h @@ -44,6 +44,8 @@ public: struct MapDiff { + MapDiff(); + ~MapDiff(); std::vector<std::string> removed; RpcSrvlist updated; }; @@ -83,12 +85,7 @@ public: MapDiff history(const vespalib::GenCnt& gen) const; - VisibleMap() - : _map(NULL), - _waitList(), - _genCnt(1) - { - } + VisibleMap(); ~VisibleMap(); }; diff --git a/staging_vespalib/src/tests/objectdump/objectdump.cpp b/staging_vespalib/src/tests/objectdump/objectdump.cpp index 421e9a4daf6..1488397911e 100644 --- a/staging_vespalib/src/tests/objectdump/objectdump.cpp +++ b/staging_vespalib/src/tests/objectdump/objectdump.cpp @@ -75,23 +75,32 @@ struct Foo : public Base std::vector<Bar> _list; std::vector<IdentifiablePtr<Base> > _list2; - Foo() : _objMember(), _objMember2(), _objPtr(0), _list(), _list2() { - _list.push_back(Bar()); - _list.push_back(Bar()); - _list.push_back(Bar()); - _list2.push_back(Bar()); - _list2.push_back(Baz()); - } - virtual Foo *clone() const { return new Foo(*this); } - - virtual void visitMembers(ObjectVisitor &v) const { - visit(v, "_objMember", _objMember); - visit(v, "_objMember2", _objMember2); - visit(v, "_objPtr", _objPtr); - visit(v, "_list", _list); - visit(v, "_list2", _list2); - } + Foo(); + ~Foo(); + Foo *clone() const override { return new Foo(*this); } + void visitMembers(ObjectVisitor &v) const override; }; + +Foo::~Foo() { } +Foo::Foo() + : _objMember(), _objMember2(), _objPtr(0), _list(), _list2() +{ + _list.push_back(Bar()); + _list.push_back(Bar()); + _list.push_back(Bar()); + _list2.push_back(Bar()); + _list2.push_back(Baz()); +} + +void +Foo::visitMembers(ObjectVisitor &v) const { + visit(v, "_objMember", _objMember); + visit(v, "_objMember2", _objMember2); + visit(v, "_objPtr", _objPtr); + visit(v, "_list", _list); + visit(v, "_list2", _list2); +} + IMPLEMENT_IDENTIFIABLE(Foo, Base); TEST_SETUP(Test); diff --git a/staging_vespalib/src/tests/programoptions/programoptions_test.cpp b/staging_vespalib/src/tests/programoptions/programoptions_test.cpp index 5dd27c1ce38..cabff89f9bb 100644 --- a/staging_vespalib/src/tests/programoptions/programoptions_test.cpp +++ b/staging_vespalib/src/tests/programoptions/programoptions_test.cpp @@ -52,40 +52,44 @@ struct MyOptions : public ProgramOptions { std::map<std::string, std::string> properties; int anotherOptionalArg; - MyOptions(int argc, const char* const* argv) - : ProgramOptions(argc, argv) - { - // Required options - addOption("uintopt u", uintOpt, "Sets an unsigned int"); - // Optional options - addOption("b bool", boolOpt, "Enables a flag"); - addOption("boolwithdef", boolWithDefOpt, true, "If set turns to false"); + MyOptions(int argc, const char *const *argv); + ~MyOptions(); +}; - addOption("intopt i", intOpt, 5, "Sets a signed int"); - addOption("floatopt", floatOpt, 4.0f, "Sets a float\nMultiline baby"); - addOption("string s", stringOpt, std::string("ballalaika"), - "Sets a string value. This is a very long description that " - "should be broken down into multiple lines in some sensible " - "way."); - addOptionHeader("Advanced options"); - addOption("p properties", properties, "Property map"); - addHiddenIdentifiers("prop"); - setArgumentTypeName("key"); - setArgumentTypeName("value", 1); +MyOptions::MyOptions(int argc, const char* const* argv) + : ProgramOptions(argc, argv) +{ + // Required options + addOption("uintopt u", uintOpt, "Sets an unsigned int"); + // Optional options + addOption("b bool", boolOpt, "Enables a flag"); + addOption("boolwithdef", boolWithDefOpt, true, "If set turns to false"); - addArgument("argString", argString, "Required string argument."); - addArgument("argInt", argInt, "Required int argument."); - addArgument("argOptionalString", argOptionalString, std::string("foo"), - "Optional string argument with a long description so we " - "can see that it will be broken correctly."); - addArgument("argSecondOptional", anotherOptionalArg, 3, - "Yet another optional argument"); + addOption("intopt i", intOpt, 5, "Sets a signed int"); + addOption("floatopt", floatOpt, 4.0f, "Sets a float\nMultiline baby"); + addOption("string s", stringOpt, std::string("ballalaika"), + "Sets a string value. This is a very long description that " + "should be broken down into multiple lines in some sensible " + "way."); + addOptionHeader("Advanced options"); + addOption("p properties", properties, "Property map"); + addHiddenIdentifiers("prop"); + setArgumentTypeName("key"); + setArgumentTypeName("value", 1); - setSyntaxMessage("A test program to see if this utility works."); - setSyntaxPageMaxLeftColumnSize(25); - } + addArgument("argString", argString, "Required string argument."); + addArgument("argInt", argInt, "Required int argument."); + addArgument("argOptionalString", argOptionalString, std::string("foo"), + "Optional string argument with a long description so we " + "can see that it will be broken correctly."); + addArgument("argSecondOptional", anotherOptionalArg, 3, + "Yet another optional argument"); -}; + setSyntaxMessage("A test program to see if this utility works."); + setSyntaxPageMaxLeftColumnSize(25); +} + +MyOptions::~MyOptions() { } void Test::testSyntaxPage() { AppOptions opts("myapp"); diff --git a/staging_vespalib/src/vespa/vespalib/net/http_server.cpp b/staging_vespalib/src/vespa/vespalib/net/http_server.cpp index 211d4f2c810..32b9caab687 100644 --- a/staging_vespalib/src/vespa/vespalib/net/http_server.cpp +++ b/staging_vespalib/src/vespa/vespalib/net/http_server.cpp @@ -51,6 +51,8 @@ HttpServer::HttpServer(int port_in) _server->SetKeepAlive(false); } +HttpServer::~HttpServer() { } + void HttpServer::start() { diff --git a/staging_vespalib/src/vespa/vespalib/net/http_server.h b/staging_vespalib/src/vespa/vespalib/net/http_server.h index a889dd9e091..2d8beb2e1ee 100644 --- a/staging_vespalib/src/vespa/vespalib/net/http_server.h +++ b/staging_vespalib/src/vespa/vespalib/net/http_server.h @@ -41,6 +41,7 @@ private: public: typedef std::unique_ptr<HttpServer> UP; HttpServer(int port_in); + ~HttpServer(); const vespalib::string &host() const { return _my_host; } JsonHandlerRepo &repo() { return _handler_repo; } void start(); diff --git a/staging_vespalib/src/vespa/vespalib/util/xmlserializable.cpp b/staging_vespalib/src/vespa/vespalib/util/xmlserializable.cpp index d7f482fdf26..58a5489647d 100644 --- a/staging_vespalib/src/vespa/vespalib/util/xmlserializable.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/xmlserializable.cpp @@ -354,6 +354,8 @@ XmlTag::XmlTag(const XmlTag& tag) { } +XmlTag::~XmlTag() {} + XmlTag::XmlTag(const std::string& name, XmlTagFlags flags) : _name(name), _attributes(), @@ -377,9 +379,9 @@ XmlAttribute::XmlAttribute(const XmlAttribute& attribute) } XmlAttribute::XmlAttribute(const std::string& name, const char * value, uint32_t flags) - : _name(name), - _value(), - _next() + : _name(name), + _value(), + _next() { vespalib::asciistream ost; if (flags & HEX) ost << vespalib::hex << "0x"; diff --git a/staging_vespalib/src/vespa/vespalib/util/xmlserializable.h b/staging_vespalib/src/vespa/vespalib/util/xmlserializable.h index 69a48596115..b688c699d76 100644 --- a/staging_vespalib/src/vespa/vespalib/util/xmlserializable.h +++ b/staging_vespalib/src/vespa/vespalib/util/xmlserializable.h @@ -57,6 +57,7 @@ class XmlTag { public: XmlTag(const XmlTag&); XmlTag(const std::string& name, XmlTagFlags = NONE); + ~XmlTag(); const std::string& getName() const { return _name; } }; diff --git a/storage/src/tests/bucketdb/bucketmanagertest.cpp b/storage/src/tests/bucketdb/bucketmanagertest.cpp index 99bc398ec84..9277429eedd 100644 --- a/storage/src/tests/bucketdb/bucketmanagertest.cpp +++ b/storage/src/tests/bucketdb/bucketmanagertest.cpp @@ -976,6 +976,9 @@ BucketManagerTest::testQueuedRepliesOnlyDispatchedWhenAllProcessingDone() const type & name() const { return _ ## name; } struct TestParams { + TestParams(); + TestParams(const TestParams &); + ~TestParams(); BUILDER_PARAM(document::BucketId, bucket); BUILDER_PARAM(document::BucketId, remappedTo); BUILDER_PARAM(api::StorageCommand::SP, documentMutation); @@ -983,6 +986,10 @@ struct TestParams { BUILDER_PARAM(std::vector<const api::MessageType*>, expectedOrdering); }; +TestParams::TestParams() { } +TestParams::TestParams(const TestParams &) = default; +TestParams::~TestParams() {} + void BucketManagerTest::doTestMutationOrdering( ConcurrentOperationFixture& fixture, diff --git a/storage/src/tests/bucketdb/lockablemaptest.cpp b/storage/src/tests/bucketdb/lockablemaptest.cpp index 6194b23c9ce..f18e0edc02a 100644 --- a/storage/src/tests/bucketdb/lockablemaptest.cpp +++ b/storage/src/tests/bucketdb/lockablemaptest.cpp @@ -204,9 +204,9 @@ namespace { mutable std::vector<std::string> log; mutable std::vector<Map::Decision> behaviour; - EntryProcessor() : count(0), log(), behaviour() {} - EntryProcessor(const std::vector<Map::Decision>& decisions) - : count(0), log(), behaviour(decisions) {} + EntryProcessor(); + EntryProcessor(const std::vector<Map::Decision>& decisions); + ~EntryProcessor(); Map::Decision operator()(uint64_t key, A& a) const { std::ostringstream ost; @@ -230,6 +230,11 @@ namespace { }; } +EntryProcessor::EntryProcessor() : count(0), log(), behaviour() {} +EntryProcessor::EntryProcessor(const std::vector<Map::Decision>& decisions) + : count(0), log(), behaviour(decisions) {} +EntryProcessor::~EntryProcessor() {} + void LockableMapTest::testIterating() { Map map; diff --git a/storage/src/tests/distributor/pendingmessagetrackertest.cpp b/storage/src/tests/distributor/pendingmessagetrackertest.cpp index f69525836be..c83fbbe143b 100644 --- a/storage/src/tests/distributor/pendingmessagetrackertest.cpp +++ b/storage/src/tests/distributor/pendingmessagetrackertest.cpp @@ -119,19 +119,8 @@ class Fixture document::TestDocMan _testDocMan; public: - Fixture() - : _compReg(), - _clock(), - _tracker(), - _testDocMan() - { - _compReg.setClock(_clock); - _clock.setAbsoluteTimeInSeconds(1); - // Have to set clock in compReg before constructing tracker, or it'll - // flip out and die on an explicit nullptr check. - _tracker = std::unique_ptr<PendingMessageTracker>( - new PendingMessageTracker(_compReg)); - } + Fixture(); + ~Fixture(); std::shared_ptr<api::PutCommand> sendPut(const RequestBuilder& builder) { assignMockedTime(builder.atTime()); @@ -224,6 +213,20 @@ private: } }; +Fixture::Fixture() + : _compReg(), + _clock(), + _tracker(), + _testDocMan() +{ + _compReg.setClock(_clock); + _clock.setAbsoluteTimeInSeconds(1); + // Have to set clock in compReg before constructing tracker, or it'll + // flip out and die on an explicit nullptr check. + _tracker = std::unique_ptr<PendingMessageTracker>( + new PendingMessageTracker(_compReg)); +} +Fixture::~Fixture() {} } diff --git a/storage/src/tests/distributor/statecheckerstest.cpp b/storage/src/tests/distributor/statecheckerstest.cpp index ef04453b27f..f09c93622de 100644 --- a/storage/src/tests/distributor/statecheckerstest.cpp +++ b/storage/src/tests/distributor/statecheckerstest.cpp @@ -217,6 +217,8 @@ struct StateCheckersTest : public CppUnit::TestFixture, uint32_t _minSplitBits {0}; bool _includeMessagePriority {false}; bool _includeSchedulingPriority {false}; + CheckerParams(); + ~CheckerParams(); CheckerParams& expect(const std::string& e) { _expect = e; @@ -335,6 +337,11 @@ struct StateCheckersTest : public CppUnit::TestFixture, CPPUNIT_TEST_SUITE_REGISTRATION(StateCheckersTest); + +StateCheckersTest::CheckerParams::CheckerParams() {} +StateCheckersTest::CheckerParams::~CheckerParams() {} + + const StateCheckersTest::PendingMessage StateCheckersTest::CheckerParams::NO_OP_BLOCKER; @@ -1729,10 +1736,9 @@ class StateCheckerRunner NodeMaintenanceStatsTracker _statsTracker; std::string _result; public: - StateCheckerRunner(StateCheckersTest& fixture) - : _fixture(fixture) - { - } + StateCheckerRunner(StateCheckersTest& fixture); + ~StateCheckerRunner(); + StateCheckerRunner& addToDb(const document::BucketId& bid, const std::string& bucketInfo) @@ -1767,6 +1773,13 @@ public: } }; +template <typename Checker> +StateCheckerRunner<Checker>::StateCheckerRunner(StateCheckersTest& fixture) + : _fixture(fixture) +{} +template <typename Checker> +StateCheckerRunner<Checker>::~StateCheckerRunner() {} + } // anon ns void diff --git a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp index 6d52dd455b9..bf7528c2242 100644 --- a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp +++ b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp @@ -683,8 +683,8 @@ public: bool _done; bool _threadDone; - MessagePusherThread(FileStorHandler& handler, Document::SP doc) - : _handler(handler), _doc(doc), _done(false), _threadDone(false) {} + MessagePusherThread(FileStorHandler& handler, Document::SP doc); + ~MessagePusherThread(); void run() { while (!_done) { @@ -702,6 +702,11 @@ public: } }; +MessagePusherThread::MessagePusherThread(FileStorHandler& handler, Document::SP doc) + : _handler(handler), _doc(doc), _done(false), _threadDone(false) +{} +MessagePusherThread::~MessagePusherThread() {} + class MessageFetchingThread : public document::Runnable { public: FileStorHandler& _handler; diff --git a/storage/src/tests/persistence/mergehandlertest.cpp b/storage/src/tests/persistence/mergehandlertest.cpp index 19fee57ad7e..87db1f09bd3 100644 --- a/storage/src/tests/persistence/mergehandlertest.cpp +++ b/storage/src/tests/persistence/mergehandlertest.cpp @@ -174,6 +174,8 @@ private: : public HandlerInvoker { public: + HandleGetBucketDiffReplyInvoker(); + ~HandleGetBucketDiffReplyInvoker(); void beforeInvoke(MergeHandlerTest&, MergeHandler&, spi::Context&); void invoke(MergeHandlerTest&, MergeHandler&, spi::Context&); std::string afterInvoke(MergeHandlerTest&, MergeHandler&); @@ -196,11 +198,8 @@ private: : public MultiPositionHandlerInvoker { public: - HandleApplyBucketDiffReplyInvoker() - : _counter(0), - _stub(), - _applyCmd() - {} + HandleApplyBucketDiffReplyInvoker(); + ~HandleApplyBucketDiffReplyInvoker(); void beforeInvoke(MergeHandlerTest&, MergeHandler&, spi::Context&); void invoke(MergeHandlerTest&, MergeHandler&, spi::Context&); std::string afterInvoke(MergeHandlerTest&, MergeHandler&); @@ -219,6 +218,16 @@ private: CPPUNIT_TEST_SUITE_REGISTRATION(MergeHandlerTest); + +MergeHandlerTest::HandleGetBucketDiffReplyInvoker::HandleGetBucketDiffReplyInvoker() {} +MergeHandlerTest::HandleGetBucketDiffReplyInvoker::~HandleGetBucketDiffReplyInvoker() {} +MergeHandlerTest::HandleApplyBucketDiffReplyInvoker::HandleApplyBucketDiffReplyInvoker() + : _counter(0), + _stub(), + _applyCmd() +{} +MergeHandlerTest::HandleApplyBucketDiffReplyInvoker::~HandleApplyBucketDiffReplyInvoker() {} + void MergeHandlerTest::setUp() { _context.reset(new spi::Context(documentapi::LoadType::DEFAULT, 0, 0)); diff --git a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp index abe14abe4c5..79dde3f839a 100644 --- a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp +++ b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp @@ -106,6 +106,8 @@ StorageBucketDBInitializer::Metrics::Metrics(framework::Component& component) component.registerMetric(*this); } +StorageBucketDBInitializer::Metrics::~Metrics() {} + StorageBucketDBInitializer::GlobalState::GlobalState() : _insertedCount(0), _infoReadCount(0), _infoSetByLoad(0), _dirsListed(0), _dirsToList(0), diff --git a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h index a0f4345a2a6..5190be426a5 100644 --- a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h +++ b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h @@ -98,6 +98,7 @@ class StorageBucketDBInitializer : public StorageLink, metrics::LongAverageMetric _initLatency; Metrics(framework::Component&); + ~Metrics(); }; struct GlobalState { vespalib::hash_map<api::StorageMessage::Id, ReadBucketList::SP> _lists; diff --git a/storage/src/vespa/storage/distributor/maintenance/node_maintenance_stats_tracker.cpp b/storage/src/vespa/storage/distributor/maintenance/node_maintenance_stats_tracker.cpp index e10151b9ba5..f107efc8d93 100644 --- a/storage/src/vespa/storage/distributor/maintenance/node_maintenance_stats_tracker.cpp +++ b/storage/src/vespa/storage/distributor/maintenance/node_maintenance_stats_tracker.cpp @@ -20,6 +20,9 @@ operator<<(std::ostream& os, const NodeMaintenanceStats& stats) return os; } +NodeMaintenanceStatsTracker::NodeMaintenanceStatsTracker() {} +NodeMaintenanceStatsTracker::~NodeMaintenanceStatsTracker() {} + } // distributor } // storage diff --git a/storage/src/vespa/storage/distributor/maintenance/node_maintenance_stats_tracker.h b/storage/src/vespa/storage/distributor/maintenance/node_maintenance_stats_tracker.h index 477118ae821..ce807d08418 100644 --- a/storage/src/vespa/storage/distributor/maintenance/node_maintenance_stats_tracker.h +++ b/storage/src/vespa/storage/distributor/maintenance/node_maintenance_stats_tracker.h @@ -30,6 +30,8 @@ class NodeMaintenanceStatsTracker std::unordered_map<uint16_t, NodeMaintenanceStats> _stats; static const NodeMaintenanceStats _emptyStats; public: + NodeMaintenanceStatsTracker(); + ~NodeMaintenanceStatsTracker(); void incMovingOut(uint16_t node) { ++_stats[node].movingOut; } diff --git a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp index af0e016a77c..d0a1e98f0c8 100644 --- a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp @@ -7,7 +7,6 @@ #include <vespa/document/fieldvalue/document.h> #include <vespa/document/select/parser.h> #include <vespa/storageapi/message/persistence.h> -#include <vespa/storage/distributor/distributormetricsset.h> #include <vespa/storageapi/message/batch.h> #include <vespa/vespalib/stllike/hash_map.hpp> @@ -38,6 +37,8 @@ TwoPhaseUpdateOperation::TwoPhaseUpdateOperation( _updateDocBucketId = idFactory.getBucketId(_updateCmd->getDocumentId()); } +TwoPhaseUpdateOperation::~TwoPhaseUpdateOperation() {} + namespace { struct IntermediateMessageSender : DistributorMessageSender { @@ -46,13 +47,10 @@ struct IntermediateMessageSender : DistributorMessageSender { DistributorMessageSender& forward; std::shared_ptr<api::StorageReply> _reply; - IntermediateMessageSender( - SentMessageMap& mm, - const std::shared_ptr<Operation>& cb, - DistributorMessageSender & fwd) - : msgMap(mm), callback(cb), forward(fwd) - { - } + IntermediateMessageSender(SentMessageMap& mm, + const std::shared_ptr<Operation>& cb, + DistributorMessageSender & fwd); + ~IntermediateMessageSender(); virtual void sendCommand(const std::shared_ptr<api::StorageCommand>& cmd) { msgMap.insert(cmd->getMsgId(), callback); @@ -76,6 +74,16 @@ struct IntermediateMessageSender : DistributorMessageSender { } }; +IntermediateMessageSender::IntermediateMessageSender(SentMessageMap& mm, + const std::shared_ptr<Operation>& cb, + DistributorMessageSender & fwd) + : msgMap(mm), + callback(cb), + forward(fwd) +{ +} +IntermediateMessageSender::~IntermediateMessageSender() { } + } const char* diff --git a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.h b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.h index 13d501592d8..361fcd03037 100644 --- a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.h +++ b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.h @@ -50,6 +50,7 @@ public: TwoPhaseUpdateOperation(DistributorComponent& manager, const std::shared_ptr<api::UpdateCommand> & msg, DistributorMetricSet& metrics); + ~TwoPhaseUpdateOperation(); void onStart(DistributorMessageSender& sender); diff --git a/storage/src/vespa/storage/distributor/statecheckers.cpp b/storage/src/vespa/storage/distributor/statecheckers.cpp index dd247eb497e..096611e03e1 100644 --- a/storage/src/vespa/storage/distributor/statecheckers.cpp +++ b/storage/src/vespa/storage/distributor/statecheckers.cpp @@ -649,6 +649,8 @@ public: } } + ~MergeNodes(); + void operator+=(const MergeNodes& other) { _reason << other._reason.str(); _problemFlags |= other._problemFlags; @@ -714,6 +716,8 @@ private: uint8_t _priority; }; +MergeNodes::~MergeNodes() {} + bool presentInIdealState(const StateChecker::Context& c, uint16_t node) { diff --git a/storage/src/vespa/storage/persistence/splitbitdetector.cpp b/storage/src/vespa/storage/persistence/splitbitdetector.cpp index 1d32a751f34..1749df09d28 100644 --- a/storage/src/vespa/storage/persistence/splitbitdetector.cpp +++ b/storage/src/vespa/storage/persistence/splitbitdetector.cpp @@ -53,18 +53,8 @@ struct BucketVisitor : public BucketProcessor::EntryProcessor { }; std::vector<DocInfo> _firstDocs; - BucketVisitor(const document::BucketIdFactory& factory) - : _factory(factory), _splitBit(58), - _splitMask(0), _refId(), _refBucket(), - _conflictId(), _conflictBucket(), - _docCount(0), _docSize(0), _firstDocs() - { - _firstDocs.reserve(keepFirstCount); - // LOG(spam, "Checking out meta entries in bucket"); - for (uint32_t i=0; i<_splitBit; ++i) { - _splitMask = (_splitMask << 1) | 1; - } - } + BucketVisitor(const document::BucketIdFactory& factory); + ~BucketVisitor(); void process(spi::DocEntry& slot) { assert(slot.getDocumentId()); @@ -106,6 +96,20 @@ struct BucketVisitor : public BucketProcessor::EntryProcessor { }; +BucketVisitor::BucketVisitor(const document::BucketIdFactory& factory) + : _factory(factory), _splitBit(58), + _splitMask(0), _refId(), _refBucket(), + _conflictId(), _conflictBucket(), + _docCount(0), _docSize(0), _firstDocs() +{ + _firstDocs.reserve(keepFirstCount); + // LOG(spam, "Checking out meta entries in bucket"); + for (uint32_t i=0; i<_splitBit; ++i) { + _splitMask = (_splitMask << 1) | 1; + } +} +BucketVisitor::~BucketVisitor() { } + bool smallerThanSizeLimit(uint32_t minCount, uint32_t minSize, diff --git a/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.cpp b/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.cpp index 8de4199f246..27261424894 100644 --- a/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.cpp +++ b/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.cpp @@ -87,6 +87,23 @@ allDistributorsDownInState(const lib::ClusterState& state) { } +ChangedBucketOwnershipHandler::Metrics::Metrics(metrics::MetricSet* owner) + : metrics::MetricSet("changedbucketownershiphandler", "", "", owner), + averageAbortProcessingTime("avg_abort_processing_time", "", "Average time spent aborting operations for changed buckets", this), + idealStateOpsAborted("ideal_state_ops_aborted", "", "Number of outdated ideal state operations aborted", this), + externalLoadOpsAborted("external_load_ops_aborted", "", "Number of outdated external load operations aborted", this) +{} +ChangedBucketOwnershipHandler::Metrics::~Metrics() { } + +ChangedBucketOwnershipHandler::OwnershipState::OwnershipState(const lib::Distribution::SP& distribution, + const lib::ClusterState::CSP& state) + : _distribution(distribution), + _state(state) +{ +} +ChangedBucketOwnershipHandler::OwnershipState::~OwnershipState() {} + + uint16_t ChangedBucketOwnershipHandler::OwnershipState::ownerOf( const document::BucketId& bucket) const diff --git a/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.h b/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.h index 1689419d436..4d94f78629b 100644 --- a/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.h +++ b/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.h @@ -58,22 +58,8 @@ public: metrics::LongCountMetric idealStateOpsAborted; metrics::LongCountMetric externalLoadOpsAborted; - Metrics(metrics::MetricSet* owner = 0) - : metrics::MetricSet("changedbucketownershiphandler", - "", "", owner), - averageAbortProcessingTime( - "avg_abort_processing_time", "", - "Average time spent aborting operations for changed " - "buckets", this), - idealStateOpsAborted( - "ideal_state_ops_aborted", "", - "Number of outdated ideal state operations aborted", - this), - externalLoadOpsAborted( - "external_load_ops_aborted", "", - "Number of outdated external load operations aborted", - this) - {} + Metrics(metrics::MetricSet* owner = 0); + ~Metrics(); }; /** @@ -92,11 +78,8 @@ public: using CSP = std::shared_ptr<const OwnershipState>; OwnershipState(const lib::Distribution::SP& distribution, - const lib::ClusterState::CSP& state) - : _distribution(distribution), - _state(state) - { - } + const lib::ClusterState::CSP& state); + ~OwnershipState(); static const uint16_t FAILED_TO_RESOLVE = 0xffff; 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<Disk> 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<diskCount; ++i) { - disks.push_back(Disk(storageState.getDiskState(i))); - } - } + Node(const lib::NodeState& dstate, const lib::NodeState& sstate, uint32_t diskCount); + ~Node(); void print(std::ostream& out, uint32_t nodeIndex) { if (distributorState.getState().oneOf("ui")) { @@ -134,6 +124,17 @@ struct Node { } }; +Node::Node(const lib::NodeState& dstate, const lib::NodeState& sstate, uint32_t diskCount) + : distributorState(dstate), + storageState(sstate), + disks() +{ + for (uint32_t i=0; i<diskCount; ++i) { + disks.push_back(Disk(storageState.getDiskState(i))); + } +} +Node::~Node() {} + struct Distribution { std::vector<Node> 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 <vespa/fastos/fastos.h> #include <vespa/document/bucket/bucketidfactory.h> #include <vespa/vespalib/util/programoptions.h> #include <vespa/vdslib/distribution/distribution.h> #include <vespa/vdslib/state/clusterstate.h> -#include <vespa/vdslib/state/nodestate.h> #include <vespa/storage/bucketdb/judyarray.h> -#include <stdio.h> #include <iomanip> #include <iostream> -#include <vespa/vespalib/util/programoptions.h> #include <vespa/config-stor-distribution.h> 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 <vespa/fastos/fastos.h> -#include <errno.h> #include <iostream> #include <sys/vfs.h> #include <vespa/vespalib/util/programoptions.h> @@ -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/storage/src/vespa/storage/visiting/visitor.cpp b/storage/src/vespa/storage/visiting/visitor.cpp index 9419f9e2034..30bf3fe9757 100644 --- a/storage/src/vespa/storage/visiting/visitor.cpp +++ b/storage/src/vespa/storage/visiting/visitor.cpp @@ -229,6 +229,8 @@ Visitor::VisitorTarget::VisitorTarget() { } +Visitor::VisitorTarget::~VisitorTarget() {} + Visitor::Visitor(StorageComponent& component) : _component(component), _visitorOptions(), diff --git a/storage/src/vespa/storage/visiting/visitor.h b/storage/src/vespa/storage/visiting/visitor.h index b4686c8f7f0..87b894a6d2c 100644 --- a/storage/src/vespa/storage/visiting/visitor.h +++ b/storage/src/vespa/storage/visiting/visitor.h @@ -272,6 +272,7 @@ private: } VisitorTarget(); + ~VisitorTarget(); }; protected: diff --git a/storage/src/vespa/storage/visiting/visitorthread.cpp b/storage/src/vespa/storage/visiting/visitorthread.cpp index 61cdfba1a11..48ff14d9dec 100644 --- a/storage/src/vespa/storage/visiting/visitorthread.cpp +++ b/storage/src/vespa/storage/visiting/visitorthread.cpp @@ -31,6 +31,8 @@ VisitorThread::Event::Event(Event&& other) { } +VisitorThread::Event::~Event() {} + VisitorThread::Event& VisitorThread::Event::operator= (Event&& other) { diff --git a/storage/src/vespa/storage/visiting/visitorthread.h b/storage/src/vespa/storage/visiting/visitorthread.h index 545ffc6421f..fdfef7b2073 100644 --- a/storage/src/vespa/storage/visiting/visitorthread.h +++ b/storage/src/vespa/storage/visiting/visitorthread.h @@ -61,6 +61,7 @@ class VisitorThread : public framework::Runnable, Event(api::VisitorId visitor, mbus::Reply::UP reply); Event(api::VisitorId visitor, const std::shared_ptr<api::StorageMessage>& msg); + ~Event(); bool empty() const noexcept { return (_type == NONE); diff --git a/storageapi/src/vespa/storageapi/message/persistence.cpp b/storageapi/src/vespa/storageapi/message/persistence.cpp index 95466138e18..6de53d9db82 100644 --- a/storageapi/src/vespa/storageapi/message/persistence.cpp +++ b/storageapi/src/vespa/storageapi/message/persistence.cpp @@ -4,7 +4,6 @@ #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/stllike/asciistream.h> - namespace storage { namespace api { @@ -19,6 +18,11 @@ IMPLEMENT_REPLY(RemoveReply) IMPLEMENT_COMMAND(RevertCommand, RevertReply) IMPLEMENT_REPLY(RevertReply) +TestAndSetCommand::TestAndSetCommand(const MessageType & messageType, const document::BucketId & id) + : BucketInfoCommand(messageType, id) +{} +TestAndSetCommand::~TestAndSetCommand() { } + PutCommand::PutCommand(const document::BucketId& id, const document::Document::SP& doc, Timestamp time) : TestAndSetCommand(MessageType::PUT, id), @@ -32,6 +36,8 @@ PutCommand::PutCommand(const document::BucketId& id, } } +PutCommand::~PutCommand() {} + StorageCommand::UP PutCommand::createCopyToForward( const document::BucketId& bucket, uint64_t timestamp) const @@ -78,6 +84,8 @@ PutReply::PutReply(const PutCommand& cmd, bool wasFoundFlag) { } +PutReply::~PutReply() {} + void PutReply::print(std::ostream& out, bool verbose, const std::string& indent) const @@ -111,6 +119,8 @@ UpdateCommand::UpdateCommand(const document::BucketId& id, } } +UpdateCommand::~UpdateCommand() {} + vespalib::string UpdateCommand::getSummary() const { vespalib::asciistream stream; @@ -161,6 +171,8 @@ UpdateReply::UpdateReply(const UpdateCommand& cmd, Timestamp oldTimestamp) { } +UpdateReply::~UpdateReply() {} + void UpdateReply::print(std::ostream& out, bool verbose, const std::string& indent) const @@ -191,6 +203,8 @@ GetCommand::GetCommand(const document::BucketId& bid, { } +GetCommand::~GetCommand() {} + StorageCommand::UP GetCommand::createCopyToForward( const document::BucketId& bucket, uint64_t timestamp) const @@ -237,6 +251,8 @@ GetReply::GetReply(const GetCommand& cmd, { } +GetReply::~GetReply() {} + void GetReply::print(std::ostream& out, bool verbose, const std::string& indent) const @@ -258,6 +274,8 @@ RemoveCommand::RemoveCommand(const document::BucketId& bid, { } +RemoveCommand::~RemoveCommand() {} + StorageCommand::UP RemoveCommand::createCopyToForward( const document::BucketId& bucket, uint64_t timestamp) const @@ -294,6 +312,8 @@ RemoveReply::RemoveReply(const RemoveCommand& cmd, Timestamp oldTimestamp) { } +RemoveReply::~RemoveReply() {} + void RemoveReply::print(std::ostream& out, bool verbose, const std::string& indent) const @@ -319,6 +339,8 @@ RevertCommand::RevertCommand(const document::BucketId& id, { } +RevertCommand::~RevertCommand() {} + void RevertCommand::print(std::ostream& out, bool verbose, const std::string& indent) const @@ -343,6 +365,8 @@ RevertReply::RevertReply(const RevertCommand& cmd) { } +RevertReply::~RevertReply() {} + void RevertReply::print(std::ostream& out, bool verbose, const std::string& indent) const diff --git a/storageapi/src/vespa/storageapi/message/persistence.h b/storageapi/src/vespa/storageapi/message/persistence.h index acccb3f9deb..d0961266cfe 100644 --- a/storageapi/src/vespa/storageapi/message/persistence.h +++ b/storageapi/src/vespa/storageapi/message/persistence.h @@ -22,8 +22,8 @@ class TestAndSetCommand : public BucketInfoCommand { TestAndSetCondition _condition; public: - TestAndSetCommand(const MessageType & messageType, const document::BucketId & id) - : BucketInfoCommand(messageType, id) {} + TestAndSetCommand(const MessageType & messageType, const document::BucketId & id); + ~TestAndSetCommand(); void setCondition(const TestAndSetCondition & condition) { _condition = condition; } const TestAndSetCondition & getCondition() const { return _condition; } @@ -47,8 +47,8 @@ class PutCommand : public TestAndSetCommand { Timestamp _updateTimestamp; public: - PutCommand(const document::BucketId&, const document::Document::SP&, - Timestamp); + PutCommand(const document::BucketId&, const document::Document::SP&, Timestamp); + ~PutCommand(); void setTimestamp(Timestamp ts) { _timestamp = ts; } @@ -94,6 +94,7 @@ class PutReply : public BucketInfoReply { public: explicit PutReply(const PutCommand& cmd, bool wasFound = true); + ~PutReply(); const document::DocumentId& getDocumentId() const { return _docId; } bool hasDocument() const { return _document.get(); } @@ -124,6 +125,7 @@ class UpdateCommand : public TestAndSetCommand { public: UpdateCommand(const document::BucketId&, const document::DocumentUpdate::SP&, Timestamp); + ~UpdateCommand(); void setTimestamp(Timestamp ts) { _timestamp = ts; } void setOldTimestamp(Timestamp ts) { _oldTimestamp = ts; } @@ -163,6 +165,7 @@ class UpdateReply : public BucketInfoReply { public: UpdateReply(const UpdateCommand& cmd, Timestamp oldTimestamp = 0); + ~UpdateReply(); void setOldTimestamp(Timestamp ts) { _oldTimestamp = ts; } @@ -205,6 +208,7 @@ class GetCommand : public BucketInfoCommand { public: GetCommand(const document::BucketId&, const document::DocumentId&, const vespalib::stringref & fieldSet, Timestamp before = MAX_TIMESTAMP); + ~GetCommand(); void setBeforeTimestamp(Timestamp ts) { _beforeTimestamp = ts; } @@ -240,6 +244,7 @@ public: GetReply(const GetCommand& cmd, const document::Document::SP& doc = document::Document::SP(), Timestamp lastModified = 0); + ~GetReply(); const document::Document::SP& getDocument() const { return _doc; } const document::DocumentId& getDocumentId() const { return _docId; } @@ -273,6 +278,7 @@ class RemoveCommand : public TestAndSetCommand { public: RemoveCommand(const document::BucketId&, const document::DocumentId& docId, Timestamp timestamp); + ~RemoveCommand(); void setTimestamp(Timestamp ts) { _timestamp = ts; } @@ -302,6 +308,7 @@ class RemoveReply : public BucketInfoReply { public: explicit RemoveReply(const RemoveCommand& cmd, Timestamp oldTimestamp = 0); + ~RemoveReply(); const document::DocumentId& getDocumentId() const { return _docId; } Timestamp getTimestamp() { return _timestamp; }; @@ -329,6 +336,7 @@ class RevertCommand : public BucketInfoCommand { public: RevertCommand(const document::BucketId& bucket, const std::vector<Timestamp>& revertTokens); + ~RevertCommand(); const std::vector<Timestamp>& getRevertTokens() const { return _tokens; } @@ -349,6 +357,7 @@ class RevertReply : public BucketInfoReply { public: explicit RevertReply(const RevertCommand& cmd); + ~RevertReply(); const std::vector<Timestamp>& getRevertTokens() const { return _tokens; } diff --git a/storageframework/src/tests/thread/tickingthreadtest.cpp b/storageframework/src/tests/thread/tickingthreadtest.cpp index 3c3c23d244f..508cadc6fbd 100644 --- a/storageframework/src/tests/thread/tickingthreadtest.cpp +++ b/storageframework/src/tests/thread/tickingthreadtest.cpp @@ -57,17 +57,8 @@ struct MyApp : public TickingThread { std::vector<Context> _context; TickingThreadPool::UP _threadPool; - MyApp(int threadCount, bool doCritOverlapTest = false) - : _critOverlapCounter(0), - _doCritOverlapTest(doCritOverlapTest), - _critOverlap(false), - _threadPool(TickingThreadPool::createDefault("testApp")) - { - for (int i=0; i<threadCount; ++i) { - _threadPool->addThread(*this); - _context.push_back(Context()); - } - } + MyApp(int threadCount, bool doCritOverlapTest = false); + ~MyApp(); void start(ThreadPool& p) { _threadPool->start(p); } @@ -123,6 +114,20 @@ struct MyApp : public TickingThread { bool hasCritOverlap() { return _critOverlap; } }; +MyApp::MyApp(int threadCount, bool doCritOverlapTest) + : _critOverlapCounter(0), + _doCritOverlapTest(doCritOverlapTest), + _critOverlap(false), + _threadPool(TickingThreadPool::createDefault("testApp")) +{ + for (int i=0; i<threadCount; ++i) { + _threadPool->addThread(*this); + _context.push_back(Context()); + } +} + +MyApp::~MyApp() { } + } void @@ -304,12 +309,8 @@ struct BroadcastApp : public TickingThread { TickingThreadPool::UP _threadPool; // Set a huge wait time by default to ensure we have to notify - BroadcastApp() - : _threadPool(TickingThreadPool::createDefault( - "testApp", MilliSecTime(300000))) - { - _threadPool->addThread(*this); - } + BroadcastApp(); + ~BroadcastApp(); void start(ThreadPool& p) { _threadPool->start(p); } @@ -343,6 +344,13 @@ struct BroadcastApp : public TickingThread { } }; +BroadcastApp::BroadcastApp() + : _threadPool(TickingThreadPool::createDefault("testApp", MilliSecTime(300000))) +{ + _threadPool->addThread(*this); +} +BroadcastApp::~BroadcastApp() {} + } diff --git a/storageframework/src/vespa/storageframework/generic/status/httpurlpath.cpp b/storageframework/src/vespa/storageframework/generic/status/httpurlpath.cpp index 645a745a310..e29c66a8865 100644 --- a/storageframework/src/vespa/storageframework/generic/status/httpurlpath.cpp +++ b/storageframework/src/vespa/storageframework/generic/status/httpurlpath.cpp @@ -24,6 +24,8 @@ HttpUrlPath::HttpUrlPath(const vespalib::string& urlpath, init(); } +HttpUrlPath::~HttpUrlPath() {} + void HttpUrlPath::init() { diff --git a/storageframework/src/vespa/storageframework/generic/status/httpurlpath.h b/storageframework/src/vespa/storageframework/generic/status/httpurlpath.h index a535edb5180..f73fdc752ed 100644 --- a/storageframework/src/vespa/storageframework/generic/status/httpurlpath.h +++ b/storageframework/src/vespa/storageframework/generic/status/httpurlpath.h @@ -26,6 +26,7 @@ class HttpUrlPath : public vespalib::Printable { public: HttpUrlPath(const vespalib::string& urlpath); HttpUrlPath(const vespalib::string& urlpath, const vespalib::string& serverSpec); + ~HttpUrlPath(); const vespalib::string& getPath() const { return _path; } const std::map<vespalib::string, vespalib::string>& getAttributes() const 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<vdstestlib::DirConfig> storConfig; std::unique_ptr<SlobrokMirror> 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/streamingvisitors/src/vespa/searchvisitor/indexenvironment.cpp b/streamingvisitors/src/vespa/searchvisitor/indexenvironment.cpp index 5e598f0f82b..2d96eddf493 100644 --- a/streamingvisitors/src/vespa/searchvisitor/indexenvironment.cpp +++ b/streamingvisitors/src/vespa/searchvisitor/indexenvironment.cpp @@ -17,6 +17,8 @@ IndexEnvironment::IndexEnvironment(const ITableManager & tableManager) : { } +IndexEnvironment::~IndexEnvironment() {} + bool IndexEnvironment::addField(const vespalib::string & name, bool isAttribute) { diff --git a/streamingvisitors/src/vespa/searchvisitor/indexenvironment.h b/streamingvisitors/src/vespa/searchvisitor/indexenvironment.h index 61a0805e0c1..d45817d0097 100644 --- a/streamingvisitors/src/vespa/searchvisitor/indexenvironment.h +++ b/streamingvisitors/src/vespa/searchvisitor/indexenvironment.h @@ -32,6 +32,7 @@ private: public: IndexEnvironment(const search::fef::ITableManager & tableManager); + ~IndexEnvironment(); // inherit documentation virtual const search::fef::Properties & getProperties() const override { return _properties; } diff --git a/streamingvisitors/src/vespa/searchvisitor/queryenvironment.cpp b/streamingvisitors/src/vespa/searchvisitor/queryenvironment.cpp index a69dd525f96..2a841de4b34 100644 --- a/streamingvisitors/src/vespa/searchvisitor/queryenvironment.cpp +++ b/streamingvisitors/src/vespa/searchvisitor/queryenvironment.cpp @@ -14,7 +14,8 @@ namespace storage { namespace { -search::fef::Location parseLocation(const string & location_str) +search::fef::Location +parseLocation(const string & location_str) { search::fef::Location fefLocation; if (location_str.empty()) { @@ -57,5 +58,7 @@ QueryEnvironment::QueryEnvironment(const string & location_str, { } +QueryEnvironment::~QueryEnvironment() {} + } // namespace storage diff --git a/streamingvisitors/src/vespa/searchvisitor/queryenvironment.h b/streamingvisitors/src/vespa/searchvisitor/queryenvironment.h index 48d0ef7645a..05ddcba92d3 100644 --- a/streamingvisitors/src/vespa/searchvisitor/queryenvironment.h +++ b/streamingvisitors/src/vespa/searchvisitor/queryenvironment.h @@ -32,6 +32,7 @@ public: const IndexEnvironment & indexEnv, const search::fef::Properties & properties, const search::IAttributeManager * attrMgr = NULL); + ~QueryEnvironment(); // inherit documentation virtual const search::fef::Properties & getProperties() const { return _properties; } diff --git a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp index fa68c046aa6..e83ec55b93f 100644 --- a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp +++ b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp @@ -105,7 +105,11 @@ SearchVisitor::SummaryGenerator::SummaryGenerator() : { } -vespalib::ConstBufferRef SearchVisitor::SummaryGenerator::fillSummary(AttributeVector::DocId lid, const HitsAggregationResult::SummaryClassType & summaryClass) +SearchVisitor::SummaryGenerator::~SummaryGenerator() { } + + +vespalib::ConstBufferRef +SearchVisitor::SummaryGenerator::fillSummary(AttributeVector::DocId lid, const HitsAggregationResult::SummaryClassType & summaryClass) { if (_docsumWriter != NULL) { _rawBuf.reset(); @@ -135,6 +139,8 @@ SearchVisitor::GroupingEntry::GroupingEntry(Grouping * grouping) : { } +SearchVisitor::GroupingEntry::~GroupingEntry() { } + void SearchVisitor::GroupingEntry::aggregate(const document::Document & doc, search::HitRank rank) { if (_count < _limit) { @@ -393,6 +399,8 @@ SearchVisitor::PositionInserter::PositionInserter(search::AttributeVector & attr { } +SearchVisitor::PositionInserter::~PositionInserter() {} + void SearchVisitor::PositionInserter::onPrimitive(const IteratorContent & c) { @@ -458,6 +466,8 @@ SearchVisitor::RankController::RankController() : { } +SearchVisitor::RankController::~RankController() {} + void SearchVisitor::RankController::setupRankProcessors(search::Query & query, const vespalib::string & location, diff --git a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h index 101fd91c5af..e8de5f85e5a 100644 --- a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h +++ b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h @@ -101,6 +101,7 @@ private: class PositionInserter : public AttributeInserter { public: PositionInserter(search::AttributeVector & attribute, search::AttributeVector::DocId docId); + ~PositionInserter(); private: virtual void onPrimitive(const IteratorContent & c); virtual void onStructStart(const Content & fv); @@ -133,6 +134,7 @@ private: public: RankController(); + ~RankController(); bool valid() const { return _rankProcessor.get() != NULL; } void setRankProfile(const vespalib::string &rankProfile) { _rankProfile = rankProfile; } const vespalib::string &getRankProfile() const { return _rankProfile; } @@ -368,6 +370,7 @@ private: class GroupingEntry : std::shared_ptr<Grouping> { public: GroupingEntry(Grouping * grouping); + ~GroupingEntry(); void aggregate(const document::Document & doc, search::HitRank rank); const Grouping & operator * () const { return *_grouping; } Grouping & operator * () { return *_grouping; } @@ -384,6 +387,7 @@ private: { public: SummaryGenerator(); + ~SummaryGenerator(); GetDocsumsState & getDocsumState() { return _docsumState; } vsm::GetDocsumsStateCallback & getDocsumCallback() { return _callback; } void setFilter(std::unique_ptr<vsm::DocsumFilter> filter) { _docsumFilter = std::move(filter); } diff --git a/vdslib/src/tests/distribution/distributiontest.cpp b/vdslib/src/tests/distribution/distributiontest.cpp index 8886d06ca69..41e06d1941e 100644 --- a/vdslib/src/tests/distribution/distributiontest.cpp +++ b/vdslib/src/tests/distribution/distributiontest.cpp @@ -318,15 +318,8 @@ namespace { const char* _upStates; uint16_t _redundancy; - Test() - : _nodeType(&NodeType::STORAGE), - _state("distributor:10 storage:10"), - _distribution(new Distribution(Distribution::getDefaultDistributionConfig(3, 10))), - _bucketsToTest(100), - _upStates("uir"), - _redundancy(2) - { - } + Test(); + ~Test(); Test& state(const std::string& s) { _state = s; @@ -389,6 +382,16 @@ namespace { } }; + Test::Test() + : _nodeType(&NodeType::STORAGE), + _state("distributor:10 storage:10"), + _distribution(new Distribution(Distribution::getDefaultDistributionConfig(3, 10))), + _bucketsToTest(100), + _upStates("uir"), + _redundancy(2) + { } + Test::~Test() { } + std::vector<uint16_t> createNodeCountList(const std::string& source, std::vector<uint16_t>& vals) { std::vector<uint16_t> result(vals.size(), 0); diff --git a/vdslib/src/vespa/vdslib/container/documentsummary.cpp b/vdslib/src/vespa/vdslib/container/documentsummary.cpp index 3c0ff157fc3..fcb687179f0 100644 --- a/vdslib/src/vespa/vdslib/container/documentsummary.cpp +++ b/vdslib/src/vespa/vdslib/container/documentsummary.cpp @@ -20,6 +20,8 @@ DocumentSummary::DocumentSummary(document::ByteBuffer& buf) : deserialize(buf); } +DocumentSummary::~DocumentSummary() {} + void DocumentSummary::deserialize(document::ByteBuffer& buf) { int32_t tmp; diff --git a/vdslib/src/vespa/vdslib/container/documentsummary.h b/vdslib/src/vespa/vdslib/container/documentsummary.h index 2b97a90ae1d..a14082d1ca6 100644 --- a/vdslib/src/vespa/vdslib/container/documentsummary.h +++ b/vdslib/src/vespa/vdslib/container/documentsummary.h @@ -10,6 +10,8 @@ namespace vdslib { class DocumentSummary { public: DocumentSummary(); + ~DocumentSummary(); + /** * Constructs a new message from a byte buffer. diff --git a/vdslib/src/vespa/vdslib/container/searchresult.cpp b/vdslib/src/vespa/vdslib/container/searchresult.cpp index a6c71c3d9e3..7a627a34095 100644 --- a/vdslib/src/vespa/vdslib/container/searchresult.cpp +++ b/vdslib/src/vespa/vdslib/container/searchresult.cpp @@ -50,7 +50,9 @@ BlobContainer::BlobContainer(size_t reserve) : _offsets.push_back(0); } -size_t BlobContainer::BlobContainer::append(const void * v, size_t sz) +BlobContainer::~BlobContainer() {} + +size_t BlobContainer::append(const void * v, size_t sz) { const size_t index(getCount()); _offsets.push_back(_offsets.back() + sz); @@ -113,6 +115,8 @@ SearchResult::SearchResult(document::ByteBuffer & buf) : deserialize(buf); } +SearchResult::~SearchResult() {} + void SearchResult::deserialize(document::ByteBuffer & buf) { int32_t tmp; diff --git a/vdslib/src/vespa/vdslib/container/searchresult.h b/vdslib/src/vespa/vdslib/container/searchresult.h index 7d19c97122a..9cdb85b3c89 100644 --- a/vdslib/src/vespa/vdslib/container/searchresult.h +++ b/vdslib/src/vespa/vdslib/container/searchresult.h @@ -23,6 +23,7 @@ class BlobContainer { public: BlobContainer(size_t reserve=4096); + ~BlobContainer(); size_t append(const void * v, size_t sz); void getBlob(size_t index, const void * & blob, size_t & sz) const; size_t getCount() const { return _offsets.size() - 1; } @@ -50,6 +51,7 @@ public: * @param buf A byte buffer that contains a serialized message. */ SearchResult(document::ByteBuffer & buf); + ~SearchResult(); AggregatorList & getGroupingList() { return _groupingList; } const AggregatorList & getGroupingList() const { return _groupingList; } diff --git a/vdslib/src/vespa/vdslib/state/nodestate.cpp b/vdslib/src/vespa/vdslib/state/nodestate.cpp index 53be2a8da1d..d4fdfb35993 100644 --- a/vdslib/src/vespa/vdslib/state/nodestate.cpp +++ b/vdslib/src/vespa/vdslib/state/nodestate.cpp @@ -17,6 +17,12 @@ LOG_SETUP(".vdslib.nodestate"); namespace storage { namespace lib { +NodeState::NodeState(const NodeState &) = default; +NodeState & NodeState::operator = (const NodeState &) = default; +NodeState::NodeState(NodeState &&) = default; +NodeState & NodeState::operator = (NodeState &&) = default; +NodeState::~NodeState() { } + NodeState::NodeState() : _type(0), _state(0), diff --git a/vdslib/src/vespa/vdslib/state/nodestate.h b/vdslib/src/vespa/vdslib/state/nodestate.h index e9b7de56851..275e8d5658c 100644 --- a/vdslib/src/vespa/vdslib/state/nodestate.h +++ b/vdslib/src/vespa/vdslib/state/nodestate.h @@ -43,12 +43,16 @@ public: static double getListingBucketsInitProgressLimit() { return 0.01; } NodeState(); + NodeState(const NodeState &); + NodeState & operator = (const NodeState &); + NodeState(NodeState &&); + NodeState & operator = (NodeState &&); NodeState(const NodeType& nodeType, const State&, const vespalib::stringref & description = "", double capacity = 1.0, uint16_t reliability = 1); /** Set type if you want to verify that content fit with the given type. */ NodeState(const vespalib::stringref & serialized, const NodeType* nodeType = 0); - virtual ~NodeState() {} + ~NodeState(); /** * Setting prefix to something implies using this function to write a 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/vespalib/src/tests/delegatelist/delegatelist.cpp b/vespalib/src/tests/delegatelist/delegatelist.cpp index 2efb08e22df..475d4e24551 100644 --- a/vespalib/src/tests/delegatelist/delegatelist.cpp +++ b/vespalib/src/tests/delegatelist/delegatelist.cpp @@ -213,17 +213,21 @@ private: void doneOp(const Command &cmd); int perform(int cnt, int start, const CmdList &cmdList); public: - Actor(int id, History *hist) - : _id(id), _hist(hist), _queue(), _cond(), _state(STATE_INIT), - _waitCnt(0), _opCnt(0), _exit(false) {} + Actor(int id, History *hist); + ~Actor(); int getOpCnt() const { return _opCnt; } int getState() const { return _state; } void doIt(const CmdList &cmdList); void doIt(const Command &cmd); void waitState(int state); - void Run(FastOS_ThreadInterface *, void *); + void Run(FastOS_ThreadInterface *, void *) override; }; +Actor::Actor(int id, History *hist) + : _id(id), _hist(hist), _queue(), _cond(), _state(STATE_INIT), + _waitCnt(0), _opCnt(0), _exit(false) +{} +Actor::~Actor() {} void Actor::setState(int state, MonitorGuard &guard) { diff --git a/vespalib/src/tests/dotproduct/dotproductbenchmark.cpp b/vespalib/src/tests/dotproduct/dotproductbenchmark.cpp index 9ef3d959f3b..b04aa802098 100644 --- a/vespalib/src/tests/dotproduct/dotproductbenchmark.cpp +++ b/vespalib/src/tests/dotproduct/dotproductbenchmark.cpp @@ -28,20 +28,8 @@ template <typename T> class FullBenchmark : public Benchmark { public: - FullBenchmark(size_t numDocs, size_t numValues) : - _values(numDocs*numValues), - _query(numValues), - _dp(IAccelrated::getAccelrator()) - { - for (size_t i(0); i < numDocs; i++) { - for (size_t j(0); j < numValues; j++) { - _values[i*numValues + j] = j; - } - } - for (size_t j(0); j < numValues; j++) { - _query[j] = j; - } - } + FullBenchmark(size_t numDocs, size_t numValue); + ~FullBenchmark(); virtual void compute(size_t docId) const { _dp->dotProduct(&_query[0], &_values[docId * _query.size()], _query.size()); } @@ -51,20 +39,30 @@ private: IAccelrated::UP _dp; }; -class SparseBenchmark : public Benchmark +template <typename T> +FullBenchmark<T>::FullBenchmark(size_t numDocs, size_t numValues) + : _values(numDocs*numValues), + _query(numValues), + _dp(IAccelrated::getAccelrator()) { -public: - SparseBenchmark(size_t numDocs, size_t numValues, size_t numQueryValues) : - _numValues(numValues), - _values(numDocs*numValues) - { - for (size_t i(0); i < numDocs; i++) { - for (size_t j(0); j < numValues; j++) { - size_t k(numValues < numQueryValues ? (j*numQueryValues)/numValues : j); - _values[i*numValues + j] = P(k, k); - } + for (size_t i(0); i < numDocs; i++) { + for (size_t j(0); j < numValues; j++) { + _values[i*numValues + j] = j; } } + for (size_t j(0); j < numValues; j++) { + _query[j] = j; + } +} + +template <typename T> +FullBenchmark<T>::~FullBenchmark() { } + +class SparseBenchmark : public Benchmark +{ +public: + SparseBenchmark(size_t numDocs, size_t numValues, size_t numQueryValues); + ~SparseBenchmark(); protected: struct P { P(uint32_t key=0, int32_t value=0) : @@ -78,18 +76,26 @@ protected: std::vector<P> _values; }; +SparseBenchmark::SparseBenchmark(size_t numDocs, size_t numValues, size_t numQueryValues) + : _numValues(numValues), + _values(numDocs*numValues) +{ + for (size_t i(0); i < numDocs; i++) { + for (size_t j(0); j < numValues; j++) { + size_t k(numValues < numQueryValues ? (j*numQueryValues)/numValues : j); + _values[i*numValues + j] = P(k, k); + } + } +} +SparseBenchmark::~SparseBenchmark() { } + class UnorderedSparseBenchmark : public SparseBenchmark { private: typedef hash_map<uint32_t, int32_t> map; public: - UnorderedSparseBenchmark(size_t numDocs, size_t numValues, size_t numQueryValues) : - SparseBenchmark(numDocs, numValues, numQueryValues) - { - for (size_t j(0); j < numQueryValues; j++) { - _query[j] = j; - } - } + UnorderedSparseBenchmark(size_t numDocs, size_t numValues, size_t numQueryValues); + ~UnorderedSparseBenchmark(); private: virtual void compute(size_t docId) const { int64_t sum(0); @@ -105,19 +111,21 @@ private: map _query; }; +UnorderedSparseBenchmark::UnorderedSparseBenchmark(size_t numDocs, size_t numValues, size_t numQueryValues) + : SparseBenchmark(numDocs, numValues, numQueryValues) +{ + for (size_t j(0); j < numQueryValues; j++) { + _query[j] = j; + } +} +UnorderedSparseBenchmark::~UnorderedSparseBenchmark() {} + class OrderedSparseBenchmark : public SparseBenchmark { private: public: - OrderedSparseBenchmark(size_t numDocs, size_t numValues, size_t numQueryValues) : - SparseBenchmark(numDocs, numValues, numQueryValues), - _query(numQueryValues) - { - for (size_t j(0); j < numQueryValues; j++) { - size_t k(numValues > numQueryValues ? j*numValues/numQueryValues : j); - _query[j] = P(k, k); - } - } + OrderedSparseBenchmark(size_t numDocs, size_t numValues, size_t numQueryValues); + ~OrderedSparseBenchmark(); private: virtual void compute(size_t docId) const { int64_t sum(0); @@ -133,6 +141,17 @@ private: std::vector<P> _query; }; +OrderedSparseBenchmark::OrderedSparseBenchmark(size_t numDocs, size_t numValues, size_t numQueryValues) + : SparseBenchmark(numDocs, numValues, numQueryValues), + _query(numQueryValues) +{ + for (size_t j(0); j < numQueryValues; j++) { + size_t k(numValues > numQueryValues ? j*numValues/numQueryValues : j); + _query[j] = P(k, k); + } +} +OrderedSparseBenchmark::~OrderedSparseBenchmark() { } + int main(int argc, char *argv[]) { size_t numDocs(1); diff --git a/vespalib/src/tests/dual_merge_director/dual_merge_director_test.cpp b/vespalib/src/tests/dual_merge_director/dual_merge_director_test.cpp index 72fd17e76d5..b6621a75b84 100644 --- a/vespalib/src/tests/dual_merge_director/dual_merge_director_test.cpp +++ b/vespalib/src/tests/dual_merge_director/dual_merge_director_test.cpp @@ -10,16 +10,8 @@ struct MySource : public DualMergeDirector::Source { std::string data; std::string diff; - MySource(bool a, size_t num_sources, size_t source_id) - : typeA(a), - data(num_sources, '0'), - diff(num_sources, '5') - { - if (source_id < num_sources) { - data[source_id] = '1'; - diff[source_id] = '6'; - } - } + MySource(bool a, size_t num_sources, size_t source_id); + ~MySource(); virtual void merge(Source &mt) { MySource &rhs = static_cast<MySource&>(mt); ASSERT_EQUAL(typeA, rhs.typeA); @@ -40,6 +32,18 @@ struct MySource : public DualMergeDirector::Source { } }; +MySource::MySource(bool a, size_t num_sources, size_t source_id) + : typeA(a), + data(num_sources, '0'), + diff(num_sources, '5') +{ + if (source_id < num_sources) { + data[source_id] = '1'; + diff[source_id] = '6'; + } +} +MySource::~MySource() {} + TEST_MT_F("require that merging works", 64, std::unique_ptr<DualMergeDirector>()) { for (size_t use_threads = 1; use_threads <= num_threads; ++use_threads) { MySource sourceA(true, use_threads, thread_id); diff --git a/vespalib/src/tests/left_right_heap/left_right_heap_bench.cpp b/vespalib/src/tests/left_right_heap/left_right_heap_bench.cpp index 114786bf2eb..5699adfb760 100644 --- a/vespalib/src/tests/left_right_heap/left_right_heap_bench.cpp +++ b/vespalib/src/tests/left_right_heap/left_right_heap_bench.cpp @@ -74,26 +74,32 @@ struct Data32p { size_t size; std::vector<uint32_t> values; std::vector<uint16_t> data; - Data32p(size_t s) : cmp(0), size(s), values(), data() {} + Data32p(size_t s); + ~Data32p(); static const char *name() { return "uint32_t[uint16_t]"; } - void init(bool inv) { - values.resize(size); - data.resize(size); - srandom(42); - for (size_t i = 0; i < size; ++i) { - if (inv) { - values[size - i - 1] = random(); - data[size - i - 1] = (size - i - 1); - } else { - values[i] = random(); - data[i] = i; - } + void init(bool inv); +}; + +Data32p::Data32p(size_t s) : cmp(0), size(s), values(), data() {} +Data32p::~Data32p() {} +void +Data32p::init(bool inv) { + values.resize(size); + data.resize(size); + srandom(42); + for (size_t i = 0; i < size; ++i) { + if (inv) { + values[size - i - 1] = random(); + data[size - i - 1] = (size - i - 1); + } else { + values[i] = random(); + data[i] = i; } - ASSERT_EQUAL(size, values.size()); - ASSERT_EQUAL(size, data.size()); - cmp = MyCmp(&values[0]); } -}; + ASSERT_EQUAL(size, values.size()); + ASSERT_EQUAL(size, data.size()); + cmp = MyCmp(&values[0]); +} template <typename T, typename C> bool verifyOrder(T *begin, T *end, const C &cmp, bool inv) { diff --git a/vespalib/src/tests/slime/slime_inject_test.cpp b/vespalib/src/tests/slime/slime_inject_test.cpp index 6c98568e0ed..41da9fb1a73 100644 --- a/vespalib/src/tests/slime/slime_inject_test.cpp +++ b/vespalib/src/tests/slime/slime_inject_test.cpp @@ -43,8 +43,13 @@ struct DstFixture { Slime slime7; Slime slime8; Slime slime9; + DstFixture(); + ~DstFixture(); }; +DstFixture::DstFixture() { } +DstFixture::~DstFixture() { } + TEST_FF("inject into slime", SrcFixture(), DstFixture()) { EXPECT_TRUE(f1.empty.get().valid()); // explicit nix diff --git a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp index 5fd5d3be3e9..d86ffa243fc 100644 --- a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp +++ b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp @@ -10,6 +10,7 @@ struct MyBuffer : public Output { std::vector<char> data; size_t used; MyBuffer() : data(1024 * 1024), used(0) {} + ~MyBuffer(); WritableMemory reserve(size_t bytes) override { assert(data.size() >= (used + bytes)); return WritableMemory(&data[used], data.size() - used); @@ -20,6 +21,8 @@ struct MyBuffer : public Output { } }; +MyBuffer::~MyBuffer() { } + std::string make_name(size_t idx) { return make_string("summary_feature_%zu", idx); } diff --git a/vespalib/src/tests/websocket/websocket_test.cpp b/vespalib/src/tests/websocket/websocket_test.cpp index c756cb3d22d..962a78c5606 100644 --- a/vespalib/src/tests/websocket/websocket_test.cpp +++ b/vespalib/src/tests/websocket/websocket_test.cpp @@ -17,12 +17,16 @@ template <typename T> struct Receptor : vespalib::ws::Handler<T> { std::unique_ptr<T> obj; vespalib::Gate gate; + ~Receptor(); void handle(std::unique_ptr<T> t) override { obj = std::move(t); gate.countDown(); } }; +template <typename T> +Receptor<T>::~Receptor() { } + vespalib::string read_bytes(Socket &socket, size_t wanted_bytes) { char tmp[64]; vespalib::string result; diff --git a/vespalib/src/vespa/vespalib/component/versionspecification.cpp b/vespalib/src/vespa/vespalib/component/versionspecification.cpp index e54550a7fc8..71137835187 100644 --- a/vespalib/src/vespa/vespalib/component/versionspecification.cpp +++ b/vespalib/src/vespa/vespalib/component/versionspecification.cpp @@ -20,6 +20,8 @@ VersionSpecification::VersionSpecification(int major, int minor, int micro, cons initialize(); } +VersionSpecification::VersionSpecification(const VersionSpecification &) = default; + VersionSpecification::~VersionSpecification() { } void diff --git a/vespalib/src/vespa/vespalib/component/versionspecification.h b/vespalib/src/vespa/vespalib/component/versionspecification.h index 547b140c701..a0052b46b4f 100644 --- a/vespalib/src/vespa/vespalib/component/versionspecification.h +++ b/vespalib/src/vespa/vespalib/component/versionspecification.h @@ -67,6 +67,7 @@ public: VersionSpecification(int major = UNSPECIFIED, int minor = UNSPECIFIED, int micro = UNSPECIFIED, const string & qualifier = ""); + VersionSpecification(const VersionSpecification &); ~VersionSpecification(); /** diff --git a/vespalib/src/vespa/vespalib/data/simple_buffer.cpp b/vespalib/src/vespa/vespalib/data/simple_buffer.cpp index a9bf80ac845..5e0f0a5f8e0 100644 --- a/vespalib/src/vespa/vespalib/data/simple_buffer.cpp +++ b/vespalib/src/vespa/vespalib/data/simple_buffer.cpp @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include "simple_buffer.h" +#include <cassert> namespace vespalib { @@ -11,6 +11,8 @@ SimpleBuffer::SimpleBuffer() { } +SimpleBuffer::~SimpleBuffer() { } + Memory SimpleBuffer::obtain() { diff --git a/vespalib/src/vespa/vespalib/data/simple_buffer.h b/vespalib/src/vespa/vespalib/data/simple_buffer.h index ef3b6d284dc..631d5530cc8 100644 --- a/vespalib/src/vespa/vespalib/data/simple_buffer.h +++ b/vespalib/src/vespa/vespalib/data/simple_buffer.h @@ -4,7 +4,8 @@ #include "input.h" #include "output.h" -#include <ostream> +#include <iosfwd> +#include <vector> namespace vespalib { @@ -24,6 +25,7 @@ private: public: SimpleBuffer(); + ~SimpleBuffer(); Memory obtain() override; Input &evict(size_t bytes) override; WritableMemory reserve(size_t bytes) override; diff --git a/vespalib/src/vespa/vespalib/data/writable_memory.h b/vespalib/src/vespa/vespalib/data/writable_memory.h index fdcc8e07803..73bbff9dec7 100644 --- a/vespalib/src/vespa/vespalib/data/writable_memory.h +++ b/vespalib/src/vespa/vespalib/data/writable_memory.h @@ -2,6 +2,8 @@ #pragma once +#include <cstddef> + namespace vespalib { /** diff --git a/vespalib/src/vespa/vespalib/testkit/test_master.cpp b/vespalib/src/vespa/vespalib/testkit/test_master.cpp index 45906294a99..9bcadd03fd8 100644 --- a/vespalib/src/vespa/vespalib/testkit/test_master.cpp +++ b/vespalib/src/vespa/vespalib/testkit/test_master.cpp @@ -29,6 +29,8 @@ __thread TestMaster::ThreadState *TestMaster::_threadState = 0; //----------------------------------------------------------------------------- +TestMaster::TraceItem::~TraceItem() { } + TestMaster::ThreadState & TestMaster::threadState(const vespalib::LockGuard &) { diff --git a/vespalib/src/vespa/vespalib/testkit/test_master.h b/vespalib/src/vespa/vespalib/testkit/test_master.h index 369b3ea918e..1148b1ebb09 100644 --- a/vespalib/src/vespa/vespalib/testkit/test_master.h +++ b/vespalib/src/vespa/vespalib/testkit/test_master.h @@ -39,6 +39,7 @@ public: TraceItem(const std::string &file_in, uint32_t line_in, const std::string &msg_in) : file(file_in), line(line_in), msg(msg_in) {} + ~TraceItem(); }; private: diff --git a/vespalib/src/vespa/vespalib/util/thread.cpp b/vespalib/src/vespa/vespalib/util/thread.cpp index 8160e6d53a8..2170cc36db9 100644 --- a/vespalib/src/vespa/vespalib/util/thread.cpp +++ b/vespalib/src/vespa/vespalib/util/thread.cpp @@ -20,6 +20,8 @@ Thread::Proxy::Run(FastOS_ThreadInterface *, void *) _currentThread = 0; } +Thread::Proxy::~Proxy() { } + Thread::Thread(Runnable &runnable) : _proxy(*this, runnable), _pool(STACK_SIZE, 1), diff --git a/vespalib/src/vespa/vespalib/util/thread.h b/vespalib/src/vespa/vespalib/util/thread.h index 96948462ab3..1a87b3bc576 100644 --- a/vespalib/src/vespa/vespalib/util/thread.h +++ b/vespalib/src/vespa/vespalib/util/thread.h @@ -27,8 +27,10 @@ private: Proxy(Thread &parent, Runnable &target) : thread(parent), runnable(target), - start(), started(), cancel(false) {} - virtual void Run(FastOS_ThreadInterface *thisThread, void *arguments); + start(), started(), cancel(false) { } + ~Proxy(); + + void Run(FastOS_ThreadInterface *thisThread, void *arguments) override; }; Proxy _proxy; diff --git a/vespalib/src/vespa/vespalib/util/time_tracker.cpp b/vespalib/src/vespa/vespalib/util/time_tracker.cpp index d8b1f8740a7..7bd863fc898 100644 --- a/vespalib/src/vespa/vespalib/util/time_tracker.cpp +++ b/vespalib/src/vespa/vespalib/util/time_tracker.cpp @@ -6,6 +6,8 @@ namespace vespalib { +TimeTracker::Task::~Task() { } + TimeTracker::TimeTracker(uint32_t max_level_in) : _tasks(), _current_level(0), diff --git a/vespalib/src/vespa/vespalib/util/time_tracker.h b/vespalib/src/vespa/vespalib/util/time_tracker.h index f31ba4305de..7719b3afc2f 100644 --- a/vespalib/src/vespa/vespalib/util/time_tracker.h +++ b/vespalib/src/vespa/vespalib/util/time_tracker.h @@ -18,6 +18,7 @@ private: fastos::StopWatch task_time; std::vector<Task> sub_tasks; Task(const char *name_in) : name(name_in), task_time() { task_time.start(); } + ~Task(); void close_task() { task_time.stop(); } double ms() const { return (task_time.elapsed().sec() * 1000.0); } }; diff --git a/vespalib/src/vespa/vespalib/websocket/buffer.h b/vespalib/src/vespa/vespalib/websocket/buffer.h index eee9085304a..934983bc737 100644 --- a/vespalib/src/vespa/vespalib/websocket/buffer.h +++ b/vespalib/src/vespa/vespalib/websocket/buffer.h @@ -3,8 +3,8 @@ #pragma once -#include <memory> #include <vespa/vespalib/stllike/string.h> +#include <vector> namespace vespalib { namespace ws { diff --git a/vespalib/src/vespa/vespalib/websocket/request.cpp b/vespalib/src/vespa/vespalib/websocket/request.cpp index d894fdbbb3c..3bb08e9e5a7 100644 --- a/vespalib/src/vespa/vespalib/websocket/request.cpp +++ b/vespalib/src/vespa/vespalib/websocket/request.cpp @@ -1,9 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/fastos/fastos.h> #include "request.h" -#include <algorithm> +#include <cassert> namespace vespalib { namespace ws { @@ -32,6 +30,9 @@ void split(vespalib::stringref str, vespalib::stringref sep, } // namespace vespalib::ws::<unnamed> +Request::Request() { } +Request::~Request() { } + bool Request::handle_header(vespalib::string &header_name, const vespalib::string &header_line) diff --git a/vespalib/src/vespa/vespalib/websocket/request.h b/vespalib/src/vespa/vespalib/websocket/request.h index 2c08fb2abe0..8d7993ee372 100644 --- a/vespalib/src/vespa/vespalib/websocket/request.h +++ b/vespalib/src/vespa/vespalib/websocket/request.h @@ -24,6 +24,8 @@ private: const vespalib::string &header_line); public: + Request(); + ~Request(); bool read_header(Connection &conn); bool is_get() const { return _method == "GET"; } const vespalib::string &get_header(const vespalib::string &name) const; diff --git a/vespalog/src/vespa/log/bufferedlogger.cpp b/vespalog/src/vespa/log/bufferedlogger.cpp index 76fdcf1f66a..30f3dcb648d 100644 --- a/vespalog/src/vespa/log/bufferedlogger.cpp +++ b/vespalog/src/vespa/log/bufferedlogger.cpp @@ -43,6 +43,7 @@ public: Entry(Logger::LogLevel level, const char* file, int line, const std::string& token, const std::string& message, uint64_t timestamp, Logger&); + ~Entry(); bool operator==(const Entry& entry) const; bool operator<(const Entry& entry) const; @@ -139,6 +140,8 @@ BackingBuffer::Entry::Entry(Logger::LogLevel level, const char* file, int line, { } +BackingBuffer::Entry::~Entry() { } + bool BackingBuffer::Entry::operator==(const Entry& entry) const { 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<QueryTerm> 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); |