diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-09-05 12:55:29 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-09-05 12:55:29 +0000 |
commit | 3e0260e76e22bffeda3fbef7d152ba249b4b34dc (patch) | |
tree | 9f13ff92092d86e290216af6e5399c30eb8165e0 /searchlib | |
parent | 14d7f43681a92dfba3d47e964c09042184b93960 (diff) |
Some c++ cleanup while reading code.
Diffstat (limited to 'searchlib')
9 files changed, 37 insertions, 28 deletions
diff --git a/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp b/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp index 67bd0286884..29dbf33d29c 100644 --- a/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp @@ -72,7 +72,7 @@ public: } AttributeGuard::UP getAttribute(const string &) const override { - return AttributeGuard::UP(new AttributeGuard(_attribute_vector)); + return std::make_unique<AttributeGuard>(_attribute_vector); } std::unique_ptr<attribute::AttributeReadGuard> diff --git a/searchlib/src/vespa/searchcommon/attribute/i_search_context.h b/searchlib/src/vespa/searchcommon/attribute/i_search_context.h index ff62c535e7f..aa5e216ecd9 100644 --- a/searchlib/src/vespa/searchcommon/attribute/i_search_context.h +++ b/searchlib/src/vespa/searchcommon/attribute/i_search_context.h @@ -25,7 +25,7 @@ private: virtual int32_t onFind(DocId docId, int32_t elementId) const = 0; public: - virtual ~ISearchContext() {} + virtual ~ISearchContext() = default; virtual unsigned int approximateHits() const = 0; diff --git a/searchlib/src/vespa/searchcommon/attribute/iattributecontext.h b/searchlib/src/vespa/searchcommon/attribute/iattributecontext.h index bb349057ca9..9c89b6a0f8b 100644 --- a/searchlib/src/vespa/searchcommon/attribute/iattributecontext.h +++ b/searchlib/src/vespa/searchcommon/attribute/iattributecontext.h @@ -12,9 +12,9 @@ namespace search::attribute { **/ class IAttributeContext : public IAttributeExecutor { public: - typedef vespalib::string string; + using string = vespalib::string; /** Convenience typedefs **/ - typedef std::unique_ptr<IAttributeContext> UP; + using UP = std::unique_ptr<IAttributeContext>; /** * Returns the attribute vector with the given name. @@ -48,7 +48,7 @@ public: /** * Virtual destructor to allow safe subclassing. **/ - virtual ~IAttributeContext() {} + virtual ~IAttributeContext() = default; }; } diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp index 5905995d586..57423f42a10 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_blueprint_factory.cpp @@ -153,7 +153,7 @@ public: .diversityCutoffStrict(diversityCutoffStrict)) {} - SearchIterator::UP createLeafSearch(const TermFieldMatchDataArray &tfmda, bool strict) const override { + SearchIteratorUP createLeafSearch(const TermFieldMatchDataArray &tfmda, bool strict) const override { assert(tfmda.size() == 1); return _search_context->createIterator(tfmda[0], strict); } @@ -406,22 +406,7 @@ public: } } - SearchIterator::UP createLeafSearch(const TermFieldMatchDataArray &tfmda, bool) const override - { - assert(tfmda.size() == 1); - assert(getState().numFields() == 1); - if (_terms.empty()) { - return std::make_unique<queryeval::EmptySearch>(); - } - std::vector<DocumentWeightIterator> iterators; - const size_t numChildren = _terms.size(); - iterators.reserve(numChildren); - for (const IDocumentWeightAttribute::LookupResult &r : _terms) { - _attr.create(r.posting_idx, iterators); - } - bool field_is_filter = getState().fields()[0].isFilter(); - return SearchType::create(*tfmda[0], field_is_filter, _weights, std::move(iterators)); - } + SearchIterator::UP createLeafSearch(const TermFieldMatchDataArray &tfmda, bool) const override; std::unique_ptr<SearchIterator> createFilterSearch(bool strict, FilterConstraint constraint) const override; std::unique_ptr<queryeval::MatchingElementsSearch> create_matching_elements_search(const MatchingElementsFields &fields) const override { @@ -434,6 +419,26 @@ public: }; template <typename SearchType> +SearchIterator::UP +DirectWeightedSetBlueprint<SearchType>::createLeafSearch(const TermFieldMatchDataArray &tfmda, bool) const +{ + assert(tfmda.size() == 1); + assert(getState().numFields() == 1); + if (_terms.empty()) { + return std::make_unique<queryeval::EmptySearch>(); + } + std::vector<DocumentWeightIterator> iterators; + const size_t numChildren = _terms.size(); + iterators.reserve(numChildren); + for (const IDocumentWeightAttribute::LookupResult &r : _terms) { + _attr.create(r.posting_idx, iterators); + } + bool field_is_filter = getState().fields()[0].isFilter(); + return SearchType::create(*tfmda[0], field_is_filter, _weights, std::move(iterators)); +} + + +template <typename SearchType> DirectWeightedSetBlueprint<SearchType>::~DirectWeightedSetBlueprint() = default; template <typename SearchType> diff --git a/searchlib/src/vespa/searchlib/common/geo_location_parser.cpp b/searchlib/src/vespa/searchlib/common/geo_location_parser.cpp index d829e1b93e4..cb69d2346ce 100644 --- a/searchlib/src/vespa/searchlib/common/geo_location_parser.cpp +++ b/searchlib/src/vespa/searchlib/common/geo_location_parser.cpp @@ -2,7 +2,6 @@ #include "geo_location_parser.h" #include <limits> -#include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/data/slime/json_format.h> diff --git a/searchlib/src/vespa/searchlib/query/query_term_simple.cpp b/searchlib/src/vespa/searchlib/query/query_term_simple.cpp index 17e50216a23..afd5e349da9 100644 --- a/searchlib/src/vespa/searchlib/query/query_term_simple.cpp +++ b/searchlib/src/vespa/searchlib/query/query_term_simple.cpp @@ -3,7 +3,6 @@ #include "base.h" #include "query_term_simple.h" #include <vespa/vespalib/objects/visit.h> -#include <vespa/vespalib/text/utf8.h> #include <vespa/vespalib/util/classname.h> #include <vespa/vespalib/locale/c.h> #include <cmath> @@ -314,7 +313,7 @@ QueryTermSimple::getClassName() const void visit(vespalib::ObjectVisitor &self, const vespalib::string &name, const search::QueryTermSimple *obj) { - if (obj != 0) { + if (obj != nullptr) { self.openStruct(name, obj->getClassName()); obj->visitMembers(self); self.closeStruct(); diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.h b/searchlib/src/vespa/searchlib/queryeval/blueprint.h index b7fe627d854..83836f874f0 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.h @@ -169,7 +169,7 @@ protected: public: class IPredicate { public: - virtual ~IPredicate() {} + virtual ~IPredicate() = default; virtual bool check(const Blueprint & bp) const = 0; }; diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp index a123d3f6cd1..8b633302ff7 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp @@ -6,6 +6,11 @@ namespace search::queryeval { +FakeRequestContext::FakeRequestContext() + : FakeRequestContext(nullptr) +{ +} + FakeRequestContext::FakeRequestContext(attribute::IAttributeContext * context, vespalib::steady_time softDoom, vespalib::steady_time hardDoom) : _clock(std::make_unique<vespalib::TestClock>()), _doom(_clock->clock(), softDoom, hardDoom, false), diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h index 4d7e092a812..9f829c9473c 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h +++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h @@ -19,10 +19,11 @@ namespace search::queryeval { class FakeRequestContext : public IRequestContext { public: - FakeRequestContext(attribute::IAttributeContext * context = nullptr, + FakeRequestContext(); + FakeRequestContext(attribute::IAttributeContext * context, vespalib::steady_time soft=vespalib::steady_time::max(), vespalib::steady_time hard=vespalib::steady_time::max()); - ~FakeRequestContext(); + ~FakeRequestContext() override; const vespalib::Doom & getDoom() const override { return _doom; } const attribute::IAttributeVector *getAttribute(const vespalib::string &name) const override { return _attributeContext |