diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-01-22 12:15:19 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-01-22 12:15:19 +0000 |
commit | 6e9a146bcf912c9378f4b78831ac55e1c0cd5f0f (patch) | |
tree | 175960b7b3349bbca77bcbb4ac09076e05e4bda5 /searchlib | |
parent | 8372a883c5a5fa100f88fc9b80824359b5bb70cd (diff) |
nested namepace and related cleanup
Diffstat (limited to 'searchlib')
72 files changed, 629 insertions, 831 deletions
diff --git a/searchlib/src/vespa/searchlib/features/agefeature.h b/searchlib/src/vespa/searchlib/features/agefeature.h index 99898af910f..2914d2df472 100644 --- a/searchlib/src/vespa/searchlib/features/agefeature.h +++ b/searchlib/src/vespa/searchlib/features/agefeature.h @@ -2,11 +2,9 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchcommon/attribute/attributecontent.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor for the documentage feature outputting the @@ -42,5 +40,3 @@ public: }; } -} - diff --git a/searchlib/src/vespa/searchlib/features/attributefeature.h b/searchlib/src/vespa/searchlib/features/attributefeature.h index 2d206fb738e..c115c4acaea 100644 --- a/searchlib/src/vespa/searchlib/features/attributefeature.h +++ b/searchlib/src/vespa/searchlib/features/attributefeature.h @@ -3,11 +3,9 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/eval/eval/value_type.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the blueprint for the attribute executor. @@ -32,6 +30,4 @@ public: bool setup(const fef::IIndexEnvironment & env, const fef::ParameterList & params) override; }; - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/attributematchfeature.h b/searchlib/src/vespa/searchlib/features/attributematchfeature.h index 3cdc6e322a3..487a35ab573 100644 --- a/searchlib/src/vespa/searchlib/features/attributematchfeature.h +++ b/searchlib/src/vespa/searchlib/features/attributematchfeature.h @@ -2,13 +2,10 @@ #pragma once -#include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -#include <vespa/searchlib/common/feature.h> #include "queryterm.h" +#include <vespa/searchlib/fef/blueprint.h> -namespace search { -namespace features { +namespace search::features { struct AttributeMatchParams { AttributeMatchParams() : @@ -74,7 +71,7 @@ private: Computer _cmp; - virtual void handle_bind_match_data(const fef::MatchData &md) override; + void handle_bind_match_data(const fef::MatchData &md) override; public: /** @@ -106,7 +103,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/closenessfeature.h b/searchlib/src/vespa/searchlib/features/closenessfeature.h index 15e9bf574f1..d5e3cb36505 100644 --- a/searchlib/src/vespa/searchlib/features/closenessfeature.h +++ b/searchlib/src/vespa/searchlib/features/closenessfeature.h @@ -4,10 +4,8 @@ #include "logarithmcalculator.h" #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor for the closeness feature. @@ -44,6 +42,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/constant_feature.h b/searchlib/src/vespa/searchlib/features/constant_feature.h index 8f0e2f1cf8e..b7e4a9fdcab 100644 --- a/searchlib/src/vespa/searchlib/features/constant_feature.h +++ b/searchlib/src/vespa/searchlib/features/constant_feature.h @@ -6,8 +6,7 @@ namespace vespalib { namespace eval { struct ConstantValue; } } -namespace search { -namespace features { +namespace search::features { /** * Implements the blueprint for the constant feature. @@ -15,7 +14,7 @@ namespace features { * An executor of this outputs the value of a named constant. * This can either be a number or a tensor value. */ -class ConstantBlueprint : public search::fef::Blueprint { +class ConstantBlueprint : public fef::Blueprint { private: vespalib::string _key; // 'foo' std::unique_ptr<vespalib::eval::ConstantValue> _value; @@ -26,23 +25,19 @@ public: */ ConstantBlueprint(); - ~ConstantBlueprint(); + ~ConstantBlueprint() override; - virtual void visitDumpFeatures(const search::fef::IIndexEnvironment &env, - search::fef::IDumpFeatureVisitor &visitor) const override; + void visitDumpFeatures(const fef::IIndexEnvironment &env, fef::IDumpFeatureVisitor &visitor) const override; - virtual search::fef::Blueprint::UP createInstance() const override; + fef::Blueprint::UP createInstance() const override; - virtual search::fef::ParameterDescriptions getDescriptions() const override { - return search::fef::ParameterDescriptions().desc().string(); + fef::ParameterDescriptions getDescriptions() const override { + return fef::ParameterDescriptions().desc().string(); } - virtual bool setup(const search::fef::IIndexEnvironment &env, - const search::fef::ParameterList ¶ms) override; + bool setup(const fef::IIndexEnvironment &env, const fef::ParameterList ¶ms) override; - virtual search::fef::FeatureExecutor &createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; + fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/constant_tensor_executor.h b/searchlib/src/vespa/searchlib/features/constant_tensor_executor.h index 43ce48282ee..2ab7b98fabe 100644 --- a/searchlib/src/vespa/searchlib/features/constant_tensor_executor.h +++ b/searchlib/src/vespa/searchlib/features/constant_tensor_executor.h @@ -9,8 +9,7 @@ #include <vespa/eval/tensor/default_tensor_engine.h> #include <memory> -namespace search { -namespace features { +namespace search::features { /** * Feature executor that returns a constant tensor. @@ -24,8 +23,8 @@ public: ConstantTensorExecutor(vespalib::eval::Value::UP tensor) : _tensor(std::move(tensor)) {} - virtual bool isPure() override { return true; } - virtual void execute(uint32_t) override { + bool isPure() override { return true; } + void execute(uint32_t) override { outputs().set_object(0, *_tensor); } static fef::FeatureExecutor &create(std::unique_ptr<vespalib::eval::Tensor> tensor, vespalib::Stash &stash) { @@ -41,5 +40,4 @@ public: } }; -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/debug_attribute_wait.h b/searchlib/src/vespa/searchlib/features/debug_attribute_wait.h index fdb23a3f374..94083448ce9 100644 --- a/searchlib/src/vespa/searchlib/features/debug_attribute_wait.h +++ b/searchlib/src/vespa/searchlib/features/debug_attribute_wait.h @@ -2,13 +2,10 @@ #pragma once -#include <string> -#include <vector> +#include <vespa/searchlib/fef/blueprint.h> #include <vespa/searchcommon/attribute/attributecontent.h> -#include <vespa/searchlib/fef/fef.h> -namespace search { -namespace features { +namespace search::features { //----------------------------------------------------------------------------- @@ -33,8 +30,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; -//----------------------------------------------------------------------------- - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/debug_wait.h b/searchlib/src/vespa/searchlib/features/debug_wait.h index 881cf6cf289..f185b5fae1b 100644 --- a/searchlib/src/vespa/searchlib/features/debug_wait.h +++ b/searchlib/src/vespa/searchlib/features/debug_wait.h @@ -2,12 +2,9 @@ #pragma once -#include <string> -#include <vector> -#include <vespa/searchlib/fef/fef.h> +#include <vespa/searchlib/fef/blueprint.h> -namespace search { -namespace features { +namespace search::features { //----------------------------------------------------------------------------- @@ -35,8 +32,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; -//----------------------------------------------------------------------------- - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/dense_tensor_attribute_executor.h b/searchlib/src/vespa/searchlib/features/dense_tensor_attribute_executor.h index 3b66d3d0ba1..2bcf356689e 100644 --- a/searchlib/src/vespa/searchlib/features/dense_tensor_attribute_executor.h +++ b/searchlib/src/vespa/searchlib/features/dense_tensor_attribute_executor.h @@ -6,9 +6,8 @@ #include <vespa/eval/eval/value.h> #include <vespa/eval/tensor/dense/mutable_dense_tensor_view.h> -namespace search { -namespace tensor { class ITensorAttribute; } -namespace features { +namespace search::tensor { class ITensorAttribute; } +namespace search::features { /** * Executor for extracting dense tensors from an underlying dense tensor attribute @@ -25,5 +24,4 @@ public: void execute(uint32_t docId) override; }; -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/distancefeature.h b/searchlib/src/vespa/searchlib/features/distancefeature.h index eaa3c3e50f6..3c75d53ad77 100644 --- a/searchlib/src/vespa/searchlib/features/distancefeature.h +++ b/searchlib/src/vespa/searchlib/features/distancefeature.h @@ -2,13 +2,10 @@ #pragma once -#include <vespa/searchcommon/attribute/attributecontent.h> #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -#include <vespa/searchlib/common/feature.h> +#include <vespa/searchcommon/attribute/attributecontent.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor for the distance feature. @@ -54,7 +51,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/distancetopathfeature.h b/searchlib/src/vespa/searchlib/features/distancetopathfeature.h index 442f1ba3b28..e36ace0c601 100644 --- a/searchlib/src/vespa/searchlib/features/distancetopathfeature.h +++ b/searchlib/src/vespa/searchlib/features/distancetopathfeature.h @@ -1,10 +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 <vespa/searchcommon/attribute/attributecontent.h> #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -#include <vespa/searchlib/common/feature.h> +#include <vespa/searchcommon/attribute/attributecontent.h> namespace search::features { diff --git a/searchlib/src/vespa/searchlib/features/documenttestutils.cpp b/searchlib/src/vespa/searchlib/features/documenttestutils.cpp index 896e0922a48..e13699576cd 100644 --- a/searchlib/src/vespa/searchlib/features/documenttestutils.cpp +++ b/searchlib/src/vespa/searchlib/features/documenttestutils.cpp @@ -16,9 +16,7 @@ LOG_SETUP(".features.utils"); using namespace search::fef; -namespace search { -namespace features { -namespace util { +namespace search::features::util { feature_t lookupConnectedness(const search::fef::IQueryEnvironment & env, uint32_t termId, feature_t fallback) { @@ -152,6 +150,4 @@ getTermByLabel(const search::fef::IQueryEnvironment &env, const vespalib::string return 0; } -} // namespace util -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp b/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp index 0173455bcf9..ae1271edf5d 100644 --- a/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp @@ -64,9 +64,9 @@ DotProductExecutor<Vector, Buffer>::execute(uint32_t docId) outputs().set_number(0, val); } -StringVector::StringVector() { } +StringVector::StringVector() = default; -StringVector::~StringVector() { } +StringVector::~StringVector() = default; } @@ -81,7 +81,7 @@ DotProductExecutorBase<BaseType>::DotProductExecutorBase(const V & queryVector) } template <typename BaseType> -DotProductExecutorBase<BaseType>::~DotProductExecutorBase() { } +DotProductExecutorBase<BaseType>::~DotProductExecutorBase() = default; template <typename BaseType> void DotProductExecutorBase<BaseType>::execute(uint32_t docId) { diff --git a/searchlib/src/vespa/searchlib/features/dotproductfeature.h b/searchlib/src/vespa/searchlib/features/dotproductfeature.h index c350494db0e..9356fe9c7f2 100644 --- a/searchlib/src/vespa/searchlib/features/dotproductfeature.h +++ b/searchlib/src/vespa/searchlib/features/dotproductfeature.h @@ -4,18 +4,14 @@ #include "utils.h" #include <vespa/searchlib/fef/blueprint.h> -#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 { -namespace fef { -class Property; -} +namespace search::fef { class Property; } -namespace features { +namespace search::features { namespace dotproduct { @@ -246,7 +242,7 @@ public: SparseDotProductByContentFillExecutor(const attribute::IAttributeVector * attribute, const V & queryVector, const IV & queryIndexes); - ~SparseDotProductByContentFillExecutor(); + ~SparseDotProductByContentFillExecutor() override; private: size_t getAttributeValues(uint32_t docid, const AT * & values) final override; @@ -259,7 +255,6 @@ private: } - /** * Implements the blueprint for the foreach executor. */ @@ -272,7 +267,7 @@ private: public: DotProductBlueprint(); - ~DotProductBlueprint(); + ~DotProductBlueprint() override; void visitDumpFeatures(const fef::IIndexEnvironment & env, fef::IDumpFeatureVisitor & visitor) const override; fef::Blueprint::UP createInstance() const override; @@ -281,10 +276,6 @@ public: bool setup(const fef::IIndexEnvironment & env, const fef::ParameterList & params) override; void prepareSharedState(const fef::IQueryEnvironment & queryEnv, fef::IObjectStore & objectStore) const override; fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; - }; - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/element_completeness_feature.cpp b/searchlib/src/vespa/searchlib/features/element_completeness_feature.cpp index 18988281cbd..1d71fa9d47c 100644 --- a/searchlib/src/vespa/searchlib/features/element_completeness_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/element_completeness_feature.cpp @@ -1,13 +1,16 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "element_completeness_feature.h" +#include <vespa/searchlib/fef/itermdata.h> +#include <vespa/searchlib/fef/featurenamebuilder.h> +#include <vespa/searchlib/fef/properties.h> #include <vespa/vespalib/locale/c.h> namespace search::features { //----------------------------------------------------------------------------- -ElementCompletenessExecutor::ElementCompletenessExecutor(const search::fef::IQueryEnvironment &env, +ElementCompletenessExecutor::ElementCompletenessExecutor(const fef::IQueryEnvironment &env, const ElementCompletenessParams ¶ms) : _params(params), _terms(), @@ -16,11 +19,11 @@ ElementCompletenessExecutor::ElementCompletenessExecutor(const search::fef::IQue _md(nullptr) { for (uint32_t i = 0; i < env.getNumTerms(); ++i) { - const search::fef::ITermData *termData = env.getTerm(i); + const fef::ITermData *termData = env.getTerm(i); if (termData->getWeight().percent() != 0) { // only consider query terms with contribution - typedef search::fef::ITermFieldRangeAdapter FRA; + typedef fef::ITermFieldRangeAdapter FRA; for (FRA iter(*termData); iter.valid(); iter.next()) { - const search::fef::ITermFieldData &tfd = iter.get(); + const fef::ITermFieldData &tfd = iter.get(); if (tfd.getFieldId() == _params.fieldId) { int termWeight = termData->getWeight().percent(); _sumTermWeight += termWeight; @@ -36,7 +39,7 @@ ElementCompletenessExecutor::execute(uint32_t docId) { assert(_queue.empty()); for (size_t i = 0; i < _terms.size(); ++i) { - const search::fef::TermFieldMatchData *tfmd = _md->resolveTermField(_terms[i].termHandle); + const fef::TermFieldMatchData *tfmd = _md->resolveTermField(_terms[i].termHandle); if (tfmd->getDocId() == docId) { Item item(i, tfmd->begin(), tfmd->end()); if (item.pos != item.end) { @@ -92,14 +95,14 @@ ElementCompletenessBlueprint::ElementCompletenessBlueprint() } void -ElementCompletenessBlueprint::visitDumpFeatures(const search::fef::IIndexEnvironment &env, - search::fef::IDumpFeatureVisitor &visitor) const +ElementCompletenessBlueprint::visitDumpFeatures(const fef::IIndexEnvironment &env, + fef::IDumpFeatureVisitor &visitor) const { for (uint32_t i = 0; i < env.getNumFields(); ++i) { - const search::fef::FieldInfo &field = *env.getField(i); - if (field.type() == search::fef::FieldType::INDEX) { + const fef::FieldInfo &field = *env.getField(i); + if (field.type() == fef::FieldType::INDEX) { if (!field.isFilter()) { - search::fef::FeatureNameBuilder fnb; + fef::FeatureNameBuilder fnb; fnb.baseName(getBaseName()).parameter(field.name()); for (size_t out = 0; out < _output.size(); ++out) { visitor.visitDumpFeature(fnb.output(_output[out]).buildName()); @@ -109,21 +112,21 @@ ElementCompletenessBlueprint::visitDumpFeatures(const search::fef::IIndexEnviron } } -search::fef::Blueprint::UP +fef::Blueprint::UP ElementCompletenessBlueprint::createInstance() const { return Blueprint::UP(new ElementCompletenessBlueprint()); } bool -ElementCompletenessBlueprint::setup(const search::fef::IIndexEnvironment &env, - const search::fef::ParameterList ¶ms) +ElementCompletenessBlueprint::setup(const fef::IIndexEnvironment &env, + const fef::ParameterList ¶ms) { - const search::fef::FieldInfo *field = params[0].asField(); + const fef::FieldInfo *field = params[0].asField(); _params.fieldId = field->id(); - const search::fef::Properties &lst = env.getProperties(); - search::fef::Property obj = lst.lookup(getName(), "fieldCompletenessImportance"); + const fef::Properties &lst = env.getProperties(); + fef::Property obj = lst.lookup(getName(), "fieldCompletenessImportance"); if (obj.found()) { _params.fieldCompletenessImportance = vespalib::locale::c::atof(obj.get().c_str()); } @@ -135,8 +138,8 @@ ElementCompletenessBlueprint::setup(const search::fef::IIndexEnvironment &env, return true; } -search::fef::FeatureExecutor & -ElementCompletenessBlueprint::createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const +fef::FeatureExecutor & +ElementCompletenessBlueprint::createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const { return stash.create<ElementCompletenessExecutor>(env, _params); } diff --git a/searchlib/src/vespa/searchlib/features/element_completeness_feature.h b/searchlib/src/vespa/searchlib/features/element_completeness_feature.h index 1b835da45d2..ea971b6b036 100644 --- a/searchlib/src/vespa/searchlib/features/element_completeness_feature.h +++ b/searchlib/src/vespa/searchlib/features/element_completeness_feature.h @@ -2,11 +2,10 @@ #pragma once -#include <vespa/searchlib/fef/fef.h> +#include <vespa/searchlib/fef/blueprint.h> #include <vespa/vespalib/util/priority_queue.h> -namespace search { -namespace features { +namespace search::features { //----------------------------------------------------------------------------- @@ -117,8 +116,4 @@ public: const ElementCompletenessParams &getParams() const { return _params; } }; -//----------------------------------------------------------------------------- - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp b/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp index c9eab238f82..73d3262ab4e 100644 --- a/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp @@ -1,430 +1,464 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "element_similarity_feature.h" +#include <vespa/searchlib/fef/itermdata.h> +#include <vespa/searchlib/fef/featurenamebuilder.h> +#include <vespa/searchlib/fef/properties.h> #include <vespa/eval/eval/llvm/compiled_function.h> #include <vespa/eval/eval/llvm/compile_cache.h> #include <vespa/log/log.h> LOG_SETUP(".features.elementsimilarity"); -namespace search { +namespace search::features { -using CollectionType = fef::FieldInfo::CollectionType; + using CollectionType = fef::FieldInfo::CollectionType; -namespace features { - -namespace { + namespace { //----------------------------------------------------------------------------- -struct Aggregator { - typedef std::unique_ptr<Aggregator> UP; - virtual UP create() const = 0; - virtual void clear() = 0; - virtual void add(double) = 0; - virtual double get() const = 0; - virtual ~Aggregator() {} -}; - -struct MaxAggregator : Aggregator { - size_t count; - double value; - MaxAggregator() : count(0), value(0.0) {} - UP create() const override { return UP(new MaxAggregator()); } - void clear() override { count = 0; value = 0.0; } - void add(double v) override { value = ((++count == 1) || (v > value)) ? v : value; } - double get() const override { return value; } -}; - -struct AvgAggregator : Aggregator { - size_t count; - double value; - AvgAggregator() : count(0), value(0.0) {} - UP create() const override { return UP(new AvgAggregator()); } - void clear() override { count = 0; value = 0.0; } - void add(double v) override { ++count; value += v; } - double get() const override { return (count == 0) ? 0.0 : (value/count); } -}; - -struct SumAggregator : Aggregator { - double value; - SumAggregator() : value(0.0) {} - UP create() const override { return UP(new SumAggregator()); } - void clear() override { value = 0.0; } - void add(double v) override { value += v; } - double get() const override { return value; } -}; - -Aggregator::UP create_aggregator(const vespalib::string &name) { - if (name == "max") { - return Aggregator::UP(new MaxAggregator()); - } - if (name == "avg") { - return Aggregator::UP(new AvgAggregator()); - } - if (name == "sum") { - return Aggregator::UP(new SumAggregator()); - } - return Aggregator::UP(nullptr); -} + struct Aggregator { + typedef std::unique_ptr<Aggregator> UP; -//----------------------------------------------------------------------------- + virtual UP create() const = 0; + + virtual void clear() = 0; + + virtual void add(double) = 0; + + virtual double get() const = 0; + + virtual ~Aggregator() {} + }; + + struct MaxAggregator : Aggregator { + size_t count; + double value; + + MaxAggregator() : count(0), value(0.0) {} + + UP create() const override { return UP(new MaxAggregator()); } + + void clear() override { + count = 0; + value = 0.0; + } + + void add(double v) override { value = ((++count == 1) || (v > value)) ? v : value; } + + double get() const override { return value; } + }; + + struct AvgAggregator : Aggregator { + size_t count; + double value; + + AvgAggregator() : count(0), value(0.0) {} + + UP create() const override { return UP(new AvgAggregator()); } + + void clear() override { + count = 0; + value = 0.0; + } + + void add(double v) override { + ++count; + value += v; + } + + double get() const override { return (count == 0) ? 0.0 : (value / count); } + }; + + struct SumAggregator : Aggregator { + double value; -typedef double (*function_5)(double, double, double, double, double); -typedef std::pair<function_5, Aggregator::UP> OutputSpec; + SumAggregator() : value(0.0) {} + + UP create() const override { return UP(new SumAggregator()); } + + void clear() override { value = 0.0; } + + void add(double v) override { value += v; } + + double get() const override { return value; } + }; + + Aggregator::UP create_aggregator(const vespalib::string &name) { + if (name == "max") { + return Aggregator::UP(new MaxAggregator()); + } + if (name == "avg") { + return Aggregator::UP(new AvgAggregator()); + } + if (name == "sum") { + return Aggregator::UP(new SumAggregator()); + } + return Aggregator::UP(nullptr); + } //----------------------------------------------------------------------------- -struct VectorizedQueryTerms { - struct Term { - fef::TermFieldHandle handle; - int weight; - int index; - Term(fef::TermFieldHandle handle_in, int weight_in, int index_in) - : handle(handle_in), weight(weight_in), index(index_in) {} - }; + typedef double (*function_5)(double, double, double, double, double); + + typedef std::pair<function_5, Aggregator::UP> OutputSpec; + +//----------------------------------------------------------------------------- - std::vector<fef::TermFieldHandle> handles; - std::vector<int> weights; - int total_weight; - - VectorizedQueryTerms(const VectorizedQueryTerms &) = delete; - VectorizedQueryTerms(VectorizedQueryTerms &&rhs) - : handles(std::move(rhs.handles)), weights(std::move(rhs.weights)), total_weight(rhs.total_weight) {} - VectorizedQueryTerms(const fef::IQueryEnvironment &env, uint32_t field_id) - : handles(), weights(), total_weight(0) - { - std::vector<Term> terms; - for (uint32_t i = 0; i < env.getNumTerms(); ++i) { - const fef::ITermData *termData = env.getTerm(i); - if (termData->getWeight().percent() != 0) { // only consider query terms with contribution - typedef fef::ITermFieldRangeAdapter FRA; - for (FRA iter(*termData); iter.valid(); iter.next()) { - const fef::ITermFieldData &tfd = iter.get(); - if (tfd.getFieldId() == field_id) { - int term_weight = termData->getWeight().percent(); - total_weight += term_weight; - terms.push_back(Term(tfd.getHandle(), term_weight, - termData->getTermIndex())); + struct VectorizedQueryTerms { + struct Term { + fef::TermFieldHandle handle; + int weight; + int index; + + Term(fef::TermFieldHandle handle_in, int weight_in, int index_in) + : handle(handle_in), weight(weight_in), index(index_in) {} + }; + + std::vector<fef::TermFieldHandle> handles; + std::vector<int> weights; + int total_weight; + + VectorizedQueryTerms(const VectorizedQueryTerms &) = delete; + + VectorizedQueryTerms(VectorizedQueryTerms &&rhs) + : handles(std::move(rhs.handles)), weights(std::move(rhs.weights)), + total_weight(rhs.total_weight) {} + + VectorizedQueryTerms(const fef::IQueryEnvironment &env, uint32_t field_id) + : handles(), weights(), total_weight(0) { + std::vector<Term> terms; + for (uint32_t i = 0; i < env.getNumTerms(); ++i) { + const fef::ITermData *termData = env.getTerm(i); + if (termData->getWeight().percent() != 0) { // only consider query terms with contribution + typedef fef::ITermFieldRangeAdapter FRA; + for (FRA iter(*termData); iter.valid(); iter.next()) { + const fef::ITermFieldData &tfd = iter.get(); + if (tfd.getFieldId() == field_id) { + int term_weight = termData->getWeight().percent(); + total_weight += term_weight; + terms.push_back(Term(tfd.getHandle(), term_weight, + termData->getTermIndex())); + } + } } } + std::sort(terms.begin(), terms.end(), [](const Term &a, const Term &b) { return (a.index < b.index); }); + handles.reserve(terms.size()); + weights.reserve(terms.size()); + for (size_t i = 0; i < terms.size(); ++i) { + handles.push_back(terms[i].handle); + weights.push_back(terms[i].weight); + } } - } - std::sort(terms.begin(), terms.end(), [](const Term &a, const Term &b){ return (a.index < b.index); }); - handles.reserve(terms.size()); - weights.reserve(terms.size()); - for (size_t i = 0; i < terms.size(); ++i) { - handles.push_back(terms[i].handle); - weights.push_back(terms[i].weight); - } - } - ~VectorizedQueryTerms(); -}; -VectorizedQueryTerms::~VectorizedQueryTerms() { } + ~VectorizedQueryTerms(); + }; + + VectorizedQueryTerms::~VectorizedQueryTerms() {} //----------------------------------------------------------------------------- -struct State { - uint32_t element_length; - uint32_t matched_terms; - int sum_term_weight; - uint32_t last_pos; - double sum_proximity_score; - uint32_t last_idx; - uint32_t num_in_order; - - double proximity; - double order; - double query_coverage; - double field_coverage; - double element_weight; - - State(uint32_t element_length_in, int32_t element_weight_in, - uint32_t first_pos, int32_t first_weight, uint32_t first_idx) - : element_length(element_length_in), - matched_terms(1), sum_term_weight(first_weight), - last_pos(first_pos), sum_proximity_score(0.0), - last_idx(first_idx), num_in_order(0), - proximity(0.0), order(0.0), - query_coverage(0.0), field_coverage(0.0), - element_weight(element_weight_in) {} - - double proximity_score(uint32_t dist) { - return (dist > 8) ? 0 : (1.0 - (((dist-1)/8.0) * ((dist-1)/8.0))); - } + struct State { + uint32_t element_length; + uint32_t matched_terms; + int sum_term_weight; + uint32_t last_pos; + double sum_proximity_score; + uint32_t last_idx; + uint32_t num_in_order; + + double proximity; + double order; + double query_coverage; + double field_coverage; + double element_weight; + + State(uint32_t element_length_in, int32_t element_weight_in, + uint32_t first_pos, int32_t first_weight, uint32_t first_idx) + : element_length(element_length_in), + matched_terms(1), sum_term_weight(first_weight), + last_pos(first_pos), sum_proximity_score(0.0), + last_idx(first_idx), num_in_order(0), + proximity(0.0), order(0.0), + query_coverage(0.0), field_coverage(0.0), + element_weight(element_weight_in) {} + + double proximity_score(uint32_t dist) { + return (dist > 8) ? 0 : (1.0 - (((dist - 1) / 8.0) * ((dist - 1) / 8.0))); + } - bool want_match(uint32_t pos) { - return (pos > last_pos); - } + bool want_match(uint32_t pos) { + return (pos > last_pos); + } - void addMatch(uint32_t pos, int32_t weight, uint32_t idx) { - sum_proximity_score += proximity_score(pos - last_pos); - num_in_order += (idx > last_idx) ? 1 : 0; - last_pos = pos; - last_idx = idx; - ++matched_terms; - sum_term_weight += weight; - } + void addMatch(uint32_t pos, int32_t weight, uint32_t idx) { + sum_proximity_score += proximity_score(pos - last_pos); + num_in_order += (idx > last_idx) ? 1 : 0; + last_pos = pos; + last_idx = idx; + ++matched_terms; + sum_term_weight += weight; + } - void calculate_scores(size_t num_query_terms, int total_term_weight) { - double matches = std::min(element_length, matched_terms); - if (matches < 2) { - proximity = proximity_score(element_length); - order = (num_query_terms == 1) ? 1.0 : 0.0; - } else { - proximity = sum_proximity_score / (matches - 1); - order = num_in_order / (double) (matches - 1); - } - query_coverage = sum_term_weight / (double) total_term_weight; - field_coverage = matches / (double) element_length; - } -}; + void calculate_scores(size_t num_query_terms, int total_term_weight) { + double matches = std::min(element_length, matched_terms); + if (matches < 2) { + proximity = proximity_score(element_length); + order = (num_query_terms == 1) ? 1.0 : 0.0; + } else { + proximity = sum_proximity_score / (matches - 1); + order = num_in_order / (double) (matches - 1); + } + query_coverage = sum_term_weight / (double) total_term_weight; + field_coverage = matches / (double) element_length; + } + }; //----------------------------------------------------------------------------- -class ElementSimilarityExecutor : public fef::FeatureExecutor -{ -private: - typedef fef::TermFieldMatchData::PositionsIterator ITR; - - struct CmpPosition { - ITR *pos; - CmpPosition(ITR *pos_in) : pos(pos_in) {} - bool operator()(uint16_t a, uint16_t b) { - return (pos[a]->getPosition() == pos[b]->getPosition()) - ? (a < b) - : (pos[a]->getPosition() < pos[b]->getPosition()); - } - }; + class ElementSimilarityExecutor : public fef::FeatureExecutor { + private: + typedef fef::TermFieldMatchData::PositionsIterator ITR; - struct CmpElement { - ITR *pos; - CmpElement(ITR *pos_in) : pos(pos_in) {} - bool operator()(uint16_t a, uint16_t b) { - return pos[a]->getElementId() < pos[b]->getElementId(); - } - }; + struct CmpPosition { + ITR *pos; - typedef vespalib::PriorityQueue<uint16_t, CmpPosition> PositionQueue; - typedef vespalib::PriorityQueue<uint16_t, CmpElement> ElementQueue; - - VectorizedQueryTerms _terms; - std::vector<ITR> _pos; - std::vector<ITR> _end; - PositionQueue _position_queue; - ElementQueue _element_queue; - std::vector<OutputSpec> _outputs; - const fef::MatchData *_md; - -public: - ElementSimilarityExecutor(VectorizedQueryTerms &&terms, std::vector<OutputSpec> &&outputs_in) - : _terms(std::move(terms)), - _pos(_terms.handles.size(), nullptr), - _end(_terms.handles.size(), nullptr), - _position_queue(CmpPosition(&_pos[0])), - _element_queue(CmpElement(&_pos[0])), - _outputs(std::move(outputs_in)), - _md(nullptr) - {} - - bool isPure() override { return _terms.handles.empty(); } - - void handle_bind_match_data(const fef::MatchData &md) override { - _md = &md; - } + CmpPosition(ITR *pos_in) : pos(pos_in) {} - void requeue_term(uint16_t term, uint32_t element) { - while (_pos[term] != _end[term] && - _pos[term]->getElementId() == element) - { - ++_pos[term]; - } - if (_pos[term] != _end[term]) { - _element_queue.push(term); - } - } + bool operator()(uint16_t a, uint16_t b) { + return (pos[a]->getPosition() == pos[b]->getPosition()) + ? (a < b) + : (pos[a]->getPosition() < pos[b]->getPosition()); + } + }; - void execute(uint32_t docId) override { - for (auto &output: _outputs) { - output.second->clear(); - } - for (size_t i = 0; i < _terms.handles.size(); ++i) { - const fef::TermFieldMatchData *tfmd = _md->resolveTermField(_terms.handles[i]); - if (tfmd->getDocId() == docId) { - _pos[i] = tfmd->begin(); - _end[i] = tfmd->end(); - if (_pos[i] != _end[i]) { - _element_queue.push(i); + struct CmpElement { + ITR *pos; + + CmpElement(ITR *pos_in) : pos(pos_in) {} + + bool operator()(uint16_t a, uint16_t b) { + return pos[a]->getElementId() < pos[b]->getElementId(); } + }; + + typedef vespalib::PriorityQueue<uint16_t, CmpPosition> PositionQueue; + typedef vespalib::PriorityQueue<uint16_t, CmpElement> ElementQueue; + + VectorizedQueryTerms _terms; + std::vector<ITR> _pos; + std::vector<ITR> _end; + PositionQueue _position_queue; + ElementQueue _element_queue; + std::vector<OutputSpec> _outputs; + const fef::MatchData *_md; + + public: + ElementSimilarityExecutor(VectorizedQueryTerms &&terms, std::vector<OutputSpec> &&outputs_in) + : _terms(std::move(terms)), + _pos(_terms.handles.size(), nullptr), + _end(_terms.handles.size(), nullptr), + _position_queue(CmpPosition(&_pos[0])), + _element_queue(CmpElement(&_pos[0])), + _outputs(std::move(outputs_in)), + _md(nullptr) {} + + bool isPure() override { return _terms.handles.empty(); } + + void handle_bind_match_data(const fef::MatchData &md) override { + _md = &md; } - } - while (!_element_queue.empty()) { - uint32_t elementId = _pos[_element_queue.front()]->getElementId(); - while (!_element_queue.empty() && _pos[_element_queue.front()]->getElementId() == elementId) { - _position_queue.push(_element_queue.front()); - _element_queue.pop_front(); + + void requeue_term(uint16_t term, uint32_t element) { + while (_pos[term] != _end[term] && + _pos[term]->getElementId() == element) { + ++_pos[term]; + } + if (_pos[term] != _end[term]) { + _element_queue.push(term); + } } - uint16_t first = _position_queue.front(); - State state(_pos[first]->getElementLen(), - _pos[first]->getElementWeight(), - _pos[first]->getPosition(), - _terms.weights[first], - first); - requeue_term(_position_queue.front(), elementId); - _position_queue.pop_front(); - while (!_position_queue.empty()) { - uint16_t item = _position_queue.front(); - if (state.want_match(_pos[item]->getPosition())) { - state.addMatch(_pos[item]->getPosition(), - _terms.weights[item], - item); - requeue_term(_position_queue.front(), elementId); + + void execute(uint32_t docId) override { + for (auto &output: _outputs) { + output.second->clear(); + } + for (size_t i = 0; i < _terms.handles.size(); ++i) { + const fef::TermFieldMatchData *tfmd = _md->resolveTermField(_terms.handles[i]); + if (tfmd->getDocId() == docId) { + _pos[i] = tfmd->begin(); + _end[i] = tfmd->end(); + if (_pos[i] != _end[i]) { + _element_queue.push(i); + } + } + } + while (!_element_queue.empty()) { + uint32_t elementId = _pos[_element_queue.front()]->getElementId(); + while (!_element_queue.empty() && _pos[_element_queue.front()]->getElementId() == elementId) { + _position_queue.push(_element_queue.front()); + _element_queue.pop_front(); + } + uint16_t first = _position_queue.front(); + State state(_pos[first]->getElementLen(), + _pos[first]->getElementWeight(), + _pos[first]->getPosition(), + _terms.weights[first], + first); + requeue_term(_position_queue.front(), elementId); _position_queue.pop_front(); - } else { - ++_pos[item]; - if (_pos[item] == _end[item]) { - _position_queue.pop_front(); - } else { - _position_queue.adjust(); + while (!_position_queue.empty()) { + uint16_t item = _position_queue.front(); + if (state.want_match(_pos[item]->getPosition())) { + state.addMatch(_pos[item]->getPosition(), + _terms.weights[item], + item); + requeue_term(_position_queue.front(), elementId); + _position_queue.pop_front(); + } else { + ++_pos[item]; + if (_pos[item] == _end[item]) { + _position_queue.pop_front(); + } else { + _position_queue.adjust(); + } + } + } + state.calculate_scores(_terms.handles.size(), _terms.total_weight); + for (auto &output: _outputs) { + output.second->add(output.first(state.proximity, state.order, + state.query_coverage, state.field_coverage, + state.element_weight)); } } + for (size_t i = 0; i < _outputs.size(); ++i) { + outputs().set_number(i, _outputs[i].second->get()); + } } - state.calculate_scores(_terms.handles.size(), _terms.total_weight); - for (auto &output: _outputs) { - output.second->add(output.first(state.proximity, state.order, - state.query_coverage, state.field_coverage, - state.element_weight)); - } - } - for (size_t i = 0; i < _outputs.size(); ++i) { - outputs().set_number(i, _outputs[i].second->get()); - } - } -}; + }; //----------------------------------------------------------------------------- -std::vector<std::pair<vespalib::string, vespalib::string> > extract_properties(const fef::Properties &props, - const vespalib::string &ns, const vespalib::string &first_name, const vespalib::string &first_default) -{ - struct MyVisitor : fef::IPropertiesVisitor { - const vespalib::string &first_name; - std::vector<std::pair<vespalib::string, vespalib::string> > &result; - MyVisitor(const vespalib::string &first_name_in, - std::vector<std::pair<vespalib::string, vespalib::string> > &result_in) - : first_name(first_name_in), result(result_in) {} - virtual void visitProperty(const fef::Property::Value &key, - const fef::Property &values) override - { - if (key != first_name) { - result.emplace_back(key, values.get()); - } + std::vector<std::pair<vespalib::string, vespalib::string> > extract_properties(const fef::Properties &props, + const vespalib::string &ns, + const vespalib::string &first_name, + const vespalib::string &first_default) { + struct MyVisitor : fef::IPropertiesVisitor { + const vespalib::string &first_name; + std::vector<std::pair<vespalib::string, vespalib::string> > &result; + + MyVisitor(const vespalib::string &first_name_in, + std::vector<std::pair<vespalib::string, vespalib::string> > &result_in) + : first_name(first_name_in), result(result_in) {} + + virtual void visitProperty(const fef::Property::Value &key, + const fef::Property &values) override { + if (key != first_name) { + result.emplace_back(key, values.get()); + } + } + }; + std::vector<std::pair<vespalib::string, vespalib::string> > result; + result.emplace_back(first_name, props.lookup(ns, first_name).get(first_default)); + MyVisitor my_visitor(first_name, result); + props.visitNamespace(ns, my_visitor); + return result; } - }; - std::vector<std::pair<vespalib::string, vespalib::string> > result; - result.emplace_back(first_name, props.lookup(ns, first_name).get(first_default)); - MyVisitor my_visitor(first_name, result); - props.visitNamespace(ns, my_visitor); - return result; -} -std::vector<std::pair<vespalib::string, vespalib::string> > get_outputs(const fef::Properties &props, - const vespalib::string &feature) -{ - return extract_properties(props, feature + ".output", "default", "max((0.35*p+0.15*o+0.30*q+0.20*f)*w)"); -} + std::vector<std::pair<vespalib::string, vespalib::string> > get_outputs(const fef::Properties &props, + const vespalib::string &feature) { + return extract_properties(props, feature + ".output", "default", "max((0.35*p+0.15*o+0.30*q+0.20*f)*w)"); + } -} // namespace features::<unnamed> + } // namespace features::<unnamed> //----------------------------------------------------------------------------- -struct ElementSimilarityBlueprint::OutputContext { - vespalib::eval::CompileCache::Token::UP compile_token; - Aggregator::UP aggregator_factory; - OutputContext(const vespalib::eval::Function &function, - Aggregator::UP aggregator) - : compile_token(vespalib::eval::CompileCache::compile(function, vespalib::eval::PassParams::SEPARATE)), - aggregator_factory(std::move(aggregator)) {} -}; + struct ElementSimilarityBlueprint::OutputContext { + vespalib::eval::CompileCache::Token::UP compile_token; + Aggregator::UP aggregator_factory; + + OutputContext(const vespalib::eval::Function &function, + Aggregator::UP aggregator) + : compile_token(vespalib::eval::CompileCache::compile(function, vespalib::eval::PassParams::SEPARATE)), + aggregator_factory(std::move(aggregator)) {} + }; //----------------------------------------------------------------------------- -ElementSimilarityBlueprint::ElementSimilarityBlueprint() - : Blueprint("elementSimilarity"), _field_id(fef::IllegalHandle), _outputs() {} - -ElementSimilarityBlueprint::~ElementSimilarityBlueprint() {} - -void -ElementSimilarityBlueprint::visitDumpFeatures(const fef::IIndexEnvironment &env, - fef::IDumpFeatureVisitor &visitor) const -{ - for (uint32_t i = 0; i < env.getNumFields(); ++i) { - const fef::FieldInfo &field = *env.getField(i); - if ((field.type() == fef::FieldType::INDEX) && - (field.collection() != CollectionType::SINGLE) && - ( ! field.isFilter())) - { - fef::FeatureNameBuilder fnb; - fnb.baseName(getBaseName()).parameter(field.name()); - auto outputs = get_outputs(env.getProperties(), fnb.buildName()); - visitor.visitDumpFeature(fnb.output("").buildName()); - for (size_t out_idx = 1; out_idx < outputs.size(); ++out_idx) { - visitor.visitDumpFeature(fnb.output(outputs[out_idx].first).buildName()); + ElementSimilarityBlueprint::ElementSimilarityBlueprint() + : Blueprint("elementSimilarity"), _field_id(fef::IllegalHandle), _outputs() {} + + ElementSimilarityBlueprint::~ElementSimilarityBlueprint() {} + + void + ElementSimilarityBlueprint::visitDumpFeatures(const fef::IIndexEnvironment &env, + fef::IDumpFeatureVisitor &visitor) const { + for (uint32_t i = 0; i < env.getNumFields(); ++i) { + const fef::FieldInfo &field = *env.getField(i); + if ((field.type() == fef::FieldType::INDEX) && + (field.collection() != CollectionType::SINGLE) && + (!field.isFilter())) { + fef::FeatureNameBuilder fnb; + fnb.baseName(getBaseName()).parameter(field.name()); + auto outputs = get_outputs(env.getProperties(), fnb.buildName()); + visitor.visitDumpFeature(fnb.output("").buildName()); + for (size_t out_idx = 1; out_idx < outputs.size(); ++out_idx) { + visitor.visitDumpFeature(fnb.output(outputs[out_idx].first).buildName()); + } } } } -} -bool -ElementSimilarityBlueprint::setup(const fef::IIndexEnvironment &env, - const fef::ParameterList ¶ms) -{ - const fef::FieldInfo *field = params[0].asField(); - _field_id = field->id(); - fef::FeatureNameBuilder fnb; - fnb.baseName(getBaseName()).parameter(field->name()); - auto outputs = get_outputs(env.getProperties(), fnb.buildName()); - for (const auto &entry: outputs) { - describeOutput(entry.first, entry.second); - vespalib::string aggr_name; - vespalib::string expr; - vespalib::string error; - if (!vespalib::eval::Function::unwrap(entry.second, aggr_name, expr, error)) { - LOG(warning, "'%s': could not extract aggregator and expression for output '%s' from config value '%s' (%s)", - fnb.buildName().c_str(), entry.first.c_str(), entry.second.c_str(), error.c_str()); - return false; - } - Aggregator::UP aggr = create_aggregator(aggr_name); - if (aggr.get() == nullptr) { - LOG(warning, "'%s': unknown aggregator '%s'", fnb.buildName().c_str(), aggr_name.c_str()); - return false; - } - std::vector<vespalib::string> args({"p","o","q","f","w"}); - vespalib::eval::Function function = vespalib::eval::Function::parse(args, expr); - if (function.has_error()) { - LOG(warning, "'%s': per-element expression parse error: %s", - fnb.buildName().c_str(), function.get_error().c_str()); - return false; + bool + ElementSimilarityBlueprint::setup(const fef::IIndexEnvironment &env, + const fef::ParameterList ¶ms) { + const fef::FieldInfo *field = params[0].asField(); + _field_id = field->id(); + fef::FeatureNameBuilder fnb; + fnb.baseName(getBaseName()).parameter(field->name()); + auto outputs = get_outputs(env.getProperties(), fnb.buildName()); + for (const auto &entry: outputs) { + describeOutput(entry.first, entry.second); + vespalib::string aggr_name; + vespalib::string expr; + vespalib::string error; + if (!vespalib::eval::Function::unwrap(entry.second, aggr_name, expr, error)) { + LOG(warning, + "'%s': could not extract aggregator and expression for output '%s' from config value '%s' (%s)", + fnb.buildName().c_str(), entry.first.c_str(), entry.second.c_str(), error.c_str()); + return false; + } + Aggregator::UP aggr = create_aggregator(aggr_name); + if (aggr.get() == nullptr) { + LOG(warning, "'%s': unknown aggregator '%s'", fnb.buildName().c_str(), aggr_name.c_str()); + return false; + } + std::vector<vespalib::string> args({"p", "o", "q", "f", "w"}); + vespalib::eval::Function function = vespalib::eval::Function::parse(args, expr); + if (function.has_error()) { + LOG(warning, "'%s': per-element expression parse error: %s", + fnb.buildName().c_str(), function.get_error().c_str()); + return false; + } + _outputs.push_back(OutputContext_UP(new OutputContext(function, std::move(aggr)))); } - _outputs.push_back(OutputContext_UP(new OutputContext(function, std::move(aggr)))); + env.hintFieldAccess(field->id()); + return true; } - env.hintFieldAccess(field->id()); - return true; -} -fef::FeatureExecutor & -ElementSimilarityBlueprint::createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const -{ - std::vector<OutputSpec> output_specs; - for (const auto &output: _outputs) { - output_specs.emplace_back(output->compile_token->get().get_function<5>(), - output->aggregator_factory->create()); + fef::FeatureExecutor & + ElementSimilarityBlueprint::createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const { + std::vector<OutputSpec> output_specs; + for (const auto &output: _outputs) { + output_specs.emplace_back(output->compile_token->get().get_function<5>(), + output->aggregator_factory->create()); + } + return stash.create<ElementSimilarityExecutor>(VectorizedQueryTerms(env, _field_id), std::move(output_specs)); } - return stash.create<ElementSimilarityExecutor>(VectorizedQueryTerms(env, _field_id), std::move(output_specs)); -} //----------------------------------------------------------------------------- -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/element_similarity_feature.h b/searchlib/src/vespa/searchlib/features/element_similarity_feature.h index 658cb872750..1c07a28b5d9 100644 --- a/searchlib/src/vespa/searchlib/features/element_similarity_feature.h +++ b/searchlib/src/vespa/searchlib/features/element_similarity_feature.h @@ -2,11 +2,10 @@ #pragma once -#include <vespa/searchlib/fef/fef.h> +#include <vespa/searchlib/fef/blueprint.h> #include <vespa/vespalib/util/priority_queue.h> -namespace search { -namespace features { +namespace search::features { //----------------------------------------------------------------------------- @@ -34,8 +33,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; -//----------------------------------------------------------------------------- - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/euclidean_distance_feature.h b/searchlib/src/vespa/searchlib/features/euclidean_distance_feature.h index ba3f0b6da34..7825b286649 100644 --- a/searchlib/src/vespa/searchlib/features/euclidean_distance_feature.h +++ b/searchlib/src/vespa/searchlib/features/euclidean_distance_feature.h @@ -3,13 +3,9 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchcommon/attribute/attributecontent.h> - -namespace search { -namespace features { - +namespace search::features { /** * Implements the executor for the eucledian distance feature. @@ -31,7 +27,7 @@ private: public: EuclideanDistanceExecutor(const search::attribute::IAttributeVector &attribute, QueryVectorType vector); - virtual void execute(uint32_t docId) override; + void execute(uint32_t docId) override; }; @@ -57,7 +53,4 @@ public: }; - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/fieldinfofeature.h b/searchlib/src/vespa/searchlib/features/fieldinfofeature.h index 7ced5d5cb9f..f8d45d83af6 100644 --- a/searchlib/src/vespa/searchlib/features/fieldinfofeature.h +++ b/searchlib/src/vespa/searchlib/features/fieldinfofeature.h @@ -3,11 +3,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -#include <vespa/searchlib/common/feature.h> -namespace search { -namespace features { +namespace search::features { class IndexFieldInfoExecutor : public fef::FeatureExecutor { @@ -67,6 +64,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &queryEnv, vespalib::Stash &stash) const override; }; -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/fieldlengthfeature.h b/searchlib/src/vespa/searchlib/features/fieldlengthfeature.h index 4988bb97546..31b02b7d8fc 100644 --- a/searchlib/src/vespa/searchlib/features/fieldlengthfeature.h +++ b/searchlib/src/vespa/searchlib/features/fieldlengthfeature.h @@ -2,10 +2,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor for field length. @@ -15,7 +13,7 @@ private: std::vector<fef::TermFieldHandle> _fieldHandles; const fef::MatchData *_md; - virtual void handle_bind_match_data(const fef::MatchData &md) override; + void handle_bind_match_data(const fef::MatchData &md) override; public: /** @@ -48,5 +46,4 @@ public: bool setup(const fef::IIndexEnvironment & env, const fef::ParameterList & params) override; }; -}} - +} diff --git a/searchlib/src/vespa/searchlib/features/fieldmatchfeature.h b/searchlib/src/vespa/searchlib/features/fieldmatchfeature.h index 71ac1023df6..1f21364b294 100644 --- a/searchlib/src/vespa/searchlib/features/fieldmatchfeature.h +++ b/searchlib/src/vespa/searchlib/features/fieldmatchfeature.h @@ -2,12 +2,11 @@ #pragma once +#include <vespa/searchlib/fef/blueprint.h> #include <vespa/searchlib/features/fieldmatch/computer.h> #include <vespa/searchlib/features/fieldmatch/params.h> -#include <vespa/searchlib/fef/blueprint.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor for THE field match feature. @@ -52,6 +51,5 @@ public: bool setup(const fef::IIndexEnvironment & env, const fef::ParameterList & params) override; fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; - -} // namespace features -} // namespace search + +} diff --git a/searchlib/src/vespa/searchlib/features/fieldtermmatchfeature.h b/searchlib/src/vespa/searchlib/features/fieldtermmatchfeature.h index 0f89f7eeb75..c69014bb184 100644 --- a/searchlib/src/vespa/searchlib/features/fieldtermmatchfeature.h +++ b/searchlib/src/vespa/searchlib/features/fieldtermmatchfeature.h @@ -2,10 +2,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor for term feature. @@ -49,5 +47,4 @@ private: uint32_t _termId; }; -}} - +} diff --git a/searchlib/src/vespa/searchlib/features/firstphasefeature.h b/searchlib/src/vespa/searchlib/features/firstphasefeature.h index baf640d1492..5edd7a7ce0a 100644 --- a/searchlib/src/vespa/searchlib/features/firstphasefeature.h +++ b/searchlib/src/vespa/searchlib/features/firstphasefeature.h @@ -4,8 +4,7 @@ #include <vespa/searchlib/fef/blueprint.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor outputting the first phase ranking. @@ -33,6 +32,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/flow_completeness_feature.cpp b/searchlib/src/vespa/searchlib/features/flow_completeness_feature.cpp index c46d602983d..871c53221c8 100644 --- a/searchlib/src/vespa/searchlib/features/flow_completeness_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/flow_completeness_feature.cpp @@ -1,17 +1,20 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "flow_completeness_feature.h" +#include <vespa/searchlib/fef/itermdata.h> +#include <vespa/searchlib/fef/featurenamebuilder.h> +#include <vespa/searchlib/fef/properties.h> +#include <vespa/searchlib/fef/indexproperties.h> #include <vespa/vespalib/stllike/hash_map.h> #include <vespa/vespalib/locale/c.h> #include <vespa/log/log.h> LOG_SETUP(".features.flowcompleteness"); -namespace search { -namespace features { +namespace search::features { //----------------------------------------------------------------------------- -FlowCompletenessExecutor::FlowCompletenessExecutor(const search::fef::IQueryEnvironment &env, +FlowCompletenessExecutor::FlowCompletenessExecutor(const fef::IQueryEnvironment &env, const FlowCompletenessParams ¶ms) : _params(params), _terms(), @@ -20,13 +23,13 @@ FlowCompletenessExecutor::FlowCompletenessExecutor(const search::fef::IQueryEnvi { for (uint32_t i = 0; i < env.getNumTerms(); ++i) { LOG(spam, "consider term %u", i); - const search::fef::ITermData *termData = env.getTerm(i); + const fef::ITermData *termData = env.getTerm(i); LOG(spam, "term %u weight %u", i, termData->getWeight().percent()); if (termData->getWeight().percent() != 0) { // only consider query terms with contribution - typedef search::fef::ITermFieldRangeAdapter FRA; + typedef fef::ITermFieldRangeAdapter FRA; uint32_t j = 0; for (FRA iter(*termData); iter.valid(); iter.next()) { - const search::fef::ITermFieldData &tfd = iter.get(); + const fef::ITermFieldData &tfd = iter.get(); LOG(spam, "term %u field data %u for field id %u (my field id %u)", i, j++, tfd.getFieldId(), _params.fieldId); if (tfd.getFieldId() == _params.fieldId) { @@ -184,7 +187,7 @@ FlowCompletenessExecutor::execute(uint32_t) { assert(_queue.empty()); for (size_t i = 0; i < _terms.size(); ++i) { - const search::fef::TermFieldMatchData *tfmd = _md->resolveTermField(_terms[i].termHandle); + const fef::TermFieldMatchData *tfmd = _md->resolveTermField(_terms[i].termHandle); Item item(i, tfmd->begin(), tfmd->end()); LOG(spam, "found tfmd item with %zu positions", (item.end - item.pos)); if (item.pos != item.end) { @@ -255,15 +258,15 @@ FlowCompletenessBlueprint::FlowCompletenessBlueprint() } void -FlowCompletenessBlueprint::visitDumpFeatures(const search::fef::IIndexEnvironment &env, - search::fef::IDumpFeatureVisitor &visitor) const +FlowCompletenessBlueprint::visitDumpFeatures(const fef::IIndexEnvironment &env, + fef::IDumpFeatureVisitor &visitor) const { #ifdef notyet for (uint32_t i = 0; i < env.getNumFields(); ++i) { - const search::fef::FieldInfo &field = *env.getField(i); - if (field.type() == search::fef::FieldType::INDEX) { + const fef::FieldInfo &field = *env.getField(i); + if (field.type() == fef::FieldType::INDEX) { if (!field.isFilter()) { - search::fef::FeatureNameBuilder fnb; + fef::FeatureNameBuilder fnb; fnb.baseName(getBaseName()).parameter(field.name()); for (size_t out = 0; out < _output.size(); ++out) { visitor.visitDumpFeature(fnb.output(_output[out]).buildName()); @@ -277,25 +280,25 @@ FlowCompletenessBlueprint::visitDumpFeatures(const search::fef::IIndexEnvironmen #endif } -search::fef::Blueprint::UP +fef::Blueprint::UP FlowCompletenessBlueprint::createInstance() const { return Blueprint::UP(new FlowCompletenessBlueprint()); } bool -FlowCompletenessBlueprint::setup(const search::fef::IIndexEnvironment &env, - const search::fef::ParameterList ¶ms) +FlowCompletenessBlueprint::setup(const fef::IIndexEnvironment &env, + const fef::ParameterList ¶ms) { - const search::fef::FieldInfo *field = params[0].asField(); + const fef::FieldInfo *field = params[0].asField(); _params.fieldId = field->id(); - const search::fef::Properties &lst = env.getProperties(); - search::fef::Property obj = lst.lookup(getName(), "fieldCompletenessImportance"); + const fef::Properties &lst = env.getProperties(); + fef::Property obj = lst.lookup(getName(), "fieldCompletenessImportance"); if (obj.found()) { _params.fieldCompletenessImportance = vespalib::locale::c::atof(obj.get().c_str()); } - _params.fieldWeight = search::fef::indexproperties::FieldWeight::lookup(lst, field->name()); + _params.fieldWeight = fef::indexproperties::FieldWeight::lookup(lst, field->name()); describeOutput(_output[0], "combined completeness for best scored element"); describeOutput(_output[1], "best scored element completeness"); @@ -307,13 +310,12 @@ FlowCompletenessBlueprint::setup(const search::fef::IIndexEnvironment &env, return true; } -search::fef::FeatureExecutor & -FlowCompletenessBlueprint::createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const +fef::FeatureExecutor & +FlowCompletenessBlueprint::createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const { return stash.create<FlowCompletenessExecutor>(env, _params); } //----------------------------------------------------------------------------- -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/flow_completeness_feature.h b/searchlib/src/vespa/searchlib/features/flow_completeness_feature.h index db5c53beac8..cb3a71950ae 100644 --- a/searchlib/src/vespa/searchlib/features/flow_completeness_feature.h +++ b/searchlib/src/vespa/searchlib/features/flow_completeness_feature.h @@ -2,7 +2,7 @@ #pragma once -#include <vespa/searchlib/fef/fef.h> +#include <vespa/searchlib/fef/blueprint.h> #include <vespa/vespalib/util/priority_queue.h> namespace search::features { diff --git a/searchlib/src/vespa/searchlib/features/foreachfeature.h b/searchlib/src/vespa/searchlib/features/foreachfeature.h index 955724fb9c2..0eba4e36528 100644 --- a/searchlib/src/vespa/searchlib/features/foreachfeature.h +++ b/searchlib/src/vespa/searchlib/features/foreachfeature.h @@ -3,11 +3,9 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> #include <limits> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor for the foreach feature. @@ -163,7 +161,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/freshnessfeature.h b/searchlib/src/vespa/searchlib/features/freshnessfeature.h index e156cad53ed..1512a3255ad 100644 --- a/searchlib/src/vespa/searchlib/features/freshnessfeature.h +++ b/searchlib/src/vespa/searchlib/features/freshnessfeature.h @@ -4,10 +4,8 @@ #include "logarithmcalculator.h" #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor for the freshness feature. @@ -42,7 +40,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/item_raw_score_feature.h b/searchlib/src/vespa/searchlib/features/item_raw_score_feature.h index d6a55f29632..5bc7602e259 100644 --- a/searchlib/src/vespa/searchlib/features/item_raw_score_feature.h +++ b/searchlib/src/vespa/searchlib/features/item_raw_score_feature.h @@ -3,10 +3,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { class ItemRawScoreExecutor : public fef::FeatureExecutor { @@ -61,6 +59,4 @@ public: static HandleVector resolve(const fef::IQueryEnvironment &env, const vespalib::string &label); }; -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/jarowinklerdistancefeature.h b/searchlib/src/vespa/searchlib/features/jarowinklerdistancefeature.h index a8d6eacf0eb..3c3f00eda8e 100644 --- a/searchlib/src/vespa/searchlib/features/jarowinklerdistancefeature.h +++ b/searchlib/src/vespa/searchlib/features/jarowinklerdistancefeature.h @@ -2,11 +2,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -#include <vespa/searchlib/common/feature.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the necessary config to pass from the jaro winkler distance blueprint to the executor. @@ -68,5 +65,4 @@ private: JaroWinklerDistanceConfig _config; // The config for this blueprint. }; -}} - +} diff --git a/searchlib/src/vespa/searchlib/features/logarithmcalculator.h b/searchlib/src/vespa/searchlib/features/logarithmcalculator.h index d09f3a8e6ac..b223a6f2207 100644 --- a/searchlib/src/vespa/searchlib/features/logarithmcalculator.h +++ b/searchlib/src/vespa/searchlib/features/logarithmcalculator.h @@ -5,8 +5,7 @@ #include <vespa/searchlib/common/feature.h> #include <cmath> -namespace search { -namespace features { +namespace search::features { /** * This class is used to calculate a logarithmic-shaped function that goes from 1 to 0. @@ -57,6 +56,4 @@ public: } }; -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/matchcountfeature.h b/searchlib/src/vespa/searchlib/features/matchcountfeature.h index eadb5064c57..a81f4f084b8 100644 --- a/searchlib/src/vespa/searchlib/features/matchcountfeature.h +++ b/searchlib/src/vespa/searchlib/features/matchcountfeature.h @@ -3,10 +3,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor for the matchCount feature for index and @@ -18,7 +16,7 @@ private: std::vector<fef::TermFieldHandle> _handles; const fef::MatchData *_md; - virtual void handle_bind_match_data(const fef::MatchData &md) override; + void handle_bind_match_data(const fef::MatchData &md) override; public: MatchCountExecutor(uint32_t fieldId, const fef::IQueryEnvironment &env); @@ -54,6 +52,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/matchesfeature.h b/searchlib/src/vespa/searchlib/features/matchesfeature.h index c6366349dd9..53c6151a713 100644 --- a/searchlib/src/vespa/searchlib/features/matchesfeature.h +++ b/searchlib/src/vespa/searchlib/features/matchesfeature.h @@ -3,10 +3,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor for the matches feature for index and @@ -52,6 +50,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/matchfeature.h b/searchlib/src/vespa/searchlib/features/matchfeature.h index 64d931a08d8..de3205aa7a1 100644 --- a/searchlib/src/vespa/searchlib/features/matchfeature.h +++ b/searchlib/src/vespa/searchlib/features/matchfeature.h @@ -3,10 +3,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { struct MatchParams { MatchParams() : weights() {} @@ -45,7 +43,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/native_dot_product_feature.h b/searchlib/src/vespa/searchlib/features/native_dot_product_feature.h index 33c5c89c88b..0d7c75c7cf7 100644 --- a/searchlib/src/vespa/searchlib/features/native_dot_product_feature.h +++ b/searchlib/src/vespa/searchlib/features/native_dot_product_feature.h @@ -3,12 +3,10 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchlib/query/weight.h> #include <algorithm> -namespace search { -namespace features { +namespace search::features { class NativeDotProductExecutor : public fef::FeatureExecutor { @@ -44,6 +42,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/nativeattributematchfeature.h b/searchlib/src/vespa/searchlib/features/nativeattributematchfeature.h index e2c9dc7aef1..0f897c76fc4 100644 --- a/searchlib/src/vespa/searchlib/features/nativeattributematchfeature.h +++ b/searchlib/src/vespa/searchlib/features/nativeattributematchfeature.h @@ -7,8 +7,7 @@ #include <vespa/searchlib/fef/itermfielddata.h> #include <vespa/searchlib/fef/symmetrictable.h> -namespace search { -namespace features { +namespace search::features { /** * This struct contains parameters used by the executor. @@ -101,6 +100,4 @@ public: const NativeAttributeMatchParams & getParams() const { return _params; } }; - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/nativefieldmatchfeature.h b/searchlib/src/vespa/searchlib/features/nativefieldmatchfeature.h index cb676e5b775..539b64ced16 100644 --- a/searchlib/src/vespa/searchlib/features/nativefieldmatchfeature.h +++ b/searchlib/src/vespa/searchlib/features/nativefieldmatchfeature.h @@ -6,8 +6,7 @@ #include "queryterm.h" #include <vespa/fastos/dynamiclibrary.h> -namespace search { -namespace features { +namespace search::features { /** * This struct contains parameters used by the executor. @@ -114,7 +113,4 @@ public: const NativeFieldMatchParams & getParams() const { return _params; } }; - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/nativeproximityfeature.h b/searchlib/src/vespa/searchlib/features/nativeproximityfeature.h index f98fe2bfd22..13f2ea2dbcd 100644 --- a/searchlib/src/vespa/searchlib/features/nativeproximityfeature.h +++ b/searchlib/src/vespa/searchlib/features/nativeproximityfeature.h @@ -6,8 +6,7 @@ #include "queryterm.h" #include "termdistancecalculator.h" -namespace search { -namespace features { +namespace search::features { /** * This struct contains parameters used by the executor. @@ -98,7 +97,4 @@ public: const NativeProximityParams & getParams() const { return _params; } }; - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/nativerankfeature.h b/searchlib/src/vespa/searchlib/features/nativerankfeature.h index db43b7cf4f5..3b8ddccaa1d 100644 --- a/searchlib/src/vespa/searchlib/features/nativerankfeature.h +++ b/searchlib/src/vespa/searchlib/features/nativerankfeature.h @@ -3,12 +3,10 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchlib/fef/fieldtype.h> #include <vespa/searchlib/fef/table.h> -namespace search { -namespace features { +namespace search::features { /** * This struct contains parameters used by the nativeRank executor. @@ -116,6 +114,4 @@ public: static bool useTableNormalization(const fef::IIndexEnvironment & env); }; - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/nowfeature.h b/searchlib/src/vespa/searchlib/features/nowfeature.h index 867a8c15855..e9191689fb2 100644 --- a/searchlib/src/vespa/searchlib/features/nowfeature.h +++ b/searchlib/src/vespa/searchlib/features/nowfeature.h @@ -2,10 +2,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor for the 'now' feature. This executor returns the current @@ -43,5 +41,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; -}} - +} diff --git a/searchlib/src/vespa/searchlib/features/proximityfeature.h b/searchlib/src/vespa/searchlib/features/proximityfeature.h index 14a80628004..5cb8adaa287 100644 --- a/searchlib/src/vespa/searchlib/features/proximityfeature.h +++ b/searchlib/src/vespa/searchlib/features/proximityfeature.h @@ -2,10 +2,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the necessary config for proximity. @@ -62,4 +60,4 @@ private: ProximityConfig _config; }; -}} +} diff --git a/searchlib/src/vespa/searchlib/features/querycompletenessfeature.h b/searchlib/src/vespa/searchlib/features/querycompletenessfeature.h index a5e6bbdc2bb..3c0efdecf58 100644 --- a/searchlib/src/vespa/searchlib/features/querycompletenessfeature.h +++ b/searchlib/src/vespa/searchlib/features/querycompletenessfeature.h @@ -2,10 +2,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the necessary config for query completeness. @@ -63,5 +61,4 @@ private: QueryCompletenessConfig _config; }; -}} - +} diff --git a/searchlib/src/vespa/searchlib/features/queryfeature.h b/searchlib/src/vespa/searchlib/features/queryfeature.h index 779153437d4..0d4424db792 100644 --- a/searchlib/src/vespa/searchlib/features/queryfeature.h +++ b/searchlib/src/vespa/searchlib/features/queryfeature.h @@ -5,8 +5,7 @@ #include <vespa/searchlib/fef/blueprint.h> #include <vespa/eval/eval/value_type.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the blueprint for the query feature. @@ -34,6 +33,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/queryterm.cpp b/searchlib/src/vespa/searchlib/features/queryterm.cpp index 8b43df28178..84423493eb5 100644 --- a/searchlib/src/vespa/searchlib/features/queryterm.cpp +++ b/searchlib/src/vespa/searchlib/features/queryterm.cpp @@ -6,8 +6,7 @@ using namespace search::fef; using search::feature_t; -namespace search { -namespace features { +namespace search::features { QueryTerm::QueryTerm() : _termData(NULL), @@ -45,5 +44,4 @@ QueryTermFactory::create(const IQueryEnvironment & env, } -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/querytermcountfeature.h b/searchlib/src/vespa/searchlib/features/querytermcountfeature.h index 39b85756c07..f31fb1daf18 100644 --- a/searchlib/src/vespa/searchlib/features/querytermcountfeature.h +++ b/searchlib/src/vespa/searchlib/features/querytermcountfeature.h @@ -3,11 +3,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -#include <vespa/searchlib/common/feature.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the blueprint for the query term count feature. @@ -26,7 +23,4 @@ public: search::fef::FeatureExecutor &createExecutor(const search::fef::IQueryEnvironment & env, vespalib::Stash &stash) const override; }; - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/random_normal_feature.h b/searchlib/src/vespa/searchlib/features/random_normal_feature.h index adf3d3be63f..bf0aa66ea36 100644 --- a/searchlib/src/vespa/searchlib/features/random_normal_feature.h +++ b/searchlib/src/vespa/searchlib/features/random_normal_feature.h @@ -3,7 +3,6 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchlib/util/random_normal.h> namespace search::features { diff --git a/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.h b/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.h index ab9a53a2df3..6211999a4f6 100644 --- a/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.h +++ b/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.h @@ -3,7 +3,6 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchlib/util/random_normal.h> namespace search::features { diff --git a/searchlib/src/vespa/searchlib/features/randomfeature.h b/searchlib/src/vespa/searchlib/features/randomfeature.h index 8ed0e403836..8c94b71071f 100644 --- a/searchlib/src/vespa/searchlib/features/randomfeature.h +++ b/searchlib/src/vespa/searchlib/features/randomfeature.h @@ -3,7 +3,6 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchlib/util/rand48.h> namespace search::features { diff --git a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.h b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.h index 85514a4def7..8d5144206ea 100644 --- a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.h +++ b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.h @@ -2,7 +2,6 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/eval/eval/interpreted_function.h> #include <vespa/eval/eval/llvm/compile_cache.h> #include <vespa/searchlib/features/rankingexpression/expression_replacer.h> diff --git a/searchlib/src/vespa/searchlib/features/raw_score_feature.h b/searchlib/src/vespa/searchlib/features/raw_score_feature.h index db237f036c4..2a4eb946a68 100644 --- a/searchlib/src/vespa/searchlib/features/raw_score_feature.h +++ b/searchlib/src/vespa/searchlib/features/raw_score_feature.h @@ -3,7 +3,6 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> namespace search::features { diff --git a/searchlib/src/vespa/searchlib/features/reverseproximityfeature.h b/searchlib/src/vespa/searchlib/features/reverseproximityfeature.h index 776dde39f77..d06b6c57fe7 100644 --- a/searchlib/src/vespa/searchlib/features/reverseproximityfeature.h +++ b/searchlib/src/vespa/searchlib/features/reverseproximityfeature.h @@ -2,10 +2,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the necessary config for reverse proximity. @@ -59,5 +57,4 @@ private: ReverseProximityConfig _config; }; -}} - +} diff --git a/searchlib/src/vespa/searchlib/features/setup.cpp b/searchlib/src/vespa/searchlib/features/setup.cpp index 1d3c59f5b3d..a4a9689b971 100644 --- a/searchlib/src/vespa/searchlib/features/setup.cpp +++ b/searchlib/src/vespa/searchlib/features/setup.cpp @@ -54,15 +54,14 @@ #include "valuefeature.h" #include "constant_feature.h" -#include <vespa/searchlib/features/max_reduce_prod_join_replacer.h> +#include "max_reduce_prod_join_replacer.h" #include <vespa/searchlib/features/rankingexpression/expression_replacer.h> using search::fef::Blueprint; using search::features::rankingexpression::ListExpressionReplacer; using search::features::MaxReduceProdJoinReplacer; -namespace search { -namespace features { +namespace search::features { void setup_search_features(fef::IBlueprintRegistry & registry) { @@ -127,5 +126,4 @@ void setup_search_features(fef::IBlueprintRegistry & registry) registry.addPrototype(std::make_shared<RankingExpressionBlueprint>(std::move(replacers))); } -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/setup.h b/searchlib/src/vespa/searchlib/features/setup.h index 3c3057250bf..3904882c3a8 100644 --- a/searchlib/src/vespa/searchlib/features/setup.h +++ b/searchlib/src/vespa/searchlib/features/setup.h @@ -4,8 +4,7 @@ #include <vespa/searchlib/fef/blueprint.h> #include <vespa/searchlib/fef/iblueprintregistry.h> -namespace search { -namespace features { +namespace search::features { /** * Adds prototypes for all features in this library to the given registry. @@ -14,6 +13,4 @@ namespace features { **/ void setup_search_features(fef::IBlueprintRegistry & registry); -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/subqueries_feature.h b/searchlib/src/vespa/searchlib/features/subqueries_feature.h index 136d8d90f94..3a6be567548 100644 --- a/searchlib/src/vespa/searchlib/features/subqueries_feature.h +++ b/searchlib/src/vespa/searchlib/features/subqueries_feature.h @@ -3,10 +3,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { class SubqueriesExecutor : public fef::FeatureExecutor { std::vector<fef::TermFieldHandle> _handles; @@ -37,6 +35,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/tensor_attribute_executor.h b/searchlib/src/vespa/searchlib/features/tensor_attribute_executor.h index 3f981e06482..2b2e1e6e4f1 100644 --- a/searchlib/src/vespa/searchlib/features/tensor_attribute_executor.h +++ b/searchlib/src/vespa/searchlib/features/tensor_attribute_executor.h @@ -8,9 +8,8 @@ #include <vespa/vespalib/stllike/string.h> #include <vespa/eval/tensor/default_tensor.h> -namespace search { -namespace tensor { class ITensorAttribute; } -namespace features { +namespace search::tensor { class ITensorAttribute; } +namespace search::features { class TensorAttributeExecutor : public fef::FeatureExecutor { @@ -24,5 +23,4 @@ public: void execute(uint32_t docId) override; }; -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/tensor_factory_blueprint.h b/searchlib/src/vespa/searchlib/features/tensor_factory_blueprint.h index eb75b851bb9..c2b6534ae74 100644 --- a/searchlib/src/vespa/searchlib/features/tensor_factory_blueprint.h +++ b/searchlib/src/vespa/searchlib/features/tensor_factory_blueprint.h @@ -5,13 +5,12 @@ #include <vespa/searchlib/fef/blueprint.h> #include <vespa/vespalib/stllike/string.h> -namespace search { -namespace features { +namespace search::features { /** * Factory class for tensor rank features. */ -class TensorFactoryBlueprint : public search::fef::Blueprint +class TensorFactoryBlueprint : public fef::Blueprint { protected: static vespalib::string ATTRIBUTE_SOURCE; @@ -26,9 +25,8 @@ protected: ~TensorFactoryBlueprint(); public: - void visitDumpFeatures(const search::fef::IIndexEnvironment &, - search::fef::IDumpFeatureVisitor &) const override {} + void visitDumpFeatures(const fef::IIndexEnvironment &, + fef::IDumpFeatureVisitor &) const override {} }; -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/tensor_from_attribute_executor.h b/searchlib/src/vespa/searchlib/features/tensor_from_attribute_executor.h index f102749f1b6..4c5f64611c1 100644 --- a/searchlib/src/vespa/searchlib/features/tensor_from_attribute_executor.h +++ b/searchlib/src/vespa/searchlib/features/tensor_from_attribute_executor.h @@ -3,13 +3,11 @@ #pragma once #include <vespa/searchcommon/attribute/iattributevector.h> -#include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/eval/eval/value.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/eval/tensor/default_tensor.h> -namespace search { -namespace features { +namespace search::features { /** * Feature executor that extracts the content from an attribute vector @@ -52,5 +50,4 @@ TensorFromAttributeExecutor<WeightedBufferType>::execute(uint32_t docId) outputs().set_object(0, *_tensor); } -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.h b/searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.h index 4d06088bcff..e014b040eb1 100644 --- a/searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.h +++ b/searchlib/src/vespa/searchlib/features/tensor_from_labels_feature.h @@ -4,8 +4,7 @@ #include "tensor_factory_blueprint.h" -namespace search { -namespace features { +namespace search::features { /** * Blueprint for a rank feature that creates a tensor from an array @@ -18,18 +17,16 @@ class TensorFromLabelsBlueprint : public TensorFactoryBlueprint { public: TensorFromLabelsBlueprint(); - virtual search::fef::Blueprint::UP createInstance() const override { + fef::Blueprint::UP createInstance() const override { return Blueprint::UP(new TensorFromLabelsBlueprint()); } - virtual search::fef::ParameterDescriptions getDescriptions() const override { - return search::fef::ParameterDescriptions(). + fef::ParameterDescriptions getDescriptions() const override { + return fef::ParameterDescriptions(). desc().string(). desc().string().string(); } - virtual bool setup(const search::fef::IIndexEnvironment &env, - const search::fef::ParameterList ¶ms) override; - virtual search::fef::FeatureExecutor &createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; + bool setup(const fef::IIndexEnvironment &env, const fef::ParameterList ¶ms) override; + fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.h b/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.h index 5cae7f25476..367eab08076 100644 --- a/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.h +++ b/searchlib/src/vespa/searchlib/features/tensor_from_weighted_set_feature.h @@ -4,8 +4,7 @@ #include "tensor_factory_blueprint.h" -namespace search { -namespace features { +namespace search::features { /** * Feature blueprint for a rank feature that creates a tensor from a weighted set. @@ -15,18 +14,16 @@ class TensorFromWeightedSetBlueprint : public TensorFactoryBlueprint { public: TensorFromWeightedSetBlueprint(); - virtual search::fef::Blueprint::UP createInstance() const override { + fef::Blueprint::UP createInstance() const override { return Blueprint::UP(new TensorFromWeightedSetBlueprint()); } - virtual search::fef::ParameterDescriptions getDescriptions() const override { - return search::fef::ParameterDescriptions(). + fef::ParameterDescriptions getDescriptions() const override { + return fef::ParameterDescriptions(). desc().string(). desc().string().string(); } - virtual bool setup(const search::fef::IIndexEnvironment &env, - const search::fef::ParameterList ¶ms) override; - virtual search::fef::FeatureExecutor &createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; + bool setup(const fef::IIndexEnvironment &env, const fef::ParameterList ¶ms) override; + fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/term_field_md_feature.h b/searchlib/src/vespa/searchlib/features/term_field_md_feature.h index df9ab982dcb..fca101f85d4 100644 --- a/searchlib/src/vespa/searchlib/features/term_field_md_feature.h +++ b/searchlib/src/vespa/searchlib/features/term_field_md_feature.h @@ -3,13 +3,11 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchlib/fef/table.h> #include <vespa/searchlib/fef/itermdata.h> #include <vespa/searchlib/fef/itermfielddata.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor for looking at term field match data @@ -43,6 +41,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment & env, vespalib::Stash &stash) const override; }; - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/termdistancecalculator.h b/searchlib/src/vespa/searchlib/features/termdistancecalculator.h index ebda2b8daa1..e606e8666e3 100644 --- a/searchlib/src/vespa/searchlib/features/termdistancecalculator.h +++ b/searchlib/src/vespa/searchlib/features/termdistancecalculator.h @@ -4,14 +4,12 @@ #include "queryterm.h" -namespace search { - -namespace fef { +namespace search::fef { class TermFieldMatchData; class MatchData; } -namespace features { +namespace search::features { /** * This class is used to calculate the minimal forward and reverse term distance @@ -82,5 +80,4 @@ public: const fef::MatchData & match, uint32_t docId, Result & r); }; -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/termdistancefeature.h b/searchlib/src/vespa/searchlib/features/termdistancefeature.h index 8e153072bc2..276476de21b 100644 --- a/searchlib/src/vespa/searchlib/features/termdistancefeature.h +++ b/searchlib/src/vespa/searchlib/features/termdistancefeature.h @@ -3,12 +3,10 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchlib/fef/table.h> #include "termdistancecalculator.h" -namespace search { -namespace features { +namespace search::features { /** * This struct contains parameters used by the executor. @@ -59,6 +57,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/termeditdistancefeature.h b/searchlib/src/vespa/searchlib/features/termeditdistancefeature.h index ea5974495ea..6d5739c690f 100644 --- a/searchlib/src/vespa/searchlib/features/termeditdistancefeature.h +++ b/searchlib/src/vespa/searchlib/features/termeditdistancefeature.h @@ -2,8 +2,6 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -#include <vespa/searchlib/common/feature.h> namespace search::features { diff --git a/searchlib/src/vespa/searchlib/features/termfeature.h b/searchlib/src/vespa/searchlib/features/termfeature.h index 9821bb4eb69..cb1a8621795 100644 --- a/searchlib/src/vespa/searchlib/features/termfeature.h +++ b/searchlib/src/vespa/searchlib/features/termfeature.h @@ -2,11 +2,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -#include <vespa/searchlib/common/feature.h> -namespace search { -namespace features { +namespace search::features { /** * Implements the executor for term feature. @@ -47,4 +44,4 @@ private: uint32_t _termId; }; -}} +} diff --git a/searchlib/src/vespa/searchlib/features/terminfofeature.h b/searchlib/src/vespa/searchlib/features/terminfofeature.h index b05762972bf..0197e339e38 100644 --- a/searchlib/src/vespa/searchlib/features/terminfofeature.h +++ b/searchlib/src/vespa/searchlib/features/terminfofeature.h @@ -3,10 +3,8 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -namespace search { -namespace features { +namespace search::features { class TermInfoBlueprint : public fef::Blueprint { @@ -24,6 +22,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &queryEnv, vespalib::Stash &stash) const override; }; -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/text_similarity_feature.cpp b/searchlib/src/vespa/searchlib/features/text_similarity_feature.cpp index a50f042b552..c445241fe59 100644 --- a/searchlib/src/vespa/searchlib/features/text_similarity_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/text_similarity_feature.cpp @@ -1,20 +1,20 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "text_similarity_feature.h" +#include <vespa/searchlib/fef/itermdata.h> +#include <vespa/searchlib/fef/featurenamebuilder.h> -namespace search { +namespace search::features { using CollectionType = fef::FieldInfo::CollectionType; -namespace features { - namespace { struct Term { - search::fef::TermFieldHandle handle; + fef::TermFieldHandle handle; int weight; int index; - Term(search::fef::TermFieldHandle handle_in, int weight_in, int index_in) + Term(fef::TermFieldHandle handle_in, int weight_in, int index_in) : handle(handle_in), weight(weight_in), index(index_in) {} }; @@ -74,7 +74,7 @@ struct State { //----------------------------------------------------------------------------- -TextSimilarityExecutor::TextSimilarityExecutor(const search::fef::IQueryEnvironment &env, +TextSimilarityExecutor::TextSimilarityExecutor(const fef::IQueryEnvironment &env, uint32_t field_id) : _handles(), _weights(), @@ -84,11 +84,11 @@ TextSimilarityExecutor::TextSimilarityExecutor(const search::fef::IQueryEnvironm { std::vector<Term> terms; for (uint32_t i = 0; i < env.getNumTerms(); ++i) { - const search::fef::ITermData *termData = env.getTerm(i); + const fef::ITermData *termData = env.getTerm(i); if (termData->getWeight().percent() != 0) { // only consider query terms with contribution - typedef search::fef::ITermFieldRangeAdapter FRA; + typedef fef::ITermFieldRangeAdapter FRA; for (FRA iter(*termData); iter.valid(); iter.next()) { - const search::fef::ITermFieldData &tfd = iter.get(); + const fef::ITermFieldData &tfd = iter.get(); if (tfd.getFieldId() == field_id) { int term_weight = termData->getWeight().percent(); _total_term_weight += term_weight; @@ -175,14 +175,14 @@ TextSimilarityBlueprint::TextSimilarityBlueprint() : Blueprint("textSimilarity"), _field_id(fef::IllegalHandle) {} void -TextSimilarityBlueprint::visitDumpFeatures(const search::fef::IIndexEnvironment &env, - search::fef::IDumpFeatureVisitor &visitor) const +TextSimilarityBlueprint::visitDumpFeatures(const fef::IIndexEnvironment &env, + fef::IDumpFeatureVisitor &visitor) const { for (uint32_t i = 0; i < env.getNumFields(); ++i) { - const search::fef::FieldInfo &field = *env.getField(i); - if (field.type() == search::fef::FieldType::INDEX) { + const fef::FieldInfo &field = *env.getField(i); + if (field.type() == fef::FieldType::INDEX) { if (!field.isFilter() && field.collection() == CollectionType::SINGLE) { - search::fef::FeatureNameBuilder fnb; + fef::FeatureNameBuilder fnb; fnb.baseName(getBaseName()).parameter(field.name()); visitor.visitDumpFeature(fnb.output(score_output).buildName()); visitor.visitDumpFeature(fnb.output(proximity_output).buildName()); @@ -194,17 +194,17 @@ TextSimilarityBlueprint::visitDumpFeatures(const search::fef::IIndexEnvironment } } -search::fef::Blueprint::UP +fef::Blueprint::UP TextSimilarityBlueprint::createInstance() const { return Blueprint::UP(new TextSimilarityBlueprint()); } bool -TextSimilarityBlueprint::setup(const search::fef::IIndexEnvironment &env, - const search::fef::ParameterList ¶ms) +TextSimilarityBlueprint::setup(const fef::IIndexEnvironment &env, + const fef::ParameterList ¶ms) { - const search::fef::FieldInfo *field = params[0].asField(); + const fef::FieldInfo *field = params[0].asField(); _field_id = field->id(); describeOutput(score_output, "default normalized combination of other outputs"); describeOutput(proximity_output, "normalized match proximity score"); @@ -215,13 +215,12 @@ TextSimilarityBlueprint::setup(const search::fef::IIndexEnvironment &env, return true; } -search::fef::FeatureExecutor & -TextSimilarityBlueprint::createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const +fef::FeatureExecutor & +TextSimilarityBlueprint::createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const { return stash.create<TextSimilarityExecutor>(env, _field_id); } //----------------------------------------------------------------------------- -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/text_similarity_feature.h b/searchlib/src/vespa/searchlib/features/text_similarity_feature.h index a660f3e3e30..00406dc4993 100644 --- a/searchlib/src/vespa/searchlib/features/text_similarity_feature.h +++ b/searchlib/src/vespa/searchlib/features/text_similarity_feature.h @@ -2,11 +2,10 @@ #pragma once -#include <vespa/searchlib/fef/fef.h> +#include <vespa/searchlib/fef/blueprint.h> #include <vespa/vespalib/util/priority_queue.h> -namespace search { -namespace features { +namespace search::features { //----------------------------------------------------------------------------- @@ -67,8 +66,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; -//----------------------------------------------------------------------------- - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/utils.cpp b/searchlib/src/vespa/searchlib/features/utils.cpp index e87d356a074..86558e89ec9 100644 --- a/searchlib/src/vespa/searchlib/features/utils.cpp +++ b/searchlib/src/vespa/searchlib/features/utils.cpp @@ -2,9 +2,7 @@ #include "utils.hpp" -namespace search { -namespace features { -namespace util { +namespace search::features::util { template double strToNum<double>(vespalib::stringref str); template uint32_t strToNum<uint32_t>(vespalib::stringref str); @@ -12,7 +10,4 @@ template uint64_t strToNum<uint64_t>(vespalib::stringref str); template int32_t strToNum<int32_t>(vespalib::stringref str); template int64_t strToNum<int64_t>(vespalib::stringref str); -} // namespace util -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/utils.hpp b/searchlib/src/vespa/searchlib/features/utils.hpp index 1620d71e31e..7e6987ca14e 100644 --- a/searchlib/src/vespa/searchlib/features/utils.hpp +++ b/searchlib/src/vespa/searchlib/features/utils.hpp @@ -6,9 +6,7 @@ #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/exceptions.h> -namespace search { -namespace features { -namespace util { +namespace search::features::util { template <typename T> T strToNum(vespalib::stringref str) @@ -22,7 +20,5 @@ T strToNum(vespalib::stringref str) return retval; } -} // namespace util -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/valuefeature.h b/searchlib/src/vespa/searchlib/features/valuefeature.h index cb2d188d164..1cc6bd55bc1 100644 --- a/searchlib/src/vespa/searchlib/features/valuefeature.h +++ b/searchlib/src/vespa/searchlib/features/valuefeature.h @@ -3,12 +3,9 @@ #pragma once #include <vespa/searchlib/fef/blueprint.h> -#include <vespa/searchlib/fef/featureexecutor.h> -#include <vespa/searchlib/common/feature.h> #include <vector> -namespace search { -namespace features { +namespace search::features { class ValueExecutor : public fef::FeatureExecutor { @@ -51,6 +48,4 @@ public: fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &queryEnv, vespalib::Stash &stash) const override; }; -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/weighted_set_parser.h b/searchlib/src/vespa/searchlib/features/weighted_set_parser.h index 5a778ebf698..8eedd9d98b6 100644 --- a/searchlib/src/vespa/searchlib/features/weighted_set_parser.h +++ b/searchlib/src/vespa/searchlib/features/weighted_set_parser.h @@ -4,8 +4,7 @@ #include <vespa/vespalib/stllike/string.h> -namespace search { -namespace features { +namespace search::features { /** * Utility for parsing a string representation of a weighted set @@ -24,5 +23,4 @@ public: static void parse(const vespalib::string &input, OutputType &output); }; -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/weighted_set_parser.hpp b/searchlib/src/vespa/searchlib/features/weighted_set_parser.hpp index d67b089f5fe..1b3679bbf19 100644 --- a/searchlib/src/vespa/searchlib/features/weighted_set_parser.hpp +++ b/searchlib/src/vespa/searchlib/features/weighted_set_parser.hpp @@ -5,8 +5,7 @@ #include "weighted_set_parser.h" #include <vespa/vespalib/util/stringfmt.h> -namespace search { -namespace features { +namespace search::features { template <typename OutputType> void @@ -44,5 +43,4 @@ WeightedSetParser::parse(const vespalib::string &input, OutputType &output) } } -} // namespace features -} // namespace search +} |