diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-02-23 23:46:48 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-02-23 23:46:48 +0000 |
commit | d2c9bd6588e23b449c4b672bec023ddb535bc9ec (patch) | |
tree | 125cc501bdba4d13ed6e24b766fd6e71c46c22af | |
parent | 0d90251fe2dee64524836751b9d27dc71e3ab2e1 (diff) |
- Add debug logging.
- std::make_unique
- Reduce code visibility.
82 files changed, 307 insertions, 366 deletions
diff --git a/config/src/tests/trace/trace.cpp b/config/src/tests/trace/trace.cpp index 41c874eb1d4..9a355f39ecc 100644 --- a/config/src/tests/trace/trace.cpp +++ b/config/src/tests/trace/trace.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/config/common/trace.h> +#include <vespa/vespalib/data/slime/slime.h> using namespace config; diff --git a/config/src/vespa/config/common/configdefinition.cpp b/config/src/vespa/config/common/configdefinition.cpp index 861fc224867..92af068cff5 100644 --- a/config/src/vespa/config/common/configdefinition.cpp +++ b/config/src/vespa/config/common/configdefinition.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "configdefinition.h" #include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/data/slime/slime.h> using namespace vespalib; using namespace vespalib::slime; diff --git a/config/src/vespa/config/common/configdefinition.h b/config/src/vespa/config/common/configdefinition.h index 3d86e5d2567..9154f3ad88a 100644 --- a/config/src/vespa/config/common/configdefinition.h +++ b/config/src/vespa/config/common/configdefinition.h @@ -3,8 +3,11 @@ #include <vespa/vespalib/stllike/string.h> #include <vector> -#include <vespa/vespalib/data/slime/slime.h> +namespace vespalib::slime { + class Cursor; + class Inspector; +} namespace config { /** diff --git a/config/src/vespa/config/common/trace.cpp b/config/src/vespa/config/common/trace.cpp index d1bb154eda9..76310d08c7d 100644 --- a/config/src/vespa/config/common/trace.cpp +++ b/config/src/vespa/config/common/trace.cpp @@ -2,6 +2,7 @@ #include "trace.h" #include <vespa/vespalib/trace/slime_trace_serializer.h> #include <vespa/vespalib/trace/slime_trace_deserializer.h> +#include <vespa/vespalib/data/slime/slime.h> using namespace vespalib; using namespace vespalib::slime; diff --git a/config/src/vespa/config/common/trace.h b/config/src/vespa/config/common/trace.h index 772cdb6f31e..c120fe30d12 100644 --- a/config/src/vespa/config/common/trace.h +++ b/config/src/vespa/config/common/trace.h @@ -1,11 +1,14 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/trace/tracenode.h> #include <vespa/vespalib/stllike/string.h> -#include <memory> +#include <vespa/vespalib/data/memory.h> +namespace vespalib::slime { + class Cursor; + class Inspector; +} namespace config { /** diff --git a/eval/src/vespa/eval/eval/interpreted_function.cpp b/eval/src/vespa/eval/eval/interpreted_function.cpp index 0a630a3e20a..ec28604fd87 100644 --- a/eval/src/vespa/eval/eval/interpreted_function.cpp +++ b/eval/src/vespa/eval/eval/interpreted_function.cpp @@ -3,21 +3,16 @@ #include "interpreted_function.h" #include "node_visitor.h" #include "node_traverser.h" -#include "check_type.h" -#include "tensor_spec.h" -#include "operation.h" #include "tensor_nodes.h" #include "tensor_engine.h" +#include "make_tensor_function.h" +#include "compile_tensor_function.h" #include <vespa/vespalib/util/classname.h> #include <vespa/eval/eval/llvm/compile_cache.h> #include <vespa/vespalib/util/benchmark_timer.h> #include <set> -#include "make_tensor_function.h" -#include "compile_tensor_function.h" - -namespace vespalib { -namespace eval { +namespace vespalib::eval { namespace { @@ -42,11 +37,12 @@ InterpretedFunction::State::State(const TensorEngine &engine_in) params(nullptr), stash(), stack(), - program_offset(0) + program_offset(0), + if_cnt(0) { } -InterpretedFunction::State::~State() {} +InterpretedFunction::State::~State() = default; void InterpretedFunction::State::init(const LazyParams ¶ms_in) { @@ -82,7 +78,7 @@ InterpretedFunction::InterpretedFunction(const TensorEngine &engine, const nodes _program = compile_tensor_function(optimized, _stash); } -InterpretedFunction::~InterpretedFunction() {} +InterpretedFunction::~InterpretedFunction() = default; const Value & InterpretedFunction::eval(Context &ctx, const LazyParams ¶ms) const @@ -123,5 +119,4 @@ InterpretedFunction::detect_issues(const Function &function) return Function::Issues(std::move(checker.issues)); } -} // namespace vespalib::eval -} // namespace vespalib +} diff --git a/eval/src/vespa/eval/eval/interpreted_function.h b/eval/src/vespa/eval/eval/interpreted_function.h index e3e8d18b44f..e638ccffcea 100644 --- a/eval/src/vespa/eval/eval/interpreted_function.h +++ b/eval/src/vespa/eval/eval/interpreted_function.h @@ -7,8 +7,7 @@ #include "lazy_params.h" #include <vespa/vespalib/util/stash.h> -namespace vespalib { -namespace eval { +namespace vespalib::eval { namespace nodes { struct Node; } struct TensorEngine; @@ -107,5 +106,4 @@ public: static Function::Issues detect_issues(const Function &function); }; -} // namespace vespalib::eval -} // namespace vespalib +} diff --git a/eval/src/vespa/eval/eval/lazy_params.cpp b/eval/src/vespa/eval/eval/lazy_params.cpp index aec8cf78059..2c00c4c312b 100644 --- a/eval/src/vespa/eval/eval/lazy_params.cpp +++ b/eval/src/vespa/eval/eval/lazy_params.cpp @@ -1,19 +1,16 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "lazy_params.h" -#include <assert.h> +#include <vespa/vespalib/util/stash.h> +#include <cassert> namespace vespalib::eval { -LazyParams::~LazyParams() -{ -} +LazyParams::~LazyParams() = default; //----------------------------------------------------------------------------- -SimpleObjectParams::~SimpleObjectParams() -{ -} +SimpleObjectParams::~SimpleObjectParams() = default; const Value & SimpleObjectParams::resolve(size_t idx, Stash &) const @@ -24,9 +21,7 @@ SimpleObjectParams::resolve(size_t idx, Stash &) const //----------------------------------------------------------------------------- -SimpleParams::~SimpleParams() -{ -} +SimpleParams::~SimpleParams() = default; const Value & SimpleParams::resolve(size_t idx, Stash &stash) const diff --git a/eval/src/vespa/eval/eval/tensor_function.h b/eval/src/vespa/eval/eval/tensor_function.h index 4b862e9ec6a..55d27fb74ea 100644 --- a/eval/src/vespa/eval/eval/tensor_function.h +++ b/eval/src/vespa/eval/eval/tensor_function.h @@ -2,20 +2,17 @@ #pragma once -#include <memory> -#include <vector> -#include <variant> -#include <vespa/vespalib/stllike/asciistream.h> -#include <vespa/vespalib/stllike/string.h> -#include <vespa/vespalib/util/arrayref.h> -#include <vespa/vespalib/util/overload.h> #include "tensor_spec.h" #include "lazy_params.h" #include "value_type.h" #include "value.h" #include "aggr.h" - #include "interpreted_function.h" +#include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/stllike/string.h> +#include <vespa/vespalib/util/arrayref.h> +#include <vespa/vespalib/util/overload.h> +#include <variant> namespace vespalib { diff --git a/eval/src/vespa/eval/eval/value.h b/eval/src/vespa/eval/eval/value.h index 6701173bcd3..cad76c93c5c 100644 --- a/eval/src/vespa/eval/eval/value.h +++ b/eval/src/vespa/eval/eval/value.h @@ -2,13 +2,11 @@ #pragma once -#include <vespa/vespalib/stllike/string.h> -#include <memory> -#include <vespa/vespalib/util/stash.h> #include "value_type.h" +#include <vespa/vespalib/util/traits.h> +#include <memory> -namespace vespalib { -namespace eval { +namespace vespalib::eval { class Tensor; @@ -40,7 +38,6 @@ public: static const ValueType &double_type() { return _type; } }; -} // namespace vespalib::eval -} // namespace vespalib +} VESPA_CAN_SKIP_DESTRUCTION(::vespalib::eval::DoubleValue); diff --git a/fnet/src/tests/frt/values/values_test.cpp b/fnet/src/tests/frt/values/values_test.cpp index 5bc6b0e2dce..3b36e8989c1 100644 --- a/fnet/src/tests/frt/values/values_test.cpp +++ b/fnet/src/tests/frt/values/values_test.cpp @@ -3,6 +3,7 @@ #include <vespa/fnet/frt/values.h> #include <vespa/fnet/databuffer.h> #include <vespa/fnet/info.h> +#include <vespa/vespalib/util/stash.h> using vespalib::Stash; diff --git a/fnet/src/vespa/fnet/frt/rpcrequest.h b/fnet/src/vespa/fnet/frt/rpcrequest.h index cc871e7ac0c..eaa34a46b7a 100644 --- a/fnet/src/vespa/fnet/frt/rpcrequest.h +++ b/fnet/src/vespa/fnet/frt/rpcrequest.h @@ -5,6 +5,7 @@ #include "values.h" #include "error.h" #include <vespa/fnet/context.h> +#include <vespa/vespalib/util/stash.h> #include <atomic> class FNETConnection; diff --git a/fnet/src/vespa/fnet/frt/values.cpp b/fnet/src/vespa/fnet/frt/values.cpp index a5f59df19b2..3b37aa9a1bc 100644 --- a/fnet/src/vespa/fnet/frt/values.cpp +++ b/fnet/src/vespa/fnet/frt/values.cpp @@ -3,6 +3,7 @@ #include "values.h" #include <vespa/fnet/databuffer.h> #include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/stash.h> #include <cassert> static_assert(sizeof(uint8_t) == 1, "uint8_t must be 1 byte."); @@ -81,7 +82,7 @@ FRT_Values::FRT_Values(Stash &stash) _stash(stash) { } -FRT_Values::~FRT_Values() { } +FRT_Values::~FRT_Values() = default; LocalBlob::LocalBlob(const char *data, uint32_t len) : _data(Alloc::alloc(len)), @@ -294,7 +295,7 @@ FRT_Values::AddSharedData(FRT_ISharedBlob *blob) { } void -FRT_Values::AddData(vespalib::alloc::Alloc buf, uint32_t len) { +FRT_Values::AddData(vespalib::alloc::Alloc && buf, uint32_t len) { AddSharedData(&_stash.create<LocalBlob>(std::move(buf), len)); } diff --git a/fnet/src/vespa/fnet/frt/values.h b/fnet/src/vespa/fnet/frt/values.h index e00aec8423c..2aa7551c423 100644 --- a/fnet/src/vespa/fnet/frt/values.h +++ b/fnet/src/vespa/fnet/frt/values.h @@ -3,9 +3,10 @@ #pragma once #include "isharedblob.h" -#include <vespa/vespalib/util/stash.h> #include <cstring> +namespace vespalib { class Stash; } +namespace vespalib::alloc { class Alloc; } namespace fnet { char * copyString(char *dst, const char *src, size_t len); char * copyData(char *dst, const void *src, size_t len); @@ -216,7 +217,7 @@ public: char *AddString(uint32_t len); FRT_StringValue *AddStringArray(uint32_t len); void AddSharedData(FRT_ISharedBlob *blob); - void AddData(Alloc buf, uint32_t len); + void AddData(Alloc && buf, uint32_t len); void AddData(const char *buf, uint32_t len); char *AddData(uint32_t len); FRT_DataValue *AddDataArray(uint32_t len); diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp index 7c5e7584eed..0e80d31a063 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp @@ -35,7 +35,7 @@ namespace { struct WaitTimer { double &wait_time_s; vespalib::Timer wait_time; - WaitTimer(double &wait_time_s_in) + explicit WaitTimer(double &wait_time_s_in) : wait_time_s(wait_time_s_in), wait_time() { } void done() { diff --git a/searchlib/src/tests/rankingexpression/intrinsic_blueprint_adapter/intrinsic_blueprint_adapter_test.cpp b/searchlib/src/tests/rankingexpression/intrinsic_blueprint_adapter/intrinsic_blueprint_adapter_test.cpp index b10da86dd8c..861af3527ca 100644 --- a/searchlib/src/tests/rankingexpression/intrinsic_blueprint_adapter/intrinsic_blueprint_adapter_test.cpp +++ b/searchlib/src/tests/rankingexpression/intrinsic_blueprint_adapter/intrinsic_blueprint_adapter_test.cpp @@ -5,6 +5,7 @@ #include <vespa/searchlib/features/rankingexpression/intrinsic_blueprint_adapter.h> #include <vespa/searchlib/fef/test/indexenvironment.h> #include <vespa/searchlib/fef/test/queryenvironment.h> +#include <vespa/vespalib/util/stash.h> #include <set> using namespace search::features::rankingexpression; diff --git a/searchlib/src/vespa/searchlib/features/agefeature.cpp b/searchlib/src/vespa/searchlib/features/agefeature.cpp index 258648408f8..e93691e7241 100644 --- a/searchlib/src/vespa/searchlib/features/agefeature.cpp +++ b/searchlib/src/vespa/searchlib/features/agefeature.cpp @@ -4,6 +4,7 @@ #include "valuefeature.h" #include <vespa/searchlib/fef/featurenamebuilder.h> #include <vespa/searchlib/fef/matchdata.h> +#include <vespa/vespalib/util/stash.h> using search::attribute::IAttributeVector; @@ -18,20 +19,18 @@ AgeExecutor::AgeExecutor(const IAttributeVector *attribute) : _attribute(attribute), _buf() { - if (_attribute != NULL) { + if (_attribute != nullptr) { _buf.allocate(attribute->getMaxValueCount()); } } -AgeBlueprint::~AgeBlueprint() -{ -} +AgeBlueprint::~AgeBlueprint() = default; void AgeExecutor::execute(uint32_t docId) { feature_t age = 10000000000.0; - if (_attribute != NULL) { + if (_attribute != nullptr) { _buf.fill(*_attribute, docId); int64_t docTime = _buf[0]; feature_t currTime = inputs().get_number(0); @@ -65,7 +64,7 @@ AgeBlueprint::setup(const search::fef::IIndexEnvironment &env, search::fef::Blueprint::UP AgeBlueprint::createInstance() const { - return search::fef::Blueprint::UP(new AgeBlueprint()); + return std::make_unique<AgeBlueprint>(); } search::fef::FeatureExecutor & diff --git a/searchlib/src/vespa/searchlib/features/attributematchfeature.cpp b/searchlib/src/vespa/searchlib/features/attributematchfeature.cpp index 4776437a14b..c26d18eb11c 100644 --- a/searchlib/src/vespa/searchlib/features/attributematchfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/attributematchfeature.cpp @@ -8,6 +8,7 @@ #include <vespa/searchlib/fef/properties.h> #include <vespa/searchlib/fef/parameterdescriptions.h> #include <vespa/searchcommon/attribute/attributecontent.h> +#include <vespa/vespalib/util/stash.h> #include <vespa/log/log.h> LOG_SETUP(".features.attributematchfeature"); diff --git a/searchlib/src/vespa/searchlib/features/bm25_feature.cpp b/searchlib/src/vespa/searchlib/features/bm25_feature.cpp index e16b4bba996..64e365b25ac 100644 --- a/searchlib/src/vespa/searchlib/features/bm25_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/bm25_feature.cpp @@ -6,8 +6,8 @@ #include <vespa/searchlib/fef/itermfielddata.h> #include <vespa/searchlib/fef/objectstore.h> #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> #include <cmath> -#include <memory> #include <stdexcept> #include <vespa/log/log.h> diff --git a/searchlib/src/vespa/searchlib/features/closenessfeature.cpp b/searchlib/src/vespa/searchlib/features/closenessfeature.cpp index 2358e54e9f5..ccd76f5435f 100644 --- a/searchlib/src/vespa/searchlib/features/closenessfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/closenessfeature.cpp @@ -3,14 +3,14 @@ #include "closenessfeature.h" #include "utils.h" #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> #include <vespa/log/log.h> LOG_SETUP(".features.closenessfeature"); using namespace search::fef; -namespace search { -namespace features { +namespace search::features { ClosenessExecutor::ClosenessExecutor(feature_t maxDistance, feature_t scaleDistance) : FeatureExecutor(), @@ -96,7 +96,7 @@ ClosenessBlueprint::setup(const IIndexEnvironment & env, Blueprint::UP ClosenessBlueprint::createInstance() const { - return Blueprint::UP(new ClosenessBlueprint()); + return std::make_unique<ClosenessBlueprint>(); } FeatureExecutor & @@ -105,6 +105,4 @@ ClosenessBlueprint::createExecutor(const IQueryEnvironment &, vespalib::Stash &s return stash.create<ClosenessExecutor>(_maxDistance, _scaleDistance); } - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/constant_feature.cpp b/searchlib/src/vespa/searchlib/features/constant_feature.cpp index ced9d95fb33..7fc0c5c05fc 100644 --- a/searchlib/src/vespa/searchlib/features/constant_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/constant_feature.cpp @@ -4,14 +4,14 @@ #include "valuefeature.h" #include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/eval/eval/value_cache/constant_value.h> +#include <vespa/vespalib/util/stash.h> #include <vespa/log/log.h> LOG_SETUP(".features.constant_feature"); using namespace search::fef; -namespace search { -namespace features { +namespace search::features { /** * Feature executor that returns a constant value. @@ -25,8 +25,8 @@ public: ConstantFeatureExecutor(const vespalib::eval::Value &value) : _value(value) {} - 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, _value); } static FeatureExecutor &create(const vespalib::eval::Value &value, vespalib::Stash &stash) { @@ -41,9 +41,7 @@ ConstantBlueprint::ConstantBlueprint() { } -ConstantBlueprint::~ConstantBlueprint() -{ -} +ConstantBlueprint::~ConstantBlueprint() = default; void ConstantBlueprint::visitDumpFeatures(const IIndexEnvironment &, @@ -54,7 +52,7 @@ ConstantBlueprint::visitDumpFeatures(const IIndexEnvironment &, Blueprint::UP ConstantBlueprint::createInstance() const { - return Blueprint::UP(new ConstantBlueprint()); + return std::make_unique<ConstantBlueprint>(); } bool @@ -88,5 +86,4 @@ ConstantBlueprint::createExecutor(const IQueryEnvironment &env, vespalib::Stash } } -} // 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 2ab7b98fabe..785eb357795 100644 --- a/searchlib/src/vespa/searchlib/features/constant_tensor_executor.h +++ b/searchlib/src/vespa/searchlib/features/constant_tensor_executor.h @@ -7,7 +7,7 @@ #include <vespa/eval/eval/value.h> #include <vespa/eval/eval/value_type.h> #include <vespa/eval/tensor/default_tensor_engine.h> -#include <memory> +#include <vespa/vespalib/util/stash.h> namespace search::features { diff --git a/searchlib/src/vespa/searchlib/features/debug_attribute_wait.cpp b/searchlib/src/vespa/searchlib/features/debug_attribute_wait.cpp index 86a71184f43..8cc75a9a424 100644 --- a/searchlib/src/vespa/searchlib/features/debug_attribute_wait.cpp +++ b/searchlib/src/vespa/searchlib/features/debug_attribute_wait.cpp @@ -2,6 +2,8 @@ #include "debug_attribute_wait.h" #include <vespa/vespalib/util/time.h> +#include <vespa/vespalib/util/stash.h> + using search::attribute::IAttributeVector; using namespace search::fef; diff --git a/searchlib/src/vespa/searchlib/features/debug_wait.cpp b/searchlib/src/vespa/searchlib/features/debug_wait.cpp index fb002564572..57d19618ba4 100644 --- a/searchlib/src/vespa/searchlib/features/debug_wait.cpp +++ b/searchlib/src/vespa/searchlib/features/debug_wait.cpp @@ -2,6 +2,7 @@ #include "debug_wait.h" #include <vespa/vespalib/util/time.h> +#include <vespa/vespalib/util/stash.h> using namespace search::fef; diff --git a/searchlib/src/vespa/searchlib/features/distancefeature.cpp b/searchlib/src/vespa/searchlib/features/distancefeature.cpp index 501bfd7cd14..4d7d77fe315 100644 --- a/searchlib/src/vespa/searchlib/features/distancefeature.cpp +++ b/searchlib/src/vespa/searchlib/features/distancefeature.cpp @@ -5,6 +5,7 @@ #include <vespa/searchlib/fef/matchdata.h> #include <vespa/document/datatype/positiondatatype.h> #include <vespa/vespalib/geo/zcurve.h> +#include <vespa/vespalib/util/stash.h> #include <cmath> #include <limits> @@ -13,13 +14,12 @@ LOG_SETUP(".features.distancefeature"); using namespace search::fef; -namespace search { -namespace features { +namespace search::features { feature_t DistanceExecutor::calculateDistance(uint32_t docId) { - if (_location.isValid() && _pos != NULL) { + if (_location.isValid() && _pos != nullptr) { return calculate2DZDistance(docId); } return DEFAULT_DISTANCE; @@ -66,7 +66,7 @@ DistanceExecutor::DistanceExecutor(const Location & location, _pos(pos), _intBuf() { - if (_pos != NULL) { + if (_pos != nullptr) { _intBuf.allocate(_pos->getMaxValueCount()); } } @@ -86,9 +86,7 @@ DistanceBlueprint::DistanceBlueprint() : { } -DistanceBlueprint::~DistanceBlueprint() -{ -} +DistanceBlueprint::~DistanceBlueprint() = default; void DistanceBlueprint::visitDumpFeatures(const IIndexEnvironment &, @@ -99,7 +97,7 @@ DistanceBlueprint::visitDumpFeatures(const IIndexEnvironment &, Blueprint::UP DistanceBlueprint::createInstance() const { - return Blueprint::UP(new DistanceBlueprint()); + return std::make_unique<DistanceBlueprint>(); } bool @@ -116,26 +114,26 @@ DistanceBlueprint::setup(const IIndexEnvironment & env, FeatureExecutor & DistanceBlueprint::createExecutor(const IQueryEnvironment &env, vespalib::Stash &stash) const { - const search::attribute::IAttributeVector * pos = NULL; + const search::attribute::IAttributeVector * pos = nullptr; const Location & location = env.getLocation(); LOG(debug, "DistanceBlueprint::createExecutor location.valid='%s', '%s', alternatively '%s'", location.isValid() ? "true" : "false", _posAttr.c_str(), document::PositionDataType::getZCurveFieldName(_posAttr).c_str()); if (location.isValid()) { pos = env.getAttributeContext().getAttribute(_posAttr); - if (pos == NULL) { + if (pos == nullptr) { LOG(debug, "Failed to find attribute '%s', resorting too '%s'", _posAttr.c_str(), document::PositionDataType::getZCurveFieldName(_posAttr).c_str()); pos = env.getAttributeContext().getAttribute(document::PositionDataType::getZCurveFieldName(_posAttr)); } - if (pos != NULL) { + if (pos != nullptr) { if (!pos->isIntegerType()) { LOG(warning, "The position attribute '%s' is not an integer attribute. Will use default distance.", pos->getName().c_str()); - pos = NULL; + pos = nullptr; } else if (pos->getCollectionType() == attribute::CollectionType::WSET) { LOG(warning, "The position attribute '%s' is a weighted set attribute. Will use default distance.", pos->getName().c_str()); - pos = NULL; + pos = nullptr; } } else { LOG(warning, "The position attribute '%s' was not found. Will use default distance.", _posAttr.c_str()); @@ -145,7 +143,4 @@ DistanceBlueprint::createExecutor(const IQueryEnvironment &env, vespalib::Stash return stash.create<DistanceExecutor>(location, pos); } - - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/distancetopathfeature.cpp b/searchlib/src/vespa/searchlib/features/distancetopathfeature.cpp index 834f5913af9..a2f9225d3c4 100644 --- a/searchlib/src/vespa/searchlib/features/distancetopathfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/distancetopathfeature.cpp @@ -6,10 +6,10 @@ #include <vespa/searchlib/fef/properties.h> #include <vespa/document/datatype/positiondatatype.h> #include <vespa/vespalib/geo/zcurve.h> +#include <vespa/vespalib/util/stash.h> #include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/classification.hpp> #include <cmath> -#include <sstream> #include <vespa/log/log.h> LOG_SETUP(".features.distancetopathfeature"); @@ -25,7 +25,7 @@ DistanceToPathExecutor::DistanceToPathExecutor(std::vector<Vector2> &path, _path(), _pos(pos) { - if (_pos != NULL) { + if (_pos != nullptr) { _intBuf.allocate(_pos->getMaxValueCount()); } _path.swap(path); // avoid copy @@ -34,7 +34,7 @@ DistanceToPathExecutor::DistanceToPathExecutor(std::vector<Vector2> &path, void DistanceToPathExecutor::execute(uint32_t docId) { - if (_path.size() > 1 && _pos != NULL) { + if (_path.size() > 1 && _pos != nullptr) { double pos = -1, trip = 0, product = 0; double minSqDist = std::numeric_limits<double>::max(); _intBuf.fill(*_pos, docId); @@ -145,21 +145,21 @@ DistanceToPathBlueprint::createExecutor(const search::fef::IQueryEnvironment &en } // Lookup the attribute vector that holds document positions. - const search::attribute::IAttributeVector *pos = NULL; + const search::attribute::IAttributeVector *pos = nullptr; if (path.size() > 1) { pos = env.getAttributeContext().getAttribute(_posAttr); - if (pos == NULL) { + if (pos == nullptr) { pos = env.getAttributeContext().getAttribute(document::PositionDataType::getZCurveFieldName(_posAttr)); } - if (pos != NULL) { + if (pos != nullptr) { if (!pos->isIntegerType()) { LOG(warning, "The position attribute '%s' is not an integer attribute. Will use default distance.", pos->getName().c_str()); - pos = NULL; + pos = nullptr; } else if (pos->getCollectionType() == attribute::CollectionType::WSET) { LOG(warning, "The position attribute '%s' is a weighted set attribute. Will use default distance.", pos->getName().c_str()); - pos = NULL; + pos = nullptr; } } else { LOG(warning, "The position attribute '%s' was not found. Will use default distance.", _posAttr.c_str()); diff --git a/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp b/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp index 8998f01b59e..1072607aa8a 100644 --- a/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp @@ -10,12 +10,11 @@ #include <vespa/searchlib/attribute/floatbase.h> #include <vespa/searchlib/attribute/multinumericattribute.h> #include <vespa/searchlib/attribute/multienumattribute.h> -#include <type_traits> - -#include <vespa/log/log.h> #include <vespa/eval/tensor/serialization/typed_binary_format.h> #include <vespa/vespalib/objects/nbostream.h> +#include <vespa/vespalib/util/stash.h> +#include <vespa/log/log.h> LOG_SETUP(".features.dotproduct"); using namespace search::attribute; diff --git a/searchlib/src/vespa/searchlib/features/element_completeness_feature.cpp b/searchlib/src/vespa/searchlib/features/element_completeness_feature.cpp index 1622a87e733..1014fe4679a 100644 --- a/searchlib/src/vespa/searchlib/features/element_completeness_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/element_completeness_feature.cpp @@ -5,6 +5,7 @@ #include <vespa/searchlib/fef/featurenamebuilder.h> #include <vespa/searchlib/fef/properties.h> #include <vespa/vespalib/locale/c.h> +#include <vespa/vespalib/util/stash.h> #include <cassert> namespace search::features { @@ -116,7 +117,7 @@ ElementCompletenessBlueprint::visitDumpFeatures(const fef::IIndexEnvironment &en fef::Blueprint::UP ElementCompletenessBlueprint::createInstance() const { - return Blueprint::UP(new ElementCompletenessBlueprint()); + return std::make_unique<ElementCompletenessBlueprint>(); } bool diff --git a/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp b/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp index 0676b0a46c4..45fcd013fbf 100644 --- a/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/element_similarity_feature.cpp @@ -6,6 +6,7 @@ #include <vespa/searchlib/fef/properties.h> #include <vespa/eval/eval/llvm/compiled_function.h> #include <vespa/eval/eval/llvm/compile_cache.h> +#include <vespa/vespalib/util/stash.h> #include <vespa/log/log.h> LOG_SETUP(".features.elementsimilarity"); diff --git a/searchlib/src/vespa/searchlib/features/euclidean_distance_feature.cpp b/searchlib/src/vespa/searchlib/features/euclidean_distance_feature.cpp index cd007f1396f..9d71d358b46 100644 --- a/searchlib/src/vespa/searchlib/features/euclidean_distance_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/euclidean_distance_feature.cpp @@ -4,9 +4,9 @@ #include "euclidean_distance_feature.h" #include "array_parser.hpp" #include <vespa/searchlib/attribute/integerbase.h> -#include <vespa/searchlib/attribute/floatbase.h> #include <vespa/searchlib/fef/properties.h> #include <vespa/searchcommon/attribute/attributecontent.h> +#include <vespa/vespalib/util/stash.h> #include <cmath> #include <vespa/log/log.h> @@ -15,8 +15,7 @@ LOG_SETUP(".features.euclidean_distance_feature"); using namespace search::attribute; using namespace search::fef; -namespace search { -namespace features { +namespace search::features { template <typename DataType> @@ -57,7 +56,7 @@ EuclideanDistanceBlueprint::EuclideanDistanceBlueprint() : { } -EuclideanDistanceBlueprint::~EuclideanDistanceBlueprint() {} +EuclideanDistanceBlueprint::~EuclideanDistanceBlueprint() = default; void EuclideanDistanceBlueprint::visitDumpFeatures(const IIndexEnvironment &, IDumpFeatureVisitor &) const @@ -78,7 +77,7 @@ EuclideanDistanceBlueprint::setup(const IIndexEnvironment &env, const ParameterL Blueprint::UP EuclideanDistanceBlueprint::createInstance() const { - return Blueprint::UP(new EuclideanDistanceBlueprint()); + return std::make_unique<EuclideanDistanceBlueprint>(); } namespace { @@ -97,7 +96,7 @@ FeatureExecutor & EuclideanDistanceBlueprint::createExecutor(const IQueryEnvironment &env, vespalib::Stash &stash) const { const IAttributeVector * attribute = env.getAttributeContext().getAttribute(_attributeName); - if (attribute == NULL) { + if (attribute == nullptr) { LOG(warning, "The attribute vector '%s' was not found in the attribute manager, returning executor with default value.", _attributeName.c_str()); return stash.create<SingleZeroValueExecutor>(); @@ -118,6 +117,5 @@ EuclideanDistanceBlueprint::createExecutor(const IQueryEnvironment &env, vespali } -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/fieldinfofeature.cpp b/searchlib/src/vespa/searchlib/features/fieldinfofeature.cpp index d7e17187ff4..18a15ccf541 100644 --- a/searchlib/src/vespa/searchlib/features/fieldinfofeature.cpp +++ b/searchlib/src/vespa/searchlib/features/fieldinfofeature.cpp @@ -7,12 +7,11 @@ #include <vespa/searchlib/fef/fieldinfo.h> #include <vespa/searchlib/fef/fieldtype.h> #include <vespa/searchlib/fef/featurenamebuilder.h> -#include <vespa/searchlib/fef/itermdata.h> #include <vespa/searchlib/fef/handle.h> +#include <vespa/vespalib/util/stash.h> #include <sstream> -namespace search { -namespace features { +namespace search::features { IndexFieldInfoExecutor::IndexFieldInfoExecutor(feature_t type, feature_t isFilter, [[maybe_unused]] uint32_t field, uint32_t fieldHandle) @@ -238,5 +237,4 @@ FieldInfoBlueprint::createExecutor(const fef::IQueryEnvironment &queryEnv, vespa return stash.create<ValueExecutor>(values); } -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/fieldlengthfeature.cpp b/searchlib/src/vespa/searchlib/features/fieldlengthfeature.cpp index d0680e8fc19..74bfa156b5f 100644 --- a/searchlib/src/vespa/searchlib/features/fieldlengthfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/fieldlengthfeature.cpp @@ -6,13 +6,12 @@ #include <vespa/searchlib/fef/itermdata.h> #include <vespa/searchlib/fef/featurenamebuilder.h> #include <vespa/searchlib/fef/fieldinfo.h> -#include <vespa/searchlib/fef/fieldtype.h> -#include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/stash.h> + using namespace search::fef; -namespace search { -namespace features { +namespace search::features { FieldLengthExecutor:: FieldLengthExecutor(const IQueryEnvironment &env, @@ -63,7 +62,7 @@ FieldLengthExecutor::handle_bind_match_data(const MatchData &md) FieldLengthBlueprint::FieldLengthBlueprint() : Blueprint("fieldLength"), - _field(NULL) + _field(nullptr) { } @@ -86,7 +85,7 @@ FieldLengthBlueprint::setup(const IIndexEnvironment &env, Blueprint::UP FieldLengthBlueprint::createInstance() const { - return Blueprint::UP(new FieldLengthBlueprint()); + return std::make_unique<FieldLengthBlueprint>(); } FeatureExecutor & @@ -100,4 +99,4 @@ FieldLengthBlueprint::createExecutor(const IQueryEnvironment &env, vespalib::Sta return stash.create<FieldLengthExecutor>(env, _field->id()); } -}} +} diff --git a/searchlib/src/vespa/searchlib/features/fieldmatchfeature.cpp b/searchlib/src/vespa/searchlib/features/fieldmatchfeature.cpp index 583afa6e698..7ad9eef0506 100644 --- a/searchlib/src/vespa/searchlib/features/fieldmatchfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/fieldmatchfeature.cpp @@ -7,6 +7,7 @@ #include <vespa/searchlib/fef/properties.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/locale/c.h> +#include <vespa/vespalib/util/stash.h> using namespace search::fef; using CollectionType = FieldInfo::CollectionType; @@ -92,14 +93,12 @@ FieldMatchExecutor::handle_bind_match_data(const fef::MatchData &md) FieldMatchBlueprint::FieldMatchBlueprint() : Blueprint("fieldMatch"), - _field(NULL), + _field(nullptr), _params() { } -FieldMatchBlueprint::~FieldMatchBlueprint() -{ -} +FieldMatchBlueprint::~FieldMatchBlueprint() = default; void FieldMatchBlueprint::visitDumpFeatures(const IIndexEnvironment & env, @@ -158,7 +157,7 @@ FieldMatchBlueprint::visitDumpFeatures(const IIndexEnvironment & env, Blueprint::UP FieldMatchBlueprint::createInstance() const { - return Blueprint::UP(new FieldMatchBlueprint()); + return std::make_unique<FieldMatchBlueprint>(); } bool @@ -306,5 +305,4 @@ FieldMatchBlueprint::createExecutor(const IQueryEnvironment & env, vespalib::Sta return stash.create<FieldMatchExecutor>(env, *_field, _params); } - } diff --git a/searchlib/src/vespa/searchlib/features/fieldtermmatchfeature.cpp b/searchlib/src/vespa/searchlib/features/fieldtermmatchfeature.cpp index a7a00bee956..2f065fee289 100644 --- a/searchlib/src/vespa/searchlib/features/fieldtermmatchfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/fieldtermmatchfeature.cpp @@ -8,9 +8,10 @@ #include <vespa/searchlib/fef/properties.h> #include <vespa/searchlib/fef/itermdata.h> #include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/stash.h> -namespace search { -namespace features { + +namespace search::features { FieldTermMatchExecutor::FieldTermMatchExecutor(const search::fef::IQueryEnvironment &env, uint32_t fieldId, uint32_t termId) : @@ -122,7 +123,7 @@ FieldTermMatchBlueprint::setup(const search::fef::IIndexEnvironment &env, search::fef::Blueprint::UP FieldTermMatchBlueprint::createInstance() const { - return search::fef::Blueprint::UP(new FieldTermMatchBlueprint()); + return std::make_unique<FieldTermMatchBlueprint>(); } search::fef::FeatureExecutor & @@ -131,4 +132,4 @@ FieldTermMatchBlueprint::createExecutor(const search::fef::IQueryEnvironment &en return stash.create<FieldTermMatchExecutor>(env, _fieldId, _termId); } -}} +} diff --git a/searchlib/src/vespa/searchlib/features/firstphasefeature.cpp b/searchlib/src/vespa/searchlib/features/firstphasefeature.cpp index 2e6bae14a44..9d1831c6102 100644 --- a/searchlib/src/vespa/searchlib/features/firstphasefeature.cpp +++ b/searchlib/src/vespa/searchlib/features/firstphasefeature.cpp @@ -4,11 +4,12 @@ #include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchlib/fef/indexproperties.h> #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> + using namespace search::fef; -namespace search { -namespace features { +namespace search::features { void FirstPhaseExecutor::execute(uint32_t) @@ -34,7 +35,7 @@ FirstPhaseBlueprint::visitDumpFeatures(const IIndexEnvironment &, Blueprint::UP FirstPhaseBlueprint::createInstance() const { - return Blueprint::UP(new FirstPhaseBlueprint()); + return std::make_unique<FirstPhaseBlueprint>(); } bool @@ -54,5 +55,4 @@ FirstPhaseBlueprint::createExecutor(const IQueryEnvironment &, vespalib::Stash & } -} // 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 eda83b991bf..e43faaec4e1 100644 --- a/searchlib/src/vespa/searchlib/features/flow_completeness_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/flow_completeness_feature.cpp @@ -7,6 +7,8 @@ #include <vespa/searchlib/fef/indexproperties.h> #include <vespa/vespalib/stllike/hash_map.h> #include <vespa/vespalib/locale/c.h> +#include <vespa/vespalib/util/stash.h> + #include <cassert> #include <vespa/log/log.h> @@ -285,7 +287,7 @@ FlowCompletenessBlueprint::visitDumpFeatures(const fef::IIndexEnvironment &env, fef::Blueprint::UP FlowCompletenessBlueprint::createInstance() const { - return Blueprint::UP(new FlowCompletenessBlueprint()); + return std::make_unique<FlowCompletenessBlueprint>(); } bool @@ -318,6 +320,4 @@ FlowCompletenessBlueprint::createExecutor(const fef::IQueryEnvironment &env, ves return stash.create<FlowCompletenessExecutor>(env, _params); } -//----------------------------------------------------------------------------- - } diff --git a/searchlib/src/vespa/searchlib/features/foreachfeature.cpp b/searchlib/src/vespa/searchlib/features/foreachfeature.cpp index a67d8001a36..21167dd23d4 100644 --- a/searchlib/src/vespa/searchlib/features/foreachfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/foreachfeature.cpp @@ -6,6 +6,7 @@ #include <vespa/searchlib/fef/properties.h> #include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/stash.h> #include <boost/algorithm/string/replace.hpp> #include <vespa/log/log.h> @@ -120,9 +121,7 @@ ForeachBlueprint::ForeachBlueprint() : { } -ForeachBlueprint::~ForeachBlueprint() -{ -} +ForeachBlueprint::~ForeachBlueprint() = default; void ForeachBlueprint::visitDumpFeatures(const IIndexEnvironment &, @@ -171,13 +170,13 @@ ForeachBlueprint::setup(const IIndexEnvironment & env, Blueprint::UP ForeachBlueprint::createInstance() const { - return Blueprint::UP(new ForeachBlueprint()); + return std::make_unique<ForeachBlueprint>(); } FeatureExecutor & ForeachBlueprint::createExecutor(const IQueryEnvironment &, vespalib::Stash &stash) const { - if (_executorCreator.get() != NULL) { + if (_executorCreator) { return _executorCreator->create(_num_inputs, stash); } return stash.create<SingleZeroValueExecutor>(); diff --git a/searchlib/src/vespa/searchlib/features/freshnessfeature.cpp b/searchlib/src/vespa/searchlib/features/freshnessfeature.cpp index 11ae8305e16..6e621f61034 100644 --- a/searchlib/src/vespa/searchlib/features/freshnessfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/freshnessfeature.cpp @@ -3,14 +3,14 @@ #include "freshnessfeature.h" #include "utils.h" #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> #include <vespa/log/log.h> LOG_SETUP(".features.freshnessfeature"); using namespace search::fef; -namespace search { -namespace features { +namespace search::features { FreshnessExecutor::FreshnessExecutor(feature_t maxAge, feature_t scaleAge) : FeatureExecutor(), @@ -86,7 +86,7 @@ FreshnessBlueprint::setup(const IIndexEnvironment & env, Blueprint::UP FreshnessBlueprint::createInstance() const { - return Blueprint::UP(new FreshnessBlueprint()); + return std::make_unique<FreshnessBlueprint>(); } fef::ParameterDescriptions @@ -101,7 +101,4 @@ FreshnessBlueprint::createExecutor(const IQueryEnvironment &, vespalib::Stash &s return stash.create<FreshnessExecutor>(_maxAge, _scaleAge); } - -} // namespace features -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/features/internal_max_reduce_prod_join_feature.cpp b/searchlib/src/vespa/searchlib/features/internal_max_reduce_prod_join_feature.cpp index fd1faeae5ea..e2e8a206099 100644 --- a/searchlib/src/vespa/searchlib/features/internal_max_reduce_prod_join_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/internal_max_reduce_prod_join_feature.cpp @@ -5,12 +5,13 @@ #include "weighted_set_parser.h" #include "dotproductfeature.h" -#include <vespa/searchlib/attribute/attribute.h> #include <vespa/searchlib/attribute/imported_attribute_vector_read_guard.h> #include <vespa/searchlib/attribute/multinumericattribute.h> #include <vespa/searchlib/fef/properties.h> #include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchcommon/common/datatype.h> +#include <vespa/vespalib/util/stash.h> + #include <vespa/log/log.h> LOG_SETUP(".features.internalmaxreduceprodjoin"); diff --git a/searchlib/src/vespa/searchlib/features/item_raw_score_feature.cpp b/searchlib/src/vespa/searchlib/features/item_raw_score_feature.cpp index 45baf646656..89f7751a369 100644 --- a/searchlib/src/vespa/searchlib/features/item_raw_score_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/item_raw_score_feature.cpp @@ -3,11 +3,11 @@ #include "item_raw_score_feature.h" #include "valuefeature.h" #include "utils.h" +#include <vespa/vespalib/util/stash.h> using namespace search::fef; -namespace search { -namespace features { +namespace search::features { void ItemRawScoreExecutor::execute(uint32_t docId) @@ -89,6 +89,4 @@ ItemRawScoreBlueprint::resolve(const IQueryEnvironment &env, return handles; } - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/jarowinklerdistancefeature.cpp b/searchlib/src/vespa/searchlib/features/jarowinklerdistancefeature.cpp index a5e3e2da5ba..dc689459ff3 100644 --- a/searchlib/src/vespa/searchlib/features/jarowinklerdistancefeature.cpp +++ b/searchlib/src/vespa/searchlib/features/jarowinklerdistancefeature.cpp @@ -6,6 +6,8 @@ #include <vespa/searchlib/fef/properties.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/locale/c.h> +#include <vespa/vespalib/util/stash.h> + namespace search::features { @@ -168,7 +170,7 @@ JaroWinklerDistanceBlueprint::setup(const search::fef::IIndexEnvironment &env, search::fef::Blueprint::UP JaroWinklerDistanceBlueprint::createInstance() const { - return search::fef::Blueprint::UP(new JaroWinklerDistanceBlueprint()); + return std::make_unique<JaroWinklerDistanceBlueprint>(); } search::fef::FeatureExecutor & diff --git a/searchlib/src/vespa/searchlib/features/matchcountfeature.cpp b/searchlib/src/vespa/searchlib/features/matchcountfeature.cpp index fd453e17eb1..c061ace4854 100644 --- a/searchlib/src/vespa/searchlib/features/matchcountfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/matchcountfeature.cpp @@ -3,11 +3,11 @@ #include "matchcountfeature.h" #include "utils.h" #include "valuefeature.h" +#include <vespa/vespalib/util/stash.h> using namespace search::fef; -namespace search { -namespace features { +namespace search::features { MatchCountExecutor::MatchCountExecutor(uint32_t fieldId, const IQueryEnvironment &env) : FeatureExecutor(), @@ -43,7 +43,7 @@ MatchCountExecutor::handle_bind_match_data(const MatchData &md) MatchCountBlueprint::MatchCountBlueprint() : Blueprint("matchCount"), - _field(NULL) + _field(nullptr) { } @@ -63,7 +63,7 @@ MatchCountBlueprint::setup(const IIndexEnvironment &, const ParameterList & para Blueprint::UP MatchCountBlueprint::createInstance() const { - return Blueprint::UP(new MatchCountBlueprint()); + return std::make_unique<MatchCountBlueprint>(); } FeatureExecutor & @@ -75,5 +75,4 @@ MatchCountBlueprint::createExecutor(const IQueryEnvironment & queryEnv, vespalib return stash.create<MatchCountExecutor>(_field->id(), queryEnv); } -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/matchesfeature.cpp b/searchlib/src/vespa/searchlib/features/matchesfeature.cpp index f4788ee74c8..a99c2330ee3 100644 --- a/searchlib/src/vespa/searchlib/features/matchesfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/matchesfeature.cpp @@ -4,11 +4,12 @@ #include "utils.h" #include "valuefeature.h" #include <vespa/searchlib/fef/fieldinfo.h> +#include <vespa/vespalib/util/stash.h> + using namespace search::fef; -namespace search { -namespace features { +namespace search::features { MatchesExecutor::MatchesExecutor(uint32_t fieldId, const search::fef::IQueryEnvironment &env, @@ -47,7 +48,7 @@ MatchesExecutor::handle_bind_match_data(const MatchData &md) MatchesBlueprint::MatchesBlueprint() : Blueprint("matches"), - _field(NULL), + _field(nullptr), _termIdx(std::numeric_limits<uint32_t>::max()) { } @@ -73,7 +74,7 @@ MatchesBlueprint::setup(const IIndexEnvironment &, Blueprint::UP MatchesBlueprint::createInstance() const { - return Blueprint::UP(new MatchesBlueprint()); + return std::make_unique<MatchesBlueprint>(); } FeatureExecutor & @@ -89,5 +90,4 @@ MatchesBlueprint::createExecutor(const IQueryEnvironment & queryEnv, vespalib::S } } -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/matchfeature.cpp b/searchlib/src/vespa/searchlib/features/matchfeature.cpp index 7210b8b67e9..f6843df1a2f 100644 --- a/searchlib/src/vespa/searchlib/features/matchfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/matchfeature.cpp @@ -2,17 +2,16 @@ #include "matchfeature.h" #include "utils.h" -#include <vespa/searchlib/fef/featurenamebuilder.h> #include <vespa/searchlib/fef/fieldinfo.h> #include <vespa/searchlib/fef/indexproperties.h> #include <vespa/searchlib/fef/properties.h> -#include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/stash.h> + using namespace search::fef; using CollectionType = FieldInfo::CollectionType; -namespace search { -namespace features { +namespace search::features { MatchExecutor::MatchExecutor(const MatchParams & params) : FeatureExecutor(), @@ -46,9 +45,7 @@ MatchBlueprint::MatchBlueprint() : { } -MatchBlueprint::~MatchBlueprint() -{ -} +MatchBlueprint::~MatchBlueprint() = default; void MatchBlueprint::visitDumpFeatures(const IIndexEnvironment & env, @@ -61,7 +58,7 @@ MatchBlueprint::visitDumpFeatures(const IIndexEnvironment & env, Blueprint::UP MatchBlueprint::createInstance() const { - return Blueprint::UP(new MatchBlueprint()); + return std::make_unique<MatchBlueprint>(); } bool @@ -101,6 +98,4 @@ MatchBlueprint::createExecutor(const IQueryEnvironment &env, vespalib::Stash &st return stash.create<MatchExecutor>(_params); } - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/native_dot_product_feature.cpp b/searchlib/src/vespa/searchlib/features/native_dot_product_feature.cpp index 7865e32849f..5ede14130ec 100644 --- a/searchlib/src/vespa/searchlib/features/native_dot_product_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/native_dot_product_feature.cpp @@ -2,11 +2,11 @@ #include "native_dot_product_feature.h" #include "utils.h" +#include <vespa/vespalib/util/stash.h> using namespace search::fef; -namespace search { -namespace features { +namespace search::features { NativeDotProductExecutor::NativeDotProductExecutor(const search::fef::IQueryEnvironment &env) : FeatureExecutor(), @@ -80,5 +80,4 @@ NativeDotProductBlueprint::createExecutor(const IQueryEnvironment &queryEnv, ves } } -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/nativeattributematchfeature.cpp b/searchlib/src/vespa/searchlib/features/nativeattributematchfeature.cpp index 5dda159f629..865ea9fc3c4 100644 --- a/searchlib/src/vespa/searchlib/features/nativeattributematchfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/nativeattributematchfeature.cpp @@ -7,11 +7,11 @@ #include <vespa/searchlib/fef/indexproperties.h> #include <vespa/searchlib/fef/itablemanager.h> #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> using namespace search::fef; -namespace search { -namespace features { +namespace search::features { feature_t NativeAttributeMatchExecutor::calculateScore(const CachedTermData &td, const TermFieldMatchData &tfmd) @@ -115,7 +115,7 @@ NativeAttributeMatchBlueprint::visitDumpFeatures(const IIndexEnvironment & env, Blueprint::UP NativeAttributeMatchBlueprint::createInstance() const { - return Blueprint::UP(new NativeAttributeMatchBlueprint()); + return std::make_unique<NativeAttributeMatchBlueprint>(); } fef::ParameterDescriptions @@ -160,6 +160,4 @@ NativeAttributeMatchBlueprint::createExecutor(const IQueryEnvironment &env, vesp return NativeAttributeMatchExecutor::createExecutor(env, _params, stash); } - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/nativefieldmatchfeature.cpp b/searchlib/src/vespa/searchlib/features/nativefieldmatchfeature.cpp index 089a8102d6e..2b6841750ad 100644 --- a/searchlib/src/vespa/searchlib/features/nativefieldmatchfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/nativefieldmatchfeature.cpp @@ -7,11 +7,11 @@ #include <vespa/searchlib/fef/indexproperties.h> #include <vespa/searchlib/fef/itablemanager.h> #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> using namespace search::fef; -namespace search { -namespace features { +namespace search::features { const uint32_t NativeFieldMatchParam::NOT_DEF_FIELD_LENGTH(std::numeric_limits<uint32_t>::max()); @@ -95,9 +95,7 @@ NativeFieldMatchBlueprint::NativeFieldMatchBlueprint() : { } -NativeFieldMatchBlueprint::~NativeFieldMatchBlueprint() -{ -} +NativeFieldMatchBlueprint::~NativeFieldMatchBlueprint() = default; void NativeFieldMatchBlueprint::visitDumpFeatures(const IIndexEnvironment & env, @@ -110,7 +108,7 @@ NativeFieldMatchBlueprint::visitDumpFeatures(const IIndexEnvironment & env, Blueprint::UP NativeFieldMatchBlueprint::createInstance() const { - return Blueprint::UP(new NativeFieldMatchBlueprint()); + return std::make_unique<NativeFieldMatchBlueprint>(); } bool @@ -181,5 +179,4 @@ NativeFieldMatchBlueprint::createExecutor(const IQueryEnvironment &env, vespalib } } -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/nativeproximityfeature.cpp b/searchlib/src/vespa/searchlib/features/nativeproximityfeature.cpp index a31d9207e05..2809417e382 100644 --- a/searchlib/src/vespa/searchlib/features/nativeproximityfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/nativeproximityfeature.cpp @@ -7,12 +7,12 @@ #include <vespa/searchlib/fef/indexproperties.h> #include <vespa/searchlib/fef/itablemanager.h> #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> #include <map> using namespace search::fef; -namespace search { -namespace features { +namespace search::features { feature_t NativeProximityExecutor::calculateScoreForField(const FieldSetup & fs, uint32_t docId) @@ -136,9 +136,7 @@ NativeProximityBlueprint::NativeProximityBlueprint() : { } -NativeProximityBlueprint::~NativeProximityBlueprint() -{ -} +NativeProximityBlueprint::~NativeProximityBlueprint() = default; void NativeProximityBlueprint::visitDumpFeatures(const IIndexEnvironment & env, @@ -151,7 +149,7 @@ NativeProximityBlueprint::visitDumpFeatures(const IIndexEnvironment & env, Blueprint::UP NativeProximityBlueprint::createInstance() const { - return Blueprint::UP(new NativeProximityBlueprint()); + return std::make_unique<NativeProximityBlueprint>(); } bool @@ -168,12 +166,12 @@ NativeProximityBlueprint::setup(const IIndexEnvironment & env, NativeProximityParam & param = _params.vector[fieldId]; param.field = true; if ((param.proximityTable = - util::lookupTable(env, getBaseName(), "proximityTable", info->name(), _defaultProximityBoost)) == NULL) + util::lookupTable(env, getBaseName(), "proximityTable", info->name(), _defaultProximityBoost)) == nullptr) { return false; } if ((param.revProximityTable = - util::lookupTable(env, getBaseName(), "reverseProximityTable", info->name(), _defaultRevProximityBoost)) == NULL) + util::lookupTable(env, getBaseName(), "reverseProximityTable", info->name(), _defaultRevProximityBoost)) == nullptr) { return false; } @@ -190,7 +188,7 @@ NativeProximityBlueprint::setup(const IIndexEnvironment & env, if (NativeRankBlueprint::useTableNormalization(env)) { const Table * fp = param.proximityTable; const Table * rp = param.revProximityTable; - if (fp != NULL && rp != NULL) { + if (fp != nullptr && rp != nullptr) { double value = (fp->max() * param.proximityImportance) + (rp->max() * (1 - param.proximityImportance)); _params.setMaxTableSums(fieldId, value); @@ -217,6 +215,4 @@ NativeProximityBlueprint::createExecutor(const IQueryEnvironment &env, vespalib: } - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/nativerankfeature.cpp b/searchlib/src/vespa/searchlib/features/nativerankfeature.cpp index b519c4f4b7f..a980c265484 100644 --- a/searchlib/src/vespa/searchlib/features/nativerankfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/nativerankfeature.cpp @@ -4,6 +4,7 @@ #include "valuefeature.h" #include "utils.h" #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> #include <sstream> #include <vespa/log/log.h> @@ -30,8 +31,7 @@ buildFeatureName(const vespalib::string & baseName, const search::features::Fiel } -namespace search { -namespace features { +namespace search::features { FieldWrapper::FieldWrapper(const IIndexEnvironment & env, const ParameterList & fields, @@ -93,7 +93,7 @@ NativeRankBlueprint::visitDumpFeatures(const IIndexEnvironment & env, Blueprint::UP NativeRankBlueprint::createInstance() const { - return Blueprint::UP(new NativeRankBlueprint()); + return std::make_unique<NativeRankBlueprint>(); } bool @@ -168,6 +168,4 @@ NativeRankBlueprint::useTableNormalization(const search::fef::IIndexEnvironment return (!(norm.found() && (norm.get() == vespalib::string("false")))); } - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/nowfeature.cpp b/searchlib/src/vespa/searchlib/features/nowfeature.cpp index 074acb2e890..d6059592cf3 100644 --- a/searchlib/src/vespa/searchlib/features/nowfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/nowfeature.cpp @@ -3,6 +3,7 @@ #include "nowfeature.h" #include <vespa/searchlib/fef/queryproperties.h> #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> #include <chrono> namespace search::features { diff --git a/searchlib/src/vespa/searchlib/features/proximityfeature.cpp b/searchlib/src/vespa/searchlib/features/proximityfeature.cpp index f625e30f378..daeb4af6569 100644 --- a/searchlib/src/vespa/searchlib/features/proximityfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/proximityfeature.cpp @@ -2,13 +2,11 @@ #include "proximityfeature.h" #include "utils.h" -#include <vespa/searchlib/fef/featurenamebuilder.h> #include <vespa/searchlib/fef/fieldinfo.h> #include <vespa/searchlib/fef/itermdata.h> -#include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/stash.h> -namespace search { -namespace features { +namespace search::features { ProximityConfig::ProximityConfig() : fieldId(search::fef::IllegalHandle), @@ -139,7 +137,7 @@ ProximityBlueprint::setup(const search::fef::IIndexEnvironment &env, search::fef::Blueprint::UP ProximityBlueprint::createInstance() const { - return search::fef::Blueprint::UP(new ProximityBlueprint()); + return std::make_unique<ProximityBlueprint>(); } search::fef::FeatureExecutor & @@ -148,4 +146,4 @@ ProximityBlueprint::createExecutor(const search::fef::IQueryEnvironment &env, ve return stash.create<ProximityExecutor>(env, _config); } -}} +} diff --git a/searchlib/src/vespa/searchlib/features/querycompletenessfeature.cpp b/searchlib/src/vespa/searchlib/features/querycompletenessfeature.cpp index b4b6a1b0eb4..56e8810e14b 100644 --- a/searchlib/src/vespa/searchlib/features/querycompletenessfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/querycompletenessfeature.cpp @@ -3,15 +3,14 @@ #include "querycompletenessfeature.h" #include "utils.h" #include <vespa/searchlib/fef/featurenamebuilder.h> -#include <vespa/searchlib/fef/fieldinfo.h> #include <vespa/searchlib/fef/itermdata.h> +#include <vespa/vespalib/util/stash.h> #include <limits> #include <vespa/log/log.h> LOG_SETUP(".features.querycompleteness"); -namespace search { -namespace features { +namespace search::features { QueryCompletenessConfig::QueryCompletenessConfig() : fieldId(search::fef::IllegalHandle), @@ -106,7 +105,7 @@ QueryCompletenessBlueprint::setup(const search::fef::IIndexEnvironment &env, search::fef::Blueprint::UP QueryCompletenessBlueprint::createInstance() const { - return search::fef::Blueprint::UP(new QueryCompletenessBlueprint()); + return std::make_unique<QueryCompletenessBlueprint>(); } search::fef::FeatureExecutor & @@ -115,4 +114,4 @@ QueryCompletenessBlueprint::createExecutor(const search::fef::IQueryEnvironment return stash.create<QueryCompletenessExecutor>(env, _config); } -}} +} diff --git a/searchlib/src/vespa/searchlib/features/querytermcountfeature.cpp b/searchlib/src/vespa/searchlib/features/querytermcountfeature.cpp index dfc4af059a1..cbaf9e97cb6 100644 --- a/searchlib/src/vespa/searchlib/features/querytermcountfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/querytermcountfeature.cpp @@ -4,15 +4,14 @@ #include "valuefeature.h" #include <vespa/searchlib/fef/properties.h> #include <vespa/searchlib/fef/fieldinfo.h> -#include <vespa/searchlib/fef/fieldtype.h> #include <vespa/searchlib/fef/featurenamebuilder.h> #include <vespa/searchlib/fef/itermdata.h> -#include <vespa/searchlib/fef/handle.h> +#include <vespa/vespalib/util/stash.h> + using namespace search::fef; -namespace search { -namespace features { +namespace search::features { QueryTermCountBlueprint::QueryTermCountBlueprint() : Blueprint("queryTermCount") @@ -30,7 +29,7 @@ QueryTermCountBlueprint::visitDumpFeatures(const IIndexEnvironment & env, Blueprint::UP QueryTermCountBlueprint::createInstance() const { - return Blueprint::UP(new QueryTermCountBlueprint()); + return std::make_unique<QueryTermCountBlueprint>(); } bool @@ -49,6 +48,4 @@ QueryTermCountBlueprint::createExecutor(const IQueryEnvironment &env, vespalib:: return stash.create<ValueExecutor>(values); } - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/random_normal_feature.cpp b/searchlib/src/vespa/searchlib/features/random_normal_feature.cpp index dd0c67df45c..8d4af8fd88d 100644 --- a/searchlib/src/vespa/searchlib/features/random_normal_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/random_normal_feature.cpp @@ -3,6 +3,7 @@ #include "random_normal_feature.h" #include "utils.h" #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> #include <chrono> #include <vespa/log/log.h> diff --git a/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp b/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp index bde0cedaed0..f3d33c7dc29 100644 --- a/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp @@ -3,6 +3,7 @@ #include "random_normal_stable_feature.h" #include "utils.h" #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> #include <vespa/log/log.h> LOG_SETUP(".features.randomnormalstablefeature"); @@ -41,7 +42,7 @@ RandomNormalStableBlueprint::visitDumpFeatures(const search::fef::IIndexEnvironm search::fef::Blueprint::UP RandomNormalStableBlueprint::createInstance() const { - return search::fef::Blueprint::UP(new RandomNormalStableBlueprint()); + return std::make_unique<RandomNormalStableBlueprint>(); } bool @@ -75,5 +76,4 @@ RandomNormalStableBlueprint::createExecutor(const search::fef::IQueryEnvironment return stash.create<RandomNormalStableExecutor>(seed, _mean, _stddev); } - } diff --git a/searchlib/src/vespa/searchlib/features/randomfeature.cpp b/searchlib/src/vespa/searchlib/features/randomfeature.cpp index 18b0cf616d4..95daebd0452 100644 --- a/searchlib/src/vespa/searchlib/features/randomfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/randomfeature.cpp @@ -3,7 +3,9 @@ #include "randomfeature.h" #include "utils.h" #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> #include <chrono> + #include <vespa/log/log.h> LOG_SETUP(".features.randomfeature"); @@ -75,5 +77,4 @@ RandomBlueprint::createExecutor(const fef::IQueryEnvironment &env, vespalib::Sta return stash.create<RandomExecutor>(seed, matchSeed); } - } diff --git a/searchlib/src/vespa/searchlib/features/raw_score_feature.cpp b/searchlib/src/vespa/searchlib/features/raw_score_feature.cpp index 61355581214..ea696c75eff 100644 --- a/searchlib/src/vespa/searchlib/features/raw_score_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/raw_score_feature.cpp @@ -2,6 +2,7 @@ #include "raw_score_feature.h" #include "utils.h" +#include <vespa/vespalib/util/stash.h> using namespace search::fef; diff --git a/searchlib/src/vespa/searchlib/features/reverseproximityfeature.cpp b/searchlib/src/vespa/searchlib/features/reverseproximityfeature.cpp index c27936332d2..436e9bc0a0c 100644 --- a/searchlib/src/vespa/searchlib/features/reverseproximityfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/reverseproximityfeature.cpp @@ -2,14 +2,11 @@ #include "reverseproximityfeature.h" #include "utils.h" -#include <vespa/searchlib/fef/featurenamebuilder.h> #include <vespa/searchlib/fef/fieldinfo.h> -#include <vespa/searchlib/fef/fieldtype.h> #include <vespa/searchlib/fef/itermdata.h> -#include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/stash.h> -namespace search { -namespace features { +namespace search::features { ReverseProximityConfig::ReverseProximityConfig() : fieldId(search::fef::IllegalHandle), @@ -126,7 +123,7 @@ ReverseProximityBlueprint::setup(const search::fef::IIndexEnvironment &env, search::fef::Blueprint::UP ReverseProximityBlueprint::createInstance() const { - return search::fef::Blueprint::UP(new ReverseProximityBlueprint()); + return std::make_unique<ReverseProximityBlueprint>(); } search::fef::FeatureExecutor & @@ -135,4 +132,4 @@ ReverseProximityBlueprint::createExecutor(const search::fef::IQueryEnvironment & return stash.create<ReverseProximityExecutor>(env, _config); } -}} +} diff --git a/searchlib/src/vespa/searchlib/features/subqueries_feature.cpp b/searchlib/src/vespa/searchlib/features/subqueries_feature.cpp index 6c52b6edb76..aaff46af93e 100644 --- a/searchlib/src/vespa/searchlib/features/subqueries_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/subqueries_feature.cpp @@ -2,11 +2,11 @@ #include "subqueries_feature.h" #include "utils.h" +#include <vespa/vespalib/util/stash.h> using namespace search::fef; -namespace search { -namespace features { +namespace search::features { SubqueriesExecutor::SubqueriesExecutor(const IQueryEnvironment &env, uint32_t fieldId) @@ -59,5 +59,4 @@ SubqueriesBlueprint::createExecutor(const IQueryEnvironment &queryEnv, vespalib: return stash.create<SubqueriesExecutor>(queryEnv, _field->id()); } -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/term_field_md_feature.cpp b/searchlib/src/vespa/searchlib/features/term_field_md_feature.cpp index a4ca8524140..7fd487d8bdd 100644 --- a/searchlib/src/vespa/searchlib/features/term_field_md_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/term_field_md_feature.cpp @@ -2,10 +2,10 @@ #include "term_field_md_feature.h" #include "utils.h" -#include <vespa/searchlib/fef/fieldinfo.h> #include <vespa/searchlib/fef/indexproperties.h> #include <vespa/searchlib/fef/itablemanager.h> #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> #include <cassert> using namespace search::fef; @@ -83,7 +83,7 @@ TermFieldMdBlueprint::visitDumpFeatures(const IIndexEnvironment &, Blueprint::UP TermFieldMdBlueprint::createInstance() const { - return Blueprint::UP(new TermFieldMdBlueprint()); + return std::make_unique<TermFieldMdBlueprint>(); } bool diff --git a/searchlib/src/vespa/searchlib/features/termdistancefeature.cpp b/searchlib/src/vespa/searchlib/features/termdistancefeature.cpp index fb38a49d6eb..e9f48421fcf 100644 --- a/searchlib/src/vespa/searchlib/features/termdistancefeature.cpp +++ b/searchlib/src/vespa/searchlib/features/termdistancefeature.cpp @@ -5,11 +5,11 @@ #include "utils.h" #include <vespa/searchlib/fef/fieldinfo.h> #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> using namespace search::fef; -namespace search { -namespace features { +namespace search::features { TermDistanceExecutor::TermDistanceExecutor(const IQueryEnvironment & env, @@ -61,7 +61,7 @@ TermDistanceBlueprint::visitDumpFeatures(const IIndexEnvironment &, Blueprint::UP TermDistanceBlueprint::createInstance() const { - return Blueprint::UP(new TermDistanceBlueprint()); + return std::make_unique<TermDistanceBlueprint>(); } bool @@ -97,6 +97,4 @@ TermDistanceBlueprint::createExecutor(const IQueryEnvironment &env, vespalib::St } } - -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/features/termeditdistancefeature.cpp b/searchlib/src/vespa/searchlib/features/termeditdistancefeature.cpp index 5990d62cb25..433bf6134b8 100644 --- a/searchlib/src/vespa/searchlib/features/termeditdistancefeature.cpp +++ b/searchlib/src/vespa/searchlib/features/termeditdistancefeature.cpp @@ -6,6 +6,8 @@ #include <vespa/searchlib/fef/properties.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/locale/c.h> +#include <vespa/vespalib/util/stash.h> + #include <vespa/log/log.h> LOG_SETUP(".features.termeditdistance"); @@ -219,7 +221,7 @@ TermEditDistanceBlueprint::setup(const search::fef::IIndexEnvironment &env, search::fef::Blueprint::UP TermEditDistanceBlueprint::createInstance() const { - return search::fef::Blueprint::UP(new TermEditDistanceBlueprint()); + return std::make_unique<TermEditDistanceBlueprint>(); } search::fef::FeatureExecutor & diff --git a/searchlib/src/vespa/searchlib/features/termfeature.cpp b/searchlib/src/vespa/searchlib/features/termfeature.cpp index d6df25cc2b9..90540726227 100644 --- a/searchlib/src/vespa/searchlib/features/termfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/termfeature.cpp @@ -4,15 +4,14 @@ #include "utils.h" #include <vespa/searchlib/fef/featurenamebuilder.h> #include <vespa/searchlib/fef/fieldinfo.h> -#include <vespa/searchlib/fef/fieldtype.h> #include <vespa/searchlib/fef/properties.h> #include <vespa/searchlib/fef/itermdata.h> #include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/stash.h> using namespace search::fef; -namespace search { -namespace features { +namespace search::features { TermExecutor::TermExecutor(const search::fef::IQueryEnvironment &env, uint32_t termId) : @@ -21,7 +20,7 @@ TermExecutor::TermExecutor(const search::fef::IQueryEnvironment &env, _connectedness(util::lookupConnectedness(env, termId)), _significance(0) { - if (_termData != NULL) { + if (_termData != nullptr) { feature_t fallback = util::getSignificance(*_termData); _significance = util::lookupSignificance(env, termId, fallback); } @@ -30,7 +29,7 @@ TermExecutor::TermExecutor(const search::fef::IQueryEnvironment &env, void TermExecutor::execute(uint32_t) { - if (_termData == NULL) { // this query term is not present in the query + if (_termData == nullptr) { // this query term is not present in the query outputs().set_number(0, 0.0f); // connectedness outputs().set_number(1, 0.0f); // significance (1 - frequency) outputs().set_number(2, 0.0f); // weight @@ -76,7 +75,7 @@ TermBlueprint::setup(const search::fef::IIndexEnvironment &, search::fef::Blueprint::UP TermBlueprint::createInstance() const { - return search::fef::Blueprint::UP(new TermBlueprint()); + return std::make_unique<TermBlueprint>(); } search::fef::FeatureExecutor & @@ -85,4 +84,4 @@ TermBlueprint::createExecutor(const search::fef::IQueryEnvironment &env, vespali return stash.create<TermExecutor>(env, _termId); } -}} +} diff --git a/searchlib/src/vespa/searchlib/features/terminfofeature.cpp b/searchlib/src/vespa/searchlib/features/terminfofeature.cpp index 4f32cda8c86..ca7a5d8e248 100644 --- a/searchlib/src/vespa/searchlib/features/terminfofeature.cpp +++ b/searchlib/src/vespa/searchlib/features/terminfofeature.cpp @@ -3,30 +3,28 @@ #include "terminfofeature.h" #include "valuefeature.h" #include <vespa/searchlib/fef/properties.h> -#include <vespa/searchlib/fef/fieldinfo.h> -#include <vespa/searchlib/fef/fieldtype.h> #include <vespa/searchlib/fef/featurenamebuilder.h> #include <vespa/searchlib/fef/itermdata.h> -#include <vespa/searchlib/fef/handle.h> +#include <vespa/vespalib/util/stash.h> -namespace search { -namespace features { +using namespace search::fef; +namespace search::features { TermInfoBlueprint::TermInfoBlueprint() - : search::fef::Blueprint("termInfo"), + : Blueprint("termInfo"), _termIdx(0) { } void -TermInfoBlueprint::visitDumpFeatures(const search::fef::IIndexEnvironment &, - search::fef::IDumpFeatureVisitor &) const +TermInfoBlueprint::visitDumpFeatures(const IIndexEnvironment &, + IDumpFeatureVisitor &) const { } bool -TermInfoBlueprint::setup(const search::fef::IIndexEnvironment &, - const search::fef::ParameterList & params) +TermInfoBlueprint::setup(const IIndexEnvironment &, + const ParameterList & params) { _termIdx = params[0].asInteger(); describeOutput("queryidx", "The index of the first term with the given " @@ -34,8 +32,8 @@ TermInfoBlueprint::setup(const search::fef::IIndexEnvironment &, return true; } -search::fef::FeatureExecutor & -TermInfoBlueprint::createExecutor(const search::fef::IQueryEnvironment &queryEnv, vespalib::Stash &stash) const +FeatureExecutor & +TermInfoBlueprint::createExecutor(const IQueryEnvironment &queryEnv, vespalib::Stash &stash) const { feature_t queryIdx = -1.0; if (queryEnv.getNumTerms() > _termIdx) { @@ -46,5 +44,4 @@ TermInfoBlueprint::createExecutor(const search::fef::IQueryEnvironment &queryEnv return stash.create<ValueExecutor>(values); } -} // 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 3cdb20a16e5..a0e0a8759a0 100644 --- a/searchlib/src/vespa/searchlib/features/text_similarity_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/text_similarity_feature.cpp @@ -3,6 +3,7 @@ #include "text_similarity_feature.h" #include <vespa/searchlib/fef/itermdata.h> #include <vespa/searchlib/fef/featurenamebuilder.h> +#include <vespa/vespalib/util/stash.h> namespace search::features { @@ -194,7 +195,7 @@ TextSimilarityBlueprint::visitDumpFeatures(const fef::IIndexEnvironment &env, fef::Blueprint::UP TextSimilarityBlueprint::createInstance() const { - return Blueprint::UP(new TextSimilarityBlueprint()); + return std::make_unique<TextSimilarityBlueprint>(); } bool @@ -218,6 +219,4 @@ TextSimilarityBlueprint::createExecutor(const fef::IQueryEnvironment &env, vespa return stash.create<TextSimilarityExecutor>(env, _field_id); } -//----------------------------------------------------------------------------- - } diff --git a/searchlib/src/vespa/searchlib/features/valuefeature.cpp b/searchlib/src/vespa/searchlib/features/valuefeature.cpp index 339cc5431f1..2b91cf1688b 100644 --- a/searchlib/src/vespa/searchlib/features/valuefeature.cpp +++ b/searchlib/src/vespa/searchlib/features/valuefeature.cpp @@ -2,12 +2,13 @@ #include "valuefeature.h" #include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/util/stash.h> -namespace search { -namespace features { +using namespace search::fef; +namespace search::features { ValueExecutor::ValueExecutor(const std::vector<feature_t> & values) : - search::fef::FeatureExecutor(), + FeatureExecutor(), _values(values) { } @@ -27,22 +28,20 @@ SingleZeroValueExecutor::execute(uint32_t) } ValueBlueprint::ValueBlueprint() : - search::fef::Blueprint("value"), + Blueprint("value"), _values() { } -ValueBlueprint::~ValueBlueprint() {} +ValueBlueprint::~ValueBlueprint() = default; void -ValueBlueprint::visitDumpFeatures(const search::fef::IIndexEnvironment &, - search::fef::IDumpFeatureVisitor &) const +ValueBlueprint::visitDumpFeatures(const IIndexEnvironment &, IDumpFeatureVisitor &) const { } bool -ValueBlueprint::setup(const search::fef::IIndexEnvironment &, - const search::fef::ParameterList & params) +ValueBlueprint::setup(const IIndexEnvironment &, const ParameterList & params) { for (uint32_t i = 0; i < params.size(); ++i) { _values.push_back(params[i].asDouble()); @@ -56,13 +55,12 @@ ValueBlueprint::setup(const search::fef::IIndexEnvironment &, return true; } -search::fef::FeatureExecutor & -ValueBlueprint::createExecutor(const search::fef::IQueryEnvironment &queryEnv, vespalib::Stash &stash) const +FeatureExecutor & +ValueBlueprint::createExecutor(const IQueryEnvironment &queryEnv, vespalib::Stash &stash) const { (void) queryEnv; return stash.create<ValueExecutor>(_values); } -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/fef/rank_program.cpp b/searchlib/src/vespa/searchlib/fef/rank_program.cpp index d39be693806..bd8abe41afb 100644 --- a/searchlib/src/vespa/searchlib/fef/rank_program.cpp +++ b/searchlib/src/vespa/searchlib/fef/rank_program.cpp @@ -6,6 +6,9 @@ #include <algorithm> #include <cassert> +#include <vespa/log/log.h> +LOG_SETUP(".fef.rankprogram"); + using vespalib::Stash; namespace search::fef { @@ -42,7 +45,7 @@ struct OverrideVisitor : public IPropertiesVisitor { auto pos = feature_map.find(key); if (pos != feature_map.end()) { - overrides.push_back(Override(pos->second, vespalib::locale::c::strtod(values.get().c_str(), nullptr))); + overrides.emplace_back(pos->second, vespalib::locale::c::strtod(values.get().c_str(), nullptr)); } } }; @@ -175,6 +178,7 @@ RankProgram::setup(const MatchData &md, auto override_end = overrides.end(); const auto &specs = _resolver->getExecutorSpecs(); + _executors.reserve(specs.size()); for (uint32_t i = 0; i < specs.size(); ++i) { vespalib::ArrayRef<NumberOrObject> outputs = _hot_stash.create_array<NumberOrObject>(specs[i].output_types.size()); StashSelector stash(_hot_stash, _cold_stash); @@ -216,6 +220,8 @@ RankProgram::setup(const MatchData &md, } } assert(_executors.size() == specs.size()); + LOG(debug, "Num executors = %ld, hot stash = %ld, cold stash = %ld, match data fields = %d", + _executors.size(), _hot_stash.count_used(), _cold_stash.count_used(), md.getNumTermFields()); } FeatureResolver diff --git a/searchlib/src/vespa/searchlib/fef/rank_program.h b/searchlib/src/vespa/searchlib/fef/rank_program.h index 0e5c390162a..aa6f77abce4 100644 --- a/searchlib/src/vespa/searchlib/fef/rank_program.h +++ b/searchlib/src/vespa/searchlib/fef/rank_program.h @@ -9,8 +9,8 @@ #include "feature_resolver.h" #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/array.h> +#include <vespa/vespalib/util/stash.h> #include <set> -#include <vector> namespace search::fef { diff --git a/searchlib/src/vespa/searchlib/fef/ranksetup.cpp b/searchlib/src/vespa/searchlib/fef/ranksetup.cpp index ee88be8ad00..88f4a07d95d 100644 --- a/searchlib/src/vespa/searchlib/fef/ranksetup.cpp +++ b/searchlib/src/vespa/searchlib/fef/ranksetup.cpp @@ -12,7 +12,7 @@ class VisitorAdapter : public search::fef::IDumpFeatureVisitor { search::fef::BlueprintResolver &_resolver; public: - VisitorAdapter(search::fef::BlueprintResolver &resolver) + explicit VisitorAdapter(search::fef::BlueprintResolver &resolver) : _resolver(resolver) {} void visitDumpFeature(const vespalib::string &name) override { _resolver.addSeed(name); @@ -60,7 +60,8 @@ RankSetup::RankSetup(const BlueprintFactory &factory, const IIndexEnvironment &i _diversityCutoffFactor(10.0), _diversityCutoffStrategy("loose"), _softTimeoutEnabled(false), - _softTimeoutTailCost(0.1) + _softTimeoutTailCost(0.1), + _softTimeoutFactor(0.5) { } RankSetup::~RankSetup() = default; @@ -71,13 +72,13 @@ RankSetup::configure() setFirstPhaseRank(rank::FirstPhase::lookup(_indexEnv.getProperties())); setSecondPhaseRank(rank::SecondPhase::lookup(_indexEnv.getProperties())); std::vector<vespalib::string> summaryFeatures = summary::Feature::lookup(_indexEnv.getProperties()); - for (uint32_t i = 0; i < summaryFeatures.size(); ++i) { - addSummaryFeature(summaryFeatures[i]); + for (const auto & feature : summaryFeatures) { + addSummaryFeature(feature); } setIgnoreDefaultRankFeatures(dump::IgnoreDefaultFeatures::check(_indexEnv.getProperties())); std::vector<vespalib::string> dumpFeatures = dump::Feature::lookup(_indexEnv.getProperties()); - for (uint32_t i = 0; i < dumpFeatures.size(); ++i) { - addDumpFeature(dumpFeatures[i]); + for (const auto & feature : dumpFeatures) { + addDumpFeature(feature); } split_unpacking_iterators(matching::SplitUnpackingIterators::check(_indexEnv.getProperties())); delay_unpacking_iterators(matching::DelayUnpackingIterators::check(_indexEnv.getProperties())); @@ -159,15 +160,15 @@ RankSetup::compile() _compileError = true; } } - for (uint32_t i = 0; i < _summaryFeatures.size(); ++i) { - _summary_resolver->addSeed(_summaryFeatures[i]); + for (const auto & feature :_summaryFeatures) { + _summary_resolver->addSeed(feature); } if (!_ignoreDefaultRankFeatures) { VisitorAdapter adapter(*_dumpResolver); _factory.visitDumpFeatures(_indexEnv, adapter); } - for (uint32_t i = 0; i < _dumpFeatures.size(); ++i) { - _dumpResolver->addSeed(_dumpFeatures[i]); + for (const auto & feature : _dumpFeatures) { + _dumpResolver->addSeed(feature); } _indexEnv.hintFeatureMotivation(IIndexEnvironment::RANK); _compileError |= !_first_phase_resolver->compile(); diff --git a/searchlib/src/vespa/searchlib/fef/ranksetup.h b/searchlib/src/vespa/searchlib/fef/ranksetup.h index d543794b347..e1cd78d41a9 100644 --- a/searchlib/src/vespa/searchlib/fef/ranksetup.h +++ b/searchlib/src/vespa/searchlib/fef/ranksetup.h @@ -397,10 +397,10 @@ public: // them to be ready to use. Also keep in mind that creating a rank // program is cheap while setting it up is more expensive. - RankProgram::UP create_first_phase_program() const { return RankProgram::UP(new RankProgram(_first_phase_resolver)); } - RankProgram::UP create_second_phase_program() const { return RankProgram::UP(new RankProgram(_second_phase_resolver)); } - RankProgram::UP create_summary_program() const { return RankProgram::UP(new RankProgram(_summary_resolver)); } - RankProgram::UP create_dump_program() const { return RankProgram::UP(new RankProgram(_dumpResolver)); } + RankProgram::UP create_first_phase_program() const { return std::make_unique<RankProgram>(_first_phase_resolver); } + RankProgram::UP create_second_phase_program() const { return std::make_unique<RankProgram>(_second_phase_resolver); } + RankProgram::UP create_summary_program() const { return std::make_unique<RankProgram>(_summary_resolver); } + RankProgram::UP create_dump_program() const { return std::make_unique<RankProgram>(_dumpResolver); } /** * Here you can do some preprocessing. State must be stored in the IObjectStore. diff --git a/searchlib/src/vespa/searchlib/fef/test/plugin/cfgvalue.cpp b/searchlib/src/vespa/searchlib/fef/test/plugin/cfgvalue.cpp index 31e99ef9953..8be0961f999 100644 --- a/searchlib/src/vespa/searchlib/fef/test/plugin/cfgvalue.cpp +++ b/searchlib/src/vespa/searchlib/fef/test/plugin/cfgvalue.cpp @@ -2,11 +2,10 @@ #include "cfgvalue.h" #include <vespa/searchlib/fef/properties.h> +#include <vespa/vespalib/util/stash.h> #include <sstream> -namespace search { -namespace fef { -namespace test { +namespace search::fef::test { CfgValueBlueprint::CfgValueBlueprint() : Blueprint("test_cfgvalue"), @@ -14,9 +13,7 @@ CfgValueBlueprint::CfgValueBlueprint() : { } -CfgValueBlueprint::~CfgValueBlueprint() -{ -} +CfgValueBlueprint::~CfgValueBlueprint() = default; void CfgValueBlueprint::visitDumpFeatures(const IIndexEnvironment &indexEnv, IDumpFeatureVisitor &visitor) const @@ -59,6 +56,4 @@ CfgValueBlueprint::createExecutor(const IQueryEnvironment & queryEnv, vespalib:: return stash.create<search::features::ValueExecutor>(_values); } -} // namespace test -} // namespace fef -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/fef/test/plugin/chain.cpp b/searchlib/src/vespa/searchlib/fef/test/plugin/chain.cpp index 86754c2c22d..017b916ad76 100644 --- a/searchlib/src/vespa/searchlib/fef/test/plugin/chain.cpp +++ b/searchlib/src/vespa/searchlib/fef/test/plugin/chain.cpp @@ -1,11 +1,10 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "chain.h" +#include <vespa/vespalib/util/stash.h> #include <sstream> -namespace search { -namespace fef { -namespace test { +namespace search::fef::test { ChainExecutor::ChainExecutor() : FeatureExecutor() @@ -67,6 +66,4 @@ ChainBlueprint::createExecutor(const IQueryEnvironment &queryEnv, vespalib::Stas return stash.create<ChainExecutor>(); } -} // namespace test -} // namespace fef -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/fef/test/plugin/double.cpp b/searchlib/src/vespa/searchlib/fef/test/plugin/double.cpp index d9ec8b13e57..6f8ebd57fb0 100644 --- a/searchlib/src/vespa/searchlib/fef/test/plugin/double.cpp +++ b/searchlib/src/vespa/searchlib/fef/test/plugin/double.cpp @@ -3,6 +3,7 @@ #include "double.h" #include <vespa/searchlib/fef/featurenamebuilder.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/util/stash.h> #include <cassert> namespace search::fef::test { diff --git a/searchlib/src/vespa/searchlib/fef/test/plugin/query.cpp b/searchlib/src/vespa/searchlib/fef/test/plugin/query.cpp index 4b4b10c4d25..1e57d6252ee 100644 --- a/searchlib/src/vespa/searchlib/fef/test/plugin/query.cpp +++ b/searchlib/src/vespa/searchlib/fef/test/plugin/query.cpp @@ -4,6 +4,7 @@ #include <vespa/searchlib/features/valuefeature.h> #include <vespa/searchlib/fef/properties.h> #include <vespa/vespalib/locale/c.h> +#include <vespa/vespalib/util/stash.h> #include <sstream> namespace search::fef::test { @@ -32,7 +33,7 @@ QueryBlueprint::createExecutor(const IQueryEnvironment &queryEnv, vespalib::Stas { std::vector<feature_t> values; std::string val = queryEnv.getProperties().lookup(_key).get("0.0"); - values.push_back(vespalib::locale::c::strtod(val.data(), NULL)); + values.push_back(vespalib::locale::c::strtod(val.data(), nullptr)); return stash.create<search::features::ValueExecutor>(values); } diff --git a/searchlib/src/vespa/searchlib/fef/test/plugin/staticrank.cpp b/searchlib/src/vespa/searchlib/fef/test/plugin/staticrank.cpp index c1b8b940245..c5871b23e77 100644 --- a/searchlib/src/vespa/searchlib/fef/test/plugin/staticrank.cpp +++ b/searchlib/src/vespa/searchlib/fef/test/plugin/staticrank.cpp @@ -2,10 +2,9 @@ #include "staticrank.h" #include <vespa/searchcommon/attribute/attributecontent.h> +#include <vespa/vespalib/util/stash.h> -namespace search { -namespace fef { -namespace test { +namespace search::fef::test { StaticRankExecutor::StaticRankExecutor(const search::attribute::IAttributeVector * attribute) : FeatureExecutor(), @@ -17,7 +16,7 @@ void StaticRankExecutor::execute(uint32_t docId) { search::attribute::FloatContent staticRank; - if (_attribute != NULL) { + if (_attribute != nullptr) { staticRank.allocate(_attribute->getMaxValueCount()); staticRank.fill(*_attribute, docId); } @@ -31,9 +30,7 @@ StaticRankBlueprint::StaticRankBlueprint() : { } -StaticRankBlueprint::~StaticRankBlueprint() -{ -} +StaticRankBlueprint::~StaticRankBlueprint() = default; bool StaticRankBlueprint::setup(const IIndexEnvironment & indexEnv, const StringVector & params) @@ -54,6 +51,4 @@ StaticRankBlueprint::createExecutor(const IQueryEnvironment & queryEnv, vespalib return stash.create<StaticRankExecutor>(av); } -} // namespace test -} // namespace fef -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/fef/test/plugin/sum.cpp b/searchlib/src/vespa/searchlib/fef/test/plugin/sum.cpp index b5025d53cbd..4362a7f0860 100644 --- a/searchlib/src/vespa/searchlib/fef/test/plugin/sum.cpp +++ b/searchlib/src/vespa/searchlib/fef/test/plugin/sum.cpp @@ -2,10 +2,9 @@ #include "sum.h" #include <vespa/searchlib/fef/featurenamebuilder.h> +#include <vespa/vespalib/util/stash.h> -namespace search { -namespace fef { -namespace test { +namespace search::fef::test { void SumExecutor::execute(uint32_t) @@ -73,6 +72,4 @@ SumBlueprint::createExecutor(const IQueryEnvironment &queryEnv, vespalib::Stash return stash.create<SumExecutor>(); } -} // namespace test -} // namespace fef -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/fef/test/plugin/unbox.cpp b/searchlib/src/vespa/searchlib/fef/test/plugin/unbox.cpp index 7b3876fada0..e30b4893e15 100644 --- a/searchlib/src/vespa/searchlib/fef/test/plugin/unbox.cpp +++ b/searchlib/src/vespa/searchlib/fef/test/plugin/unbox.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "unbox.h" +#include <vespa/vespalib/util/stash.h> namespace search::fef::test { diff --git a/searchlib/src/vespa/searchlib/fef/test/test_features.cpp b/searchlib/src/vespa/searchlib/fef/test/test_features.cpp index f924acd65de..c32776dc88d 100644 --- a/searchlib/src/vespa/searchlib/fef/test/test_features.cpp +++ b/searchlib/src/vespa/searchlib/fef/test/test_features.cpp @@ -3,6 +3,8 @@ #include <vespa/vespalib/testkit/test_kit.h> #include "test_features.h" #include <vespa/vespalib/locale/c.h> +#include <vespa/vespalib/util/stash.h> + using vespalib::eval::DoubleValue; using vespalib::eval::ValueType; diff --git a/vespalib/src/vespa/vespalib/geo/zcurve.cpp b/vespalib/src/vespa/vespalib/geo/zcurve.cpp index b2dc02759dc..00ce7ee18c6 100644 --- a/vespalib/src/vespa/vespalib/geo/zcurve.cpp +++ b/vespalib/src/vespa/vespalib/geo/zcurve.cpp @@ -4,8 +4,7 @@ #include <vespa/vespalib/util/priority_queue.h> #include <vespa/vespalib/util/fiddle.h> -namespace vespalib { -namespace geo { +namespace vespalib::geo { namespace { @@ -182,4 +181,3 @@ ZCurve::decodeSlow(int64_t enc, int32_t *xp, int32_t *yp) } } -} diff --git a/vespalib/src/vespa/vespalib/geo/zcurve.h b/vespalib/src/vespa/vespalib/geo/zcurve.h index 2a05c4c7744..bd76b78ea23 100644 --- a/vespalib/src/vespa/vespalib/geo/zcurve.h +++ b/vespalib/src/vespa/vespalib/geo/zcurve.h @@ -6,8 +6,7 @@ #include <cassert> #include <vector> -namespace vespalib { -namespace geo { +namespace vespalib::geo { /** * @brief Utility methods for a Z-curve (Morton-order) encoder and decoder. @@ -31,7 +30,7 @@ public: public: BoundingBox(int32_t minx, int32_t maxx, int32_t miny, int32_t maxy); - ~BoundingBox() { } + ~BoundingBox() = default; int64_t getzMinx() const { return _zMinx; } int64_t getzMaxx() const { return _zMaxx; } @@ -221,5 +220,3 @@ public: }; } -} - diff --git a/vespalib/src/vespa/vespalib/util/stash.cpp b/vespalib/src/vespa/vespalib/util/stash.cpp index 18ed0e56e27..836654c2fb2 100644 --- a/vespalib/src/vespa/vespalib/util/stash.cpp +++ b/vespalib/src/vespa/vespalib/util/stash.cpp @@ -59,14 +59,14 @@ Stash::do_alloc(size_t size) } } -Stash::Stash(size_t chunk_size) +Stash::Stash(size_t chunk_size) noexcept : _chunks(nullptr), _cleanup(nullptr), _chunk_size(std::max(size_t(4096), chunk_size)) { } -Stash::Stash(Stash &&rhs) +Stash::Stash(Stash &&rhs) noexcept : _chunks(rhs._chunks), _cleanup(rhs._cleanup), _chunk_size(rhs._chunk_size) @@ -76,7 +76,7 @@ Stash::Stash(Stash &&rhs) } Stash & -Stash::operator=(Stash &&rhs) +Stash::operator=(Stash &&rhs) noexcept { stash::run_cleanup(_cleanup); stash::free_chunks(_chunks); diff --git a/vespalib/src/vespa/vespalib/util/stash.h b/vespalib/src/vespa/vespalib/util/stash.h index aa1441aa0bb..c5e8631ca9e 100644 --- a/vespalib/src/vespa/vespalib/util/stash.h +++ b/vespalib/src/vespa/vespalib/util/stash.h @@ -14,19 +14,19 @@ struct Cleanup { explicit Cleanup(Cleanup *next_in) noexcept : next(next_in) {} virtual void cleanup() = 0; protected: - virtual ~Cleanup() {} + virtual ~Cleanup() = default; }; // used as header for memory allocated outside the stash struct DeleteMemory : public Cleanup { explicit DeleteMemory(Cleanup *next_in) noexcept : Cleanup(next_in) {} - virtual void cleanup() override { free((void*)this); } + void cleanup() override { free((void*)this); } }; // used as prefix for objects to be destructed template<typename T> struct DestructObject : public Cleanup { explicit DestructObject(Cleanup *next_in) noexcept : Cleanup(next_in) {} - virtual void cleanup() override { reinterpret_cast<T*>(this + 1)->~T(); } + void cleanup() override { reinterpret_cast<T*>(this + 1)->~T(); } }; // used as prefix for arrays to be destructed @@ -34,7 +34,7 @@ template<typename T> struct DestructArray : public Cleanup { size_t size; explicit DestructArray(Cleanup *next_in, size_t size_in) noexcept : Cleanup(next_in), size(size_in) {} - virtual void cleanup() override { + void cleanup() override { T *array = reinterpret_cast<T*>(this + 1); for (size_t i = size; i-- > 0;) { array[i].~T(); @@ -46,7 +46,7 @@ struct Chunk { Chunk *next; size_t used; Chunk(const Chunk &) = delete; - Chunk(Chunk *next_in) : next(next_in), used(sizeof(Chunk)) {} + explicit Chunk(Chunk *next_in) : next(next_in), used(sizeof(Chunk)) {} void clear() { used = sizeof(Chunk); } char *alloc(size_t size, size_t chunk_size) { size_t aligned_size = ((size + (sizeof(char *) - 1)) @@ -124,14 +124,14 @@ public: }; typedef std::unique_ptr<Stash> UP; - explicit Stash(size_t chunk_size); - Stash() : Stash(4096) {} - Stash(Stash &&rhs); + explicit Stash(size_t chunk_size) noexcept ; + Stash() noexcept : Stash(4096) {} + Stash(Stash &&rhs) noexcept; Stash(const Stash &) = delete; Stash & operator = (const Stash &) = delete; ~Stash(); - Stash &operator=(Stash &&rhs); + Stash &operator=(Stash &&rhs) noexcept; void clear(); |