diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-02-01 15:11:53 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-02-01 15:11:53 +0000 |
commit | 2634d3f67851ff602a69dec6ce00029de5fbaea7 (patch) | |
tree | dfae1e85c39aa31e59be1c83a35fa89d9f624d04 /searchcore | |
parent | 179daa38c12471ec9de4e48ec91865c8a336d8a8 (diff) |
Deinline large destructors and clean up some code based on clion hints.
Diffstat (limited to 'searchcore')
14 files changed, 127 insertions, 105 deletions
diff --git a/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp b/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp index 43d0b709a1b..deba3925eb1 100644 --- a/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp +++ b/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp @@ -114,7 +114,7 @@ private: public: VerifyRankSetup(); ~VerifyRankSetup(); - const std::vector<search::fef::Message> & getMessages() const { return _messages; } + [[nodiscard]] const std::vector<search::fef::Message> & getMessages() const { return _messages; } bool verify(const std::string & configId); }; @@ -122,22 +122,25 @@ struct DummyRankingAssetsRepo : IRankingAssetsRepo { const RankingConstantsConfig &cfg; RankingExpressions _expressions; OnnxModels _onnxModels; - DummyRankingAssetsRepo(const RankingConstantsConfig &cfg_in, RankingExpressions expressions, OnnxModels onnxModels) - : cfg(cfg_in), - _expressions(std::move(expressions)), - _onnxModels(std::move(onnxModels)) - {} - vespalib::eval::ConstantValue::UP getConstant(const vespalib::string &name) const override; + DummyRankingAssetsRepo(const RankingConstantsConfig &cfg_in, RankingExpressions expressions, OnnxModels onnxModels); + ~DummyRankingAssetsRepo() override; + [[nodiscard]] vespalib::eval::ConstantValue::UP getConstant(const vespalib::string &name) const override; - vespalib::string getExpression(const vespalib::string & name) const override { + [[nodiscard]] vespalib::string getExpression(const vespalib::string & name) const override { return _expressions.loadExpression(name); } - const search::fef::OnnxModel *getOnnxModel(const vespalib::string & name) const override { + [[nodiscard]] const search::fef::OnnxModel *getOnnxModel(const vespalib::string & name) const override { return _onnxModels.getModel(name); } }; +DummyRankingAssetsRepo::DummyRankingAssetsRepo(const RankingConstantsConfig &cfg_in, RankingExpressions expressions, OnnxModels onnxModels) + : cfg(cfg_in), + _expressions(std::move(expressions)), + _onnxModels(std::move(onnxModels)) +{} +DummyRankingAssetsRepo::~DummyRankingAssetsRepo() = default; vespalib::eval::ConstantValue::UP DummyRankingAssetsRepo::getConstant(const vespalib::string &name) const { for (const auto &entry: cfg.constant) { @@ -178,14 +181,14 @@ VerifyRankSetup::verify(const search::index::Schema &schema, if (!rankSetup.getSecondPhaseRank().empty()) { ok = verifyFeature(factory, indexEnv, rankSetup.getSecondPhaseRank(), "second phase ranking", _messages) && ok; } - for (size_t i = 0; i < rankSetup.getSummaryFeatures().size(); ++i) { - ok = verifyFeature(factory, indexEnv, rankSetup.getSummaryFeatures()[i], "summary features", _messages) && ok; + for (const auto & i : rankSetup.getSummaryFeatures()) { + ok = verifyFeature(factory, indexEnv, i, "summary features", _messages) && ok; } for (const auto & feature : rankSetup.get_match_features()) { ok = verifyFeature(factory, indexEnv, feature, "match features", _messages) && ok; } - for (size_t i = 0; i < rankSetup.getDumpFeatures().size(); ++i) { - ok = verifyFeature(factory, indexEnv, rankSetup.getDumpFeatures()[i], "dump features", _messages) && ok; + for (const auto & i : rankSetup.getDumpFeatures()) { + ok = verifyFeature(factory, indexEnv, i, "dump features", _messages) && ok; } return ok; } @@ -205,12 +208,10 @@ VerifyRankSetup::verifyConfig(const VerifyRanksetupConfig &myCfg, search::index::SchemaBuilder::build(attributeCfg, schema); DummyRankingAssetsRepo repo(constantsCfg, make_expressions(expressionsCfg, myCfg, _messages), make_models(modelsCfg, myCfg, _messages)); - for(size_t i = 0; i < rankCfg.rankprofile.size(); i++) { + for(const auto & profile : rankCfg.rankprofile) { search::fef::Properties properties; - const RankProfilesConfig::Rankprofile &profile = rankCfg.rankprofile[i]; - for(size_t j = 0; j < profile.fef.property.size(); j++) { - properties.add(profile.fef.property[j].name, - profile.fef.property[j].value); + for(const auto & j : profile.fef.property) { + properties.add(j.name, j.value); } if (verify(schema, properties, repo)) { _messages.emplace_back(search::fef::Level::INFO, 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 07167a91498..616bf9edf6a 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 @@ -181,7 +181,7 @@ struct AttributeManagerFixture proton::AttributeManager::SP _msp; proton::AttributeManager &_m; ImportedAttributesRepoBuilder _builder; - AttributeManagerFixture(BaseFixture &bf); + explicit AttributeManagerFixture(BaseFixture &bf); ~AttributeManagerFixture(); AttributeVector::SP addAttribute(const vespalib::string &name) { return _m.addAttribute({name, INT32_SINGLE}, createSerialNum); @@ -214,18 +214,21 @@ struct SequentialAttributeManager { SequentialAttributesInitializer initializer; proton::AttributeManager mgr; - SequentialAttributeManager(const AttributeManager &currMgr, AttrMgrSpec && newSpec) - : initializer(newSpec.getDocIdLimit()), - mgr(currMgr, std::move(newSpec), initializer) - { - mgr.addInitializedAttributes(initializer.getInitializedAttributes()); - } - ~SequentialAttributeManager() = default; + SequentialAttributeManager(const AttributeManager &currMgr, AttrMgrSpec && newSpec); + ~SequentialAttributeManager(); }; +SequentialAttributeManager::SequentialAttributeManager(const AttributeManager &currMgr, AttrMgrSpec && newSpec) + : initializer(newSpec.getDocIdLimit()), + mgr(currMgr, std::move(newSpec), initializer) +{ + mgr.addInitializedAttributes(initializer.getInitializedAttributes()); +} +SequentialAttributeManager::~SequentialAttributeManager() = default; + struct DummyInitializerTask : public InitializerTask { - virtual void run() override {} + void run() override {} }; struct ParallelAttributeManager @@ -240,12 +243,12 @@ struct ParallelAttributeManager ExecutorThreadService master; AttributeManagerInitializer::SP initializer; - ParallelAttributeManager(search::SerialNum configSerialNum, AttributeManager::SP baseAttrMgr, + ParallelAttributeManager(search::SerialNum configSerialNum, AttributeManager & baseAttrMgr, const AttributesConfig &attrCfg, uint32_t docIdLimit); ~ParallelAttributeManager(); }; -ParallelAttributeManager::ParallelAttributeManager(search::SerialNum configSerialNum, AttributeManager::SP baseAttrMgr, +ParallelAttributeManager::ParallelAttributeManager(search::SerialNum configSerialNum, AttributeManager & baseAttrMgr, const AttributesConfig &attrCfg, uint32_t docIdLimit) : documentMetaStoreInitTask(std::make_shared<DummyInitializerTask>()), bucketDbOwner(std::make_shared<bucketdb::BucketDBOwner>()), @@ -256,7 +259,7 @@ ParallelAttributeManager::ParallelAttributeManager(search::SerialNum configSeria masterExecutor(1), master(masterExecutor), initializer(std::make_shared<AttributeManagerInitializer>(configSerialNum, documentMetaStoreInitTask, - documentMetaStore, *baseAttrMgr, attrCfg, + documentMetaStore, baseAttrMgr, attrCfg, alloc_strategy, fastAccessAttributesOnly, master, mgr)) { @@ -389,7 +392,7 @@ TEST_F("require that predicate attributes are flushed and loaded", BaseFixture) AttributeVector::SP a1 = am.addAttribute({"a1", AttributeUtils::getPredicateConfig()}, createSerialNum); EXPECT_EQUAL(1u, a1->getNumDocs()); - auto &pa = static_cast<PredicateAttribute &>(*a1); + auto &pa = dynamic_cast<PredicateAttribute &>(*a1); PredicateIndex &index = pa.getIndex(); uint32_t doc_id; a1->addDoc(doc_id); @@ -409,7 +412,7 @@ TEST_F("require that predicate attributes are flushed and loaded", BaseFixture) AttributeVector::SP a1 = am.addAttribute({"a1", AttributeUtils::getPredicateConfig()}, createSerialNum); // loaded EXPECT_EQUAL(2u, a1->getNumDocs()); - auto &pa = static_cast<PredicateAttribute &>(*a1); + auto &pa = dynamic_cast<PredicateAttribute &>(*a1); PredicateIndex &index = pa.getIndex(); uint32_t doc_id; a1->addDoc(doc_id); @@ -441,9 +444,9 @@ TEST_F("require that reconfig can add attributes", Fixture) f._m.addExtraAttribute(ex); AttrSpecList newSpec; - newSpec.push_back(AttributeSpec("a1", INT32_SINGLE)); - newSpec.push_back(AttributeSpec("a2", INT32_SINGLE)); - newSpec.push_back(AttributeSpec("a3", INT32_SINGLE)); + newSpec.emplace_back("a1", INT32_SINGLE); + newSpec.emplace_back("a2", INT32_SINGLE); + newSpec.emplace_back("a3", INT32_SINGLE); SequentialAttributeManager sam(f._m, AttrMgrSpec(std::move(newSpec), f._m.getNumDocs(), 10)); std::vector<AttributeGuard> list; @@ -466,7 +469,7 @@ TEST_F("require that reconfig can remove attributes", Fixture) AttributeVector::SP a3 = f.addAttribute("a3"); AttrSpecList newSpec; - newSpec.push_back(AttributeSpec("a2", INT32_SINGLE)); + newSpec.emplace_back("a2", INT32_SINGLE); SequentialAttributeManager sam(f._m, AttrMgrSpec(std::move(newSpec), 1, 10)); std::vector<AttributeGuard> list; @@ -487,9 +490,9 @@ TEST_F("require that new attributes after reconfig are initialized", Fixture) EXPECT_EQUAL(3u, a1->getNumDocs()); AttrSpecList newSpec; - newSpec.push_back(AttributeSpec("a1", INT32_SINGLE)); - newSpec.push_back(AttributeSpec("a2", INT32_SINGLE)); - newSpec.push_back(AttributeSpec("a3", INT32_ARRAY)); + newSpec.emplace_back("a1", INT32_SINGLE); + newSpec.emplace_back("a2", INT32_SINGLE); + newSpec.emplace_back("a3", INT32_ARRAY); SequentialAttributeManager sam(f._m, AttrMgrSpec(std::move(newSpec), 3, 4)); AttributeGuard::UP a2ap = sam.mgr.getAttribute("a2"); @@ -521,7 +524,7 @@ TEST_F("require that removed attributes cannot resurrect", BaseFixture) am1.reset(); AttrSpecList ns2; - ns2.push_back(AttributeSpec("a1", INT32_SINGLE)); + ns2.emplace_back("a1", INT32_SINGLE); // 2 new documents added since a1 was removed SequentialAttributeManager am3(am2.mgr, AttrMgrSpec(std::move(ns2), 5, 20)); @@ -555,7 +558,7 @@ TEST_F("require that removed fields can be pruned", Fixture) f._m.flushAll(10); AttrSpecList newSpec; - newSpec.push_back(AttributeSpec("a2", INT32_SINGLE)); + newSpec.emplace_back("a2", INT32_SINGLE); SequentialAttributeManager sam(f._m, AttrMgrSpec(std::move(newSpec), 1, 11)); sam.mgr.pruneRemovedFields(11); @@ -684,9 +687,9 @@ TEST_F("require that attributes can be initialized and loaded in sequence", Base AttributeManagerFixture amf(f); AttrSpecList newSpec; - newSpec.push_back(AttributeSpec("a1", INT32_SINGLE)); - newSpec.push_back(AttributeSpec("a2", INT32_SINGLE)); - newSpec.push_back(AttributeSpec("a3", INT32_SINGLE)); + newSpec.emplace_back("a1", INT32_SINGLE); + newSpec.emplace_back("a2", INT32_SINGLE); + newSpec.emplace_back("a3", INT32_SINGLE); SequentialAttributeManager newMgr(amf._m, AttrMgrSpec(std::move(newSpec), 10, createSerialNum + 5)); @@ -723,7 +726,7 @@ TEST_F("require that attributes can be initialized and loaded in parallel", Base attrCfg.attribute.push_back(createAttributeConfig("a2")); attrCfg.attribute.push_back(createAttributeConfig("a3")); - ParallelAttributeManager newMgr(createSerialNum + 5, amf._msp, attrCfg, 10); + ParallelAttributeManager newMgr(createSerialNum + 5, *amf._msp, attrCfg, 10); AttributeGuard::UP a1 = newMgr.mgr->get()->getAttribute("a1"); TEST_DO(validateAttribute(*a1->get())); @@ -811,12 +814,12 @@ TEST_F("require that attribute vector of wrong type is dropped", BaseFixture) am1->addAttribute({"a5", predicate}, 5); am1->addAttribute({"a6", predicate}, 6); AttrSpecList newSpec; - newSpec.push_back(AttributeSpec("a1", INT32_SINGLE)); - newSpec.push_back(AttributeSpec("a2", INT32_ARRAY)); - newSpec.push_back(AttributeSpec("a3", generic_tensor)); - newSpec.push_back(AttributeSpec("a4", dense_tensor)); - newSpec.push_back(AttributeSpec("a5", predicate)); - newSpec.push_back(AttributeSpec("a6", predicate2)); + newSpec.emplace_back("a1", INT32_SINGLE); + newSpec.emplace_back("a2", INT32_ARRAY); + newSpec.emplace_back("a3", generic_tensor); + newSpec.emplace_back("a4", dense_tensor); + newSpec.emplace_back("a5", predicate); + newSpec.emplace_back("a6", predicate2); SequentialAttributeManager am2(*am1, AttrMgrSpec(std::move(newSpec), 5, 20)); TEST_DO(assertCreateSerialNum(*am1, "a1", 1)); TEST_DO(assertCreateSerialNum(*am1, "a2", 2)); @@ -858,7 +861,7 @@ TEST_F("require that shrink flushtarget is handed over to new attribute manager" auto am1 = f.make_manager(); am1->addAttribute({"a1", INT32_SINGLE}, 4); AttrSpecList newSpec; - newSpec.push_back(AttributeSpec("a1", INT32_SINGLE)); + newSpec.emplace_back("a1", INT32_SINGLE); auto am2 = am1->create(AttrMgrSpec(std::move(newSpec), 5, 20)); auto am3 = std::dynamic_pointer_cast<AttributeManager>(am2); TEST_DO(assertShrinkTargetSerial(*am3, "a1", 3)); diff --git a/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp b/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp index dbc0b890cba..c9262605274 100644 --- a/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp @@ -31,33 +31,31 @@ struct MySubDb { DocumentMetaStore _metaStore; test::UserDocuments _docs; - MySubDb(std::shared_ptr<bucketdb::BucketDBOwner> bucketDB, SubDbType subDbType) - : _metaStore(bucketDB, - DocumentMetaStore::getFixedName(), - search::GrowStrategy(), - subDbType), - _docs() - { - } + MySubDb(std::shared_ptr<bucketdb::BucketDBOwner> bucketDB, SubDbType subDbType); + ~MySubDb(); void insertDocs(const test::UserDocuments &docs_) { _docs = docs_; - for (test::UserDocuments::Iterator itr = _docs.begin(); itr != _docs.end(); ++itr) { - const test::BucketDocuments &bucketDocs = itr->second; - for (size_t i = 0; i < bucketDocs.getDocs().size(); ++i) { - const test::Document &testDoc = bucketDocs.getDocs()[i]; + for (const auto & _doc : _docs) { + const test::BucketDocuments &bucketDocs = _doc.second; + for (const auto & testDoc : bucketDocs.getDocs()) { _metaStore.put(testDoc.getGid(), testDoc.getBucket(), testDoc.getTimestamp(), testDoc.getDocSize(), testDoc.getLid(), 0u); } } } - BucketId bucket(uint32_t userId) { + BucketId bucket(uint32_t userId) const { return _docs.getBucket(userId); } - test::DocumentVector docs(uint32_t userId) { + test::DocumentVector docs(uint32_t userId) const { return _docs.getGidOrderDocs(userId); } }; +MySubDb::MySubDb(std::shared_ptr<bucketdb::BucketDBOwner> bucketDB, SubDbType subDbType) + : _metaStore(std::move(bucketDB), DocumentMetaStore::getFixedName(), search::GrowStrategy(), subDbType), + _docs() +{ } +MySubDb::~MySubDb() = default; struct MyChangedHandler : public IBucketStateChangedHandler { @@ -65,8 +63,8 @@ struct MyChangedHandler : public IBucketStateChangedHandler BucketInfo::ActiveState _state; MyChangedHandler() : _bucket(), _state(BucketInfo::NOT_ACTIVE) {} - virtual void notifyBucketStateChanged(const document::BucketId &bucketId, - storage::spi::BucketInfo::ActiveState newState) override { + void notifyBucketStateChanged(const document::BucketId &bucketId, + storage::spi::BucketInfo::ActiveState newState) override { _bucket = bucketId; _state = newState; } diff --git a/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp b/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp index 6aa17151942..fb29f968d61 100644 --- a/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp +++ b/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp @@ -14,7 +14,6 @@ using search::SerialNum; using searchcorespi::IFlushTarget; using SimpleFlushHandler = test::DummyFlushHandler; -using FlushCandidatesList = std::vector<FlushTargetCandidates>; using Config = PrepareRestartFlushStrategy::Config; const Config DEFAULT_CFG(2.0, 0.0, 4.0); @@ -34,13 +33,13 @@ struct SimpleFlushTarget : public test::DummyFlushTarget approxDiskBytes(approxDiskBytes_), replay_operation_cost(replay_operation_cost_) {} - SerialNum getFlushedSerialNum() const override { + [[nodiscard]] SerialNum getFlushedSerialNum() const override { return flushedSerial; } - uint64_t getApproxBytesToWriteToDisk() const override { + [[nodiscard]] uint64_t getApproxBytesToWriteToDisk() const override { return approxDiskBytes; } - double get_replay_operation_cost() const override { + [[nodiscard]] double get_replay_operation_cost() const override { return replay_operation_cost; } }; @@ -62,7 +61,8 @@ private: } public: - ContextsBuilder() : _result(), _handlers() {} + ContextsBuilder() noexcept; + ~ContextsBuilder(); ContextsBuilder &add(const vespalib::string &handlerName, const vespalib::string &targetName, IFlushTarget::Type targetType, @@ -97,9 +97,12 @@ public: double replay_operation_cost = 0.0) { return add("handler1", targetName, IFlushTarget::Type::GC, flushedSerial, approxDiskBytes, replay_operation_cost); } - FlushContext::List build() const { return _result; } + [[nodiscard]] FlushContext::List build() const { return _result; } }; +ContextsBuilder::ContextsBuilder() noexcept = default; +ContextsBuilder::~ContextsBuilder() = default; + class CandidatesBuilder { private: @@ -110,7 +113,7 @@ private: Config _cfg; public: - CandidatesBuilder(const FlushContext::List &sortedFlushContexts) + explicit CandidatesBuilder(const FlushContext::List &sortedFlushContexts) : _sortedFlushContexts(&sortedFlushContexts), _numCandidates(sortedFlushContexts.size()), _candidates(), @@ -142,10 +145,7 @@ public: } FlushTargetCandidates build() const { setup_candidates(); - return FlushTargetCandidates(_candidates, - _numCandidates, - _tlsStats, - _cfg); + return {_candidates, _numCandidates, _tlsStats, _cfg}; } }; @@ -212,14 +212,14 @@ struct FlushStrategyFixture { flushengine::TlsStatsMap _tlsStatsMap; PrepareRestartFlushStrategy strategy; - FlushStrategyFixture(const Config &config) + explicit FlushStrategyFixture(const Config &config) : _tlsStatsMap(defaultTransactionLogStats()), strategy(config) {} FlushStrategyFixture() : FlushStrategyFixture(DEFAULT_CFG) {} - FlushContext::List getFlushTargets(const FlushContext::List &targetList, + [[nodiscard]] FlushContext::List getFlushTargets(const FlushContext::List &targetList, const flushengine::TlsStatsMap &tlsStatsMap) const { flushengine::ActiveFlushStats active_flushes; return strategy.getFlushTargets(targetList, tlsStatsMap, active_flushes); diff --git a/searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt b/searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt index c5081f27db6..aab02c2b48c 100644 --- a/searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt +++ b/searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt @@ -5,6 +5,7 @@ vespa_add_executable(searchcore_document_db_reference_resolver_test_app TEST DEPENDS searchcore_reference searchcore_attribute + searchcore_test searchlib_test ) vespa_add_test(NAME searchcore_document_db_reference_resolver_test_app COMMAND searchcore_document_db_reference_resolver_test_app) diff --git a/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/CMakeLists.txt b/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/CMakeLists.txt index 6ac416d2ce2..d9d6501af5e 100644 --- a/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/CMakeLists.txt +++ b/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/CMakeLists.txt @@ -5,5 +5,6 @@ vespa_add_executable(searchcore_gid_to_lid_change_handler_test_app TEST DEPENDS searchcore_reference searchcore_server + searchcore_test ) vespa_add_test(NAME searchcore_gid_to_lid_change_handler_test_app COMMAND searchcore_gid_to_lid_change_handler_test_app) diff --git a/searchcore/src/tests/proton/reference/gid_to_lid_change_registrator/CMakeLists.txt b/searchcore/src/tests/proton/reference/gid_to_lid_change_registrator/CMakeLists.txt index 30929059cab..6808258cbc8 100644 --- a/searchcore/src/tests/proton/reference/gid_to_lid_change_registrator/CMakeLists.txt +++ b/searchcore/src/tests/proton/reference/gid_to_lid_change_registrator/CMakeLists.txt @@ -5,5 +5,6 @@ vespa_add_executable(searchcore_gid_to_lid_change_registrator_test_app TEST DEPENDS searchcore_reference searchcore_server + searchcore_test ) vespa_add_test(NAME searchcore_gid_to_lid_change_registrator_test_app COMMAND searchcore_gid_to_lid_change_registrator_test_app) diff --git a/searchcore/src/vespa/searchcore/proton/matching/onnx_models.h b/searchcore/src/vespa/searchcore/proton/matching/onnx_models.h index c0582600973..4a8bdbca3d9 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/onnx_models.h +++ b/searchcore/src/vespa/searchcore/proton/matching/onnx_models.h @@ -34,8 +34,8 @@ public: OnnxModels & operator =(const OnnxModels &) = delete; ~OnnxModels(); bool operator==(const OnnxModels &rhs) const; - const Model *getModel(const vespalib::string &name) const; - size_t size() const { return _models.size(); } + [[nodiscard]] const Model *getModel(const vespalib::string &name) const; + [[nodiscard]] size_t size() const { return _models.size(); } static void configure(const ModelConfig &config, Model &model); }; diff --git a/searchcore/src/vespa/searchcore/proton/matching/querynodes.h b/searchcore/src/vespa/searchcore/proton/matching/querynodes.h index fc3f12af4f7..4e9f03f2fac 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/querynodes.h +++ b/searchcore/src/vespa/searchcore/proton/matching/querynodes.h @@ -36,12 +36,11 @@ public: attribute_field(false), filter_field(false) {} - FieldSpec fieldSpec() const { - return FieldSpec(field_name, getFieldId(), - getHandle(), filter_field); + [[nodiscard]] FieldSpec fieldSpec() const { + return {field_name, getFieldId(), getHandle(), filter_field}; } using SimpleTermFieldData::getHandle; - search::fef::TermFieldHandle getHandle(search::fef::MatchDataDetails requested_details) const override; + [[nodiscard]] search::fef::TermFieldHandle getHandle(search::fef::MatchDataDetails requested_details) const override; }; private: @@ -67,10 +66,10 @@ public: void setDocumentFrequency(uint32_t estHits, uint32_t numDocs); // ITermData interface - std::optional<vespalib::string> query_tensor_name() const override { return std::nullopt; } - size_t numFields() const override final { return _fields.size(); } - const FieldEntry &field(size_t i) const override final { return _fields[i]; } - const FieldEntry *lookupField(uint32_t fieldId) const override final; + [[nodiscard]] std::optional<vespalib::string> query_tensor_name() const override { return std::nullopt; } + [[nodiscard]] size_t numFields() const final { return _fields.size(); } + [[nodiscard]] const FieldEntry &field(size_t i) const final { return _fields[i]; } + [[nodiscard]] const FieldEntry *lookupField(uint32_t fieldId) const final; }; template <typename NodeType> inline uint32_t numTerms(const NodeType &) { return 1; } @@ -85,6 +84,7 @@ struct ProtonTermBase : public Base, public ProtonTermData { using Base::Base; + ~ProtonTermBase() override; void resolve(const ViewResolver &resolver, const search::fef::IIndexEnvironment &idxEnv) { @@ -93,12 +93,15 @@ struct ProtonTermBase : public Base, } // ITermData interface - uint32_t getPhraseLength() const final { return numTerms<Base>(*this); } - search::query::Weight getWeight() const final { return Base::getWeight(); } - uint32_t getUniqueId() const final { return Base::getId(); } + [[nodiscard]] uint32_t getPhraseLength() const final { return numTerms<Base>(*this); } + [[nodiscard]] search::query::Weight getWeight() const final { return Base::getWeight(); } + [[nodiscard]] uint32_t getUniqueId() const final { return Base::getId(); } }; template <typename Base> +ProtonTermBase<Base>::~ProtonTermBase() = default; + +template <typename Base> struct ProtonTerm final : public ProtonTermBase<Base> { using ProtonTermBase<Base>::ProtonTermBase; ~ProtonTerm(); @@ -128,7 +131,7 @@ struct ProtonSameElement final : public ProtonTermBase<search::query::SameElemen struct ProtonNearestNeighborTerm : public ProtonTermBase<search::query::NearestNeighborTerm> { using ProtonTermBase::ProtonTermBase; - std::optional<vespalib::string> query_tensor_name() const override { + [[nodiscard]] std::optional<vespalib::string> query_tensor_name() const override { return ProtonTermBase::NearestNeighborTerm::get_query_tensor_name(); } }; diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenance_controller_explorer.cpp b/searchcore/src/vespa/searchcore/proton/server/maintenance_controller_explorer.cpp index f7123c1f862..170632739da 100644 --- a/searchcore/src/vespa/searchcore/proton/server/maintenance_controller_explorer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/maintenance_controller_explorer.cpp @@ -41,6 +41,7 @@ MaintenanceControllerExplorer(std::vector<MaintenanceJobRunner::SP> jobs) : _jobs(std::move(jobs)) { } +MaintenanceControllerExplorer::~MaintenanceControllerExplorer() = default; void MaintenanceControllerExplorer::get_state(const Inserter &inserter, bool full) const diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenance_controller_explorer.h b/searchcore/src/vespa/searchcore/proton/server/maintenance_controller_explorer.h index 76aef09e58c..aabb9836dcb 100644 --- a/searchcore/src/vespa/searchcore/proton/server/maintenance_controller_explorer.h +++ b/searchcore/src/vespa/searchcore/proton/server/maintenance_controller_explorer.h @@ -16,7 +16,8 @@ private: std::vector<MaintenanceJobRunner::SP> _jobs; public: - MaintenanceControllerExplorer(std::vector<MaintenanceJobRunner::SP> jobs); + explicit MaintenanceControllerExplorer(std::vector<MaintenanceJobRunner::SP> jobs); + ~MaintenanceControllerExplorer() override; void get_state(const vespalib::slime::Inserter &inserter, bool full) const override; }; diff --git a/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt index 79b0582e1d0..e3b1aad3c60 100644 --- a/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt @@ -11,6 +11,7 @@ vespa_add_library(searchcore_test STATIC dummy_feed_view.cpp dummy_flush_target.cpp dummydbowner.cpp + mock_gid_to_lid_change_handler.cpp mock_index_manager.cpp mock_shared_threading_service.cpp userdocumentsbuilder.cpp diff --git a/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.cpp b/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.cpp new file mode 100644 index 00000000000..ea011dd2d37 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.cpp @@ -0,0 +1,17 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "mock_gid_to_lid_change_handler.h" + +namespace proton::test { + +MockGidToLidChangeHandler::MockGidToLidChangeHandler() noexcept + : IGidToLidChangeHandler(), + _adds(), + _removes(), + _listeners() +{ +} + +MockGidToLidChangeHandler::~MockGidToLidChangeHandler() = default; + +} diff --git a/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h b/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h index 5931defbe7e..d7c72e3109a 100644 --- a/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h +++ b/searchcore/src/vespa/searchcore/proton/test/mock_gid_to_lid_change_handler.h @@ -6,6 +6,7 @@ #include <vespa/searchcore/proton/reference/i_pending_gid_to_lid_changes.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/test/insertion_operators.h> +#include <vespa/document/base/globalid.h> namespace proton::test { @@ -24,15 +25,8 @@ private: std::vector<std::unique_ptr<IGidToLidChangeListener>> _listeners; public: - MockGidToLidChangeHandler() noexcept - : IGidToLidChangeHandler(), - _adds(), - _removes(), - _listeners() - { - } - - ~MockGidToLidChangeHandler() override = default; + MockGidToLidChangeHandler() noexcept; + ~MockGidToLidChangeHandler() override; void addListener(std::unique_ptr<IGidToLidChangeListener> listener) override { _adds.emplace_back(listener->getDocTypeName(), listener->getName()); |