From 857b1380d3d39d3667bf7ee87daa119455bccda2 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Fri, 25 May 2018 09:47:23 +0200 Subject: Add some simple SameElement testing. --- searchlib/src/tests/query/querybuilder_test.cpp | 12 ++++-------- .../vespa/searchlib/features/distancetopathfeature.cpp | 10 +++------- .../src/vespa/searchlib/features/distancetopathfeature.h | 9 +++------ searchlib/src/vespa/searchlib/query/tree/intermediate.h | 2 +- .../src/vespa/searchlib/query/tree/intermediatenodes.h | 1 - searchlib/src/vespa/searchlib/query/tree/querybuilder.h | 5 ++--- searchlib/src/vespa/searchlib/query/tree/term.cpp | 11 +++++++++++ searchlib/src/vespa/searchlib/query/tree/term.h | 15 +++------------ searchlib/src/vespa/searchlib/query/weight.h | 6 ++---- .../queryeval/create_blueprint_visitor_helper.cpp | 2 +- 10 files changed, 30 insertions(+), 43 deletions(-) (limited to 'searchlib') diff --git a/searchlib/src/tests/query/querybuilder_test.cpp b/searchlib/src/tests/query/querybuilder_test.cpp index 37c97d69980..9753072cdf7 100644 --- a/searchlib/src/tests/query/querybuilder_test.cpp +++ b/searchlib/src/tests/query/querybuilder_test.cpp @@ -1,22 +1,18 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // Unit tests for querybuilder. -#include -LOG_SETUP("querybuilder_test"); - #include #include #include -#include #include #include -#include #include #include -#include -#include #include -#include + +#include +LOG_SETUP("querybuilder_test"); +#include using std::string; using search::SimpleQueryStackDumpIterator; diff --git a/searchlib/src/vespa/searchlib/features/distancetopathfeature.cpp b/searchlib/src/vespa/searchlib/features/distancetopathfeature.cpp index 4f4491327e7..834f5913af9 100644 --- a/searchlib/src/vespa/searchlib/features/distancetopathfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/distancetopathfeature.cpp @@ -14,8 +14,7 @@ #include LOG_SETUP(".features.distancetopathfeature"); -namespace search { -namespace features { +namespace search::features { const feature_t DistanceToPathExecutor::DEFAULT_DISTANCE(6400000000.0); @@ -96,9 +95,7 @@ DistanceToPathBlueprint::DistanceToPathBlueprint() : { } -DistanceToPathBlueprint::~DistanceToPathBlueprint() -{ -} +DistanceToPathBlueprint::~DistanceToPathBlueprint() = default; void DistanceToPathBlueprint::visitDumpFeatures(const search::fef::IIndexEnvironment &, @@ -175,5 +172,4 @@ DistanceToPathBlueprint::createExecutor(const search::fef::IQueryEnvironment &en return stash.create(path, pos); } -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/distancetopathfeature.h b/searchlib/src/vespa/searchlib/features/distancetopathfeature.h index cf268c59a2e..442f1ba3b28 100644 --- a/searchlib/src/vespa/searchlib/features/distancetopathfeature.h +++ b/searchlib/src/vespa/searchlib/features/distancetopathfeature.h @@ -6,8 +6,7 @@ #include #include -namespace search { -namespace features { +namespace search::features { /** * Define the point type that makes up the end-points in our path. @@ -52,7 +51,7 @@ private: public: DistanceToPathBlueprint(); - ~DistanceToPathBlueprint(); + ~DistanceToPathBlueprint() override; void visitDumpFeatures(const fef::IIndexEnvironment &env, fef::IDumpFeatureVisitor &visitor) const override; fef::Blueprint::UP createInstance() const override; fef::ParameterDescriptions getDescriptions() const override { @@ -64,6 +63,4 @@ public: }; -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/query/tree/intermediate.h b/searchlib/src/vespa/searchlib/query/tree/intermediate.h index 9fac7345436..052dc1db269 100644 --- a/searchlib/src/vespa/searchlib/query/tree/intermediate.h +++ b/searchlib/src/vespa/searchlib/query/tree/intermediate.h @@ -1,8 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include "node.h" #include -#include namespace search::query { diff --git a/searchlib/src/vespa/searchlib/query/tree/intermediatenodes.h b/searchlib/src/vespa/searchlib/query/tree/intermediatenodes.h index f53e5aed031..93b4000b6c3 100644 --- a/searchlib/src/vespa/searchlib/query/tree/intermediatenodes.h +++ b/searchlib/src/vespa/searchlib/query/tree/intermediatenodes.h @@ -5,7 +5,6 @@ #include "intermediate.h" #include "querynodemixin.h" #include "term.h" -#include namespace search::query { diff --git a/searchlib/src/vespa/searchlib/query/tree/querybuilder.h b/searchlib/src/vespa/searchlib/query/tree/querybuilder.h index 583966bcfc5..b6a755ddb97 100644 --- a/searchlib/src/vespa/searchlib/query/tree/querybuilder.h +++ b/searchlib/src/vespa/searchlib/query/tree/querybuilder.h @@ -20,10 +20,9 @@ #pragma once #include "predicate_query_term.h" -#include -#include -#include #include "node.h" +#include +#include namespace search::query { diff --git a/searchlib/src/vespa/searchlib/query/tree/term.cpp b/searchlib/src/vespa/searchlib/query/tree/term.cpp index 924f562760a..de59752aa10 100644 --- a/searchlib/src/vespa/searchlib/query/tree/term.cpp +++ b/searchlib/src/vespa/searchlib/query/tree/term.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "term.h" +#include namespace search::query { @@ -15,4 +16,14 @@ Term::Term(const vespalib::stringref &view, int32_t id, Weight weight) : _position_data(true) { } +void Term::setStateFrom(const Term& other) { + setTermIndex(other.getTermIndex()); + setRanked(other.isRanked()); + setPositionData(other.usePositionData()); + // too late to copy this state: + assert(_view == other.getView()); + assert(_id == other.getId()); + assert(_weight == other.getWeight()); +} + } diff --git a/searchlib/src/vespa/searchlib/query/tree/term.h b/searchlib/src/vespa/searchlib/query/tree/term.h index f172267ee98..8e9b9897e9d 100644 --- a/searchlib/src/vespa/searchlib/query/tree/term.h +++ b/searchlib/src/vespa/searchlib/query/tree/term.h @@ -1,10 +1,9 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include -#include +#include "node.h" #include -#include +#include namespace search::query { @@ -28,15 +27,7 @@ public: void setRanked(bool ranked) { _ranked = ranked; } void setPositionData(bool position_data) { _position_data = position_data; } - void setStateFrom(const Term& other) { - setTermIndex(other.getTermIndex()); - setRanked(other.isRanked()); - setPositionData(other.usePositionData()); - // too late to copy this state: - assert(_view == other.getView()); - assert(_id == other.getId()); - assert(_weight == other.getWeight()); - } + void setStateFrom(const Term& other); const vespalib::string & getView() const { return _view; } Weight getWeight() const { return _weight; } diff --git a/searchlib/src/vespa/searchlib/query/weight.h b/searchlib/src/vespa/searchlib/query/weight.h index 1b4168231c5..51596642cd2 100644 --- a/searchlib/src/vespa/searchlib/query/weight.h +++ b/searchlib/src/vespa/searchlib/query/weight.h @@ -3,8 +3,7 @@ #include -namespace search { -namespace query { +namespace search::query { /** * Represents the weight given on a query item such as a term, phrase, or equiv. @@ -44,8 +43,7 @@ public: bool operator== (const Weight& other) const { return _weight == other._weight; } }; -} // namespace query -} // namespace search +} inline search::query::Weight operator+(const search::query::Weight& a, const search::query::Weight& b) { diff --git a/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp b/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp index 09d99a77d39..3997f7d36f3 100644 --- a/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp @@ -44,7 +44,7 @@ CreateBlueprintVisitorHelper::visitPhrase(query::Phrase &n) { void CreateBlueprintVisitorHelper::visitSameElement(query::SameElement &n) { (void) n; - //TODO Implement Blueprint creation. + //TODO Implement SameElementBlueprint creation. } void -- cgit v1.2.3