diff options
49 files changed, 66 insertions, 613 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp index 65db20dd775..5ac5cf3488e 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp @@ -4,6 +4,7 @@ #include <vespa/vespalib/stllike/lrucache_map.hpp> #include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/vespalib/util/sync.h> +#include <algorithm> #include <vespa/log/log.h> LOG_SETUP(".sessionmanager"); diff --git a/searchlib/src/apps/tests/memoryindexstress_test.cpp b/searchlib/src/apps/tests/memoryindexstress_test.cpp index d3534e28d72..837952061c8 100644 --- a/searchlib/src/apps/tests/memoryindexstress_test.cpp +++ b/searchlib/src/apps/tests/memoryindexstress_test.cpp @@ -93,7 +93,7 @@ bool isWordChar(char c) { void tokenizeStringFieldValue(const document::FixedTypeRepo & repo, StringFieldValue &field) { - document::SpanTree::UP spanTree; // Note: Not thread safe, is linkedptr + document::SpanTree::UP spanTree; SpanList::UP spanList(std::make_unique<SpanList>()); SpanList *spans = spanList.get(); spanTree.reset(new document::SpanTree(SPANTREE_NAME, std::move(spanList))); diff --git a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp index 50e37b45812..e5ee83507ae 100644 --- a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp @@ -1,13 +1,14 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/log/log.h> -LOG_SETUP("blueprint_test"); +#include "mysearch.h" #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchlib/queryeval/blueprint.h> #include <vespa/searchlib/queryeval/intermediate_blueprints.h> #include <vespa/vespalib/objects/objectdumper.h> #include <vespa/vespalib/objects/visit.h> +#include <algorithm> -#include "mysearch.h" +#include <vespa/log/log.h> +LOG_SETUP("blueprint_test"); using namespace search::queryeval; using namespace search::fef; diff --git a/searchlib/src/tests/queryeval/blueprint/mysearch.h b/searchlib/src/tests/queryeval/blueprint/mysearch.h index 331675a0760..c47014e1e77 100644 --- a/searchlib/src/tests/queryeval/blueprint/mysearch.h +++ b/searchlib/src/tests/queryeval/blueprint/mysearch.h @@ -1,9 +1,9 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/searchlib/queryeval/blueprint.h> +#include <vespa/searchlib/queryeval/multisearch.h> #include <vespa/vespalib/objects/visit.hpp> -namespace search { -namespace queryeval { +namespace search::queryeval { //----------------------------------------------------------------------------- @@ -26,8 +26,8 @@ private: std::vector<uint32_t> _handles; protected: - virtual void doSeek(uint32_t) override {} - virtual void doUnpack(uint32_t) override {} + void doSeek(uint32_t) override {} + void doUnpack(uint32_t) override {} public: MySearch(const std::string &tag, bool leaf, bool strict) @@ -151,5 +151,4 @@ public: //----------------------------------------------------------------------------- -} // namespace queryeval -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/aggregation/aggregation.cpp b/searchlib/src/vespa/searchlib/aggregation/aggregation.cpp index d079d15c124..2c081328fd1 100644 --- a/searchlib/src/vespa/searchlib/aggregation/aggregation.cpp +++ b/searchlib/src/vespa/searchlib/aggregation/aggregation.cpp @@ -7,11 +7,9 @@ #include <vespa/vespalib/objects/visit.hpp> #include <vespa/vespalib/xxhash/xxhash.h> -namespace search { +using namespace search::expression; -using namespace expression; - -namespace aggregation { +namespace search::aggregation { namespace { @@ -578,8 +576,7 @@ void StandardDeviationAggregationResult::visitMembers(vespalib::ObjectVisitor &v visit(visitor, "sumOfSquared", _sumOfSquared); } -} // namespace aggregation -} // namespace search +} // this function was added by ../../forcelink.sh void forcelink_file_searchlib_aggregation_aggregation() {} diff --git a/searchlib/src/vespa/searchlib/aggregation/aggregation.h b/searchlib/src/vespa/searchlib/aggregation/aggregation.h index 10b75e2424b..8ca256460b9 100644 --- a/searchlib/src/vespa/searchlib/aggregation/aggregation.h +++ b/searchlib/src/vespa/searchlib/aggregation/aggregation.h @@ -1,22 +1,20 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include "countaggregationresult.h" +#include "sumaggregationresult.h" +#include "minaggregationresult.h" +#include "maxaggregationresult.h" +#include "averageaggregationresult.h" +#include "xoraggregationresult.h" +#include "hitsaggregationresult.h" +#include "standarddeviationaggregationresult.h" +#include "grouping.h" #include <vespa/searchlib/common/identifiable.h> #include <vespa/searchlib/common/rankedhit.h> #include <vespa/searchlib/attribute/attributeguard.h> -#include <vespa/searchlib/aggregation/countaggregationresult.h> -#include <vespa/searchlib/aggregation/sumaggregationresult.h> -#include <vespa/searchlib/aggregation/minaggregationresult.h> -#include <vespa/searchlib/aggregation/maxaggregationresult.h> -#include <vespa/searchlib/aggregation/averageaggregationresult.h> -#include <vespa/searchlib/aggregation/xoraggregationresult.h> -#include <vespa/searchlib/aggregation/hitsaggregationresult.h> -#include <vespa/searchlib/aggregation/standarddeviationaggregationresult.h> -#include <vespa/searchlib/aggregation/grouping.h> -namespace search { -namespace aggregation { +namespace search::aggregation { } -} diff --git a/searchlib/src/vespa/searchlib/aggregation/aggregationresult.h b/searchlib/src/vespa/searchlib/aggregation/aggregationresult.h index d849bb15d21..765dcf23050 100644 --- a/searchlib/src/vespa/searchlib/aggregation/aggregationresult.h +++ b/searchlib/src/vespa/searchlib/aggregation/aggregationresult.h @@ -4,8 +4,7 @@ #include <vespa/searchlib/expression/expressiontree.h> #include <vespa/searchlib/expression/resultnode.h> -namespace search { -namespace aggregation { +namespace search::aggregation { using search::expression::DocId; @@ -91,9 +90,8 @@ private: (void) rank; onAggregate(result); } - vespalib::LinkedPtr<expression::ExpressionTree> _expressionTree; + std::shared_ptr<expression::ExpressionTree> _expressionTree; uint32_t _tag; }; } -} diff --git a/searchlib/src/vespa/searchlib/aggregation/averageaggregationresult.h b/searchlib/src/vespa/searchlib/aggregation/averageaggregationresult.h index 18ecedd9178..3d3395c63fc 100644 --- a/searchlib/src/vespa/searchlib/aggregation/averageaggregationresult.h +++ b/searchlib/src/vespa/searchlib/aggregation/averageaggregationresult.h @@ -4,8 +4,7 @@ #include "aggregationresult.h" #include <vespa/searchlib/expression/numericresultnode.h> -namespace search { -namespace aggregation { +namespace search::aggregation { class AverageAggregationResult : public AggregationResult { @@ -27,4 +26,3 @@ private: }; } -} diff --git a/searchlib/src/vespa/searchlib/aggregation/countaggregationresult.h b/searchlib/src/vespa/searchlib/aggregation/countaggregationresult.h index ff682ddff53..4c70011f1f7 100644 --- a/searchlib/src/vespa/searchlib/aggregation/countaggregationresult.h +++ b/searchlib/src/vespa/searchlib/aggregation/countaggregationresult.h @@ -4,8 +4,7 @@ #include "aggregationresult.h" #include <vespa/searchlib/expression/integerresultnode.h> -namespace search { -namespace aggregation { +namespace search::aggregation { class CountAggregationResult : public AggregationResult { @@ -25,4 +24,3 @@ private: }; } -} diff --git a/searchlib/src/vespa/searchlib/aggregation/expressioncountaggregationresult.h b/searchlib/src/vespa/searchlib/aggregation/expressioncountaggregationresult.h index 8599924f98e..5d534df8cda 100644 --- a/searchlib/src/vespa/searchlib/aggregation/expressioncountaggregationresult.h +++ b/searchlib/src/vespa/searchlib/aggregation/expressioncountaggregationresult.h @@ -6,8 +6,7 @@ #include <vespa/searchlib/grouping/hyperloglog.h> #include <vespa/searchlib/expression/integerresultnode.h> -namespace search { -namespace aggregation { +namespace search::aggregation { /** * Estimates the number of unique values of an expression that has @@ -32,6 +31,4 @@ public: const Sketch<PRECISION, uint32_t> &getSketch() const { return _hll.getSketch(); } }; -} // namespace aggregation -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/aggregation/fs4hit.cpp b/searchlib/src/vespa/searchlib/aggregation/fs4hit.cpp index 16e0ecc2796..19125edface 100644 --- a/searchlib/src/vespa/searchlib/aggregation/fs4hit.cpp +++ b/searchlib/src/vespa/searchlib/aggregation/fs4hit.cpp @@ -2,8 +2,7 @@ #include "fs4hit.h" #include <vespa/vespalib/objects/visit.h> -namespace search { -namespace aggregation { +namespace search::aggregation { using vespalib::FieldBase; using vespalib::Serializer; @@ -54,7 +53,6 @@ FS4Hit::visitMembers(vespalib::ObjectVisitor &visitor) const } } -} // this function was added by ../../forcelink.sh void forcelink_file_searchlib_aggregation_fs4hit() {} diff --git a/searchlib/src/vespa/searchlib/aggregation/fs4hit.h b/searchlib/src/vespa/searchlib/aggregation/fs4hit.h index b67c2df0db0..9611899334d 100644 --- a/searchlib/src/vespa/searchlib/aggregation/fs4hit.h +++ b/searchlib/src/vespa/searchlib/aggregation/fs4hit.h @@ -6,8 +6,7 @@ #include <vespa/document/base/globalid.h> #include <vespa/searchlib/common/docstamp.h> -namespace search { -namespace aggregation { +namespace search::aggregation { class FS4Hit : public Hit { @@ -35,5 +34,3 @@ public: }; } -} - diff --git a/searchlib/src/vespa/searchlib/aggregation/group.cpp b/searchlib/src/vespa/searchlib/aggregation/group.cpp index 56e21d7e8ba..6eb131fe77d 100644 --- a/searchlib/src/vespa/searchlib/aggregation/group.cpp +++ b/searchlib/src/vespa/searchlib/aggregation/group.cpp @@ -9,9 +9,10 @@ #include <vespa/vespalib/objects/visit.hpp> #include <vespa/vespalib/stllike/hash_set.hpp> #include <cmath> +#include <cassert> +#include <algorithm> -namespace search { -namespace aggregation { +namespace search::aggregation { using search::expression::AggregationRefNode; using search::expression::ExpressionTree; @@ -757,7 +758,6 @@ Group::Value::setupAggregationReferences() } } -} // this function was added by ../../forcelink.sh void forcelink_file_searchlib_aggregation_group() {} diff --git a/searchlib/src/vespa/searchlib/aggregation/group.h b/searchlib/src/vespa/searchlib/aggregation/group.h index 23ad8d1248d..b34bd0fc88a 100644 --- a/searchlib/src/vespa/searchlib/aggregation/group.h +++ b/searchlib/src/vespa/searchlib/aggregation/group.h @@ -8,8 +8,7 @@ #include <vespa/fastos/dynamiclibrary.h> #include <vector> -namespace search { -namespace aggregation { +namespace search::aggregation { class GroupingLevel; class Grouping; @@ -275,4 +274,3 @@ public: }; } -} diff --git a/searchlib/src/vespa/searchlib/aggregation/grouping.cpp b/searchlib/src/vespa/searchlib/aggregation/grouping.cpp index 2a80cc02868..79ebaae894d 100644 --- a/searchlib/src/vespa/searchlib/aggregation/grouping.cpp +++ b/searchlib/src/vespa/searchlib/aggregation/grouping.cpp @@ -21,8 +21,7 @@ using vespalib::FieldBase; using vespalib::Serializer; using vespalib::Deserializer; -namespace search { -namespace aggregation { +namespace search::aggregation { namespace { @@ -362,7 +361,6 @@ Grouping::visitMembers(vespalib::ObjectVisitor &visitor) const } } -} // this function was added by ../../forcelink.sh void forcelink_file_searchlib_aggregation_grouping() {} diff --git a/searchlib/src/vespa/searchlib/aggregation/groupinglevel.cpp b/searchlib/src/vespa/searchlib/aggregation/groupinglevel.cpp index 9a643d02cf4..2ae1855ab77 100644 --- a/searchlib/src/vespa/searchlib/aggregation/groupinglevel.cpp +++ b/searchlib/src/vespa/searchlib/aggregation/groupinglevel.cpp @@ -4,8 +4,7 @@ #include "grouping.h" #include <vespa/searchlib/expression/resultvector.h> -namespace search { -namespace aggregation { +namespace search::aggregation { using expression::ResultNodeVector; using vespalib::FieldBase; @@ -109,7 +108,6 @@ void GroupingLevel::prepare(const Grouping * grouping, uint32_t level, bool isOr // template<> void GroupingLevel::MultiValueGrouper::groupDoc(Group & g, const ResultNode::CP & result, DocId doc, HitRank rank, bool isOrdered) const; } -} // this function was added by ../../forcelink.sh void forcelink_file_searchlib_aggregation_groupinglevel() {} diff --git a/searchlib/src/vespa/searchlib/aggregation/groupinglevel.h b/searchlib/src/vespa/searchlib/aggregation/groupinglevel.h index 2051513459a..16d004f807d 100644 --- a/searchlib/src/vespa/searchlib/aggregation/groupinglevel.h +++ b/searchlib/src/vespa/searchlib/aggregation/groupinglevel.h @@ -4,8 +4,7 @@ #include "group.h" #include <vespa/searchlib/expression/aggregationrefnode.h> -namespace search { -namespace aggregation { +namespace search::aggregation { class Grouping; @@ -126,5 +125,3 @@ public: }; } -} - diff --git a/searchlib/src/vespa/searchlib/aggregation/hit.cpp b/searchlib/src/vespa/searchlib/aggregation/hit.cpp index 8bdb63bc9a8..3f4f46b4a51 100644 --- a/searchlib/src/vespa/searchlib/aggregation/hit.cpp +++ b/searchlib/src/vespa/searchlib/aggregation/hit.cpp @@ -2,8 +2,7 @@ #include "hit.h" #include <vespa/vespalib/objects/visit.h> -namespace search { -namespace aggregation { +namespace search::aggregation { using vespalib::FieldBase; using vespalib::Serializer; @@ -39,7 +38,6 @@ Hit::visitMembers(vespalib::ObjectVisitor &visitor) const } } -} // this function was added by ../../forcelink.sh void forcelink_file_searchlib_aggregation_hit() {} diff --git a/searchlib/src/vespa/searchlib/aggregation/hit.h b/searchlib/src/vespa/searchlib/aggregation/hit.h index 6b5dc341eec..556f60dfb8d 100644 --- a/searchlib/src/vespa/searchlib/aggregation/hit.h +++ b/searchlib/src/vespa/searchlib/aggregation/hit.h @@ -5,8 +5,7 @@ #include <vespa/searchlib/common/identifiable.h> #include <vespa/searchlib/common/hitrank.h> -namespace search { -namespace aggregation { +namespace search::aggregation { class Hit : public vespalib::Identifiable { @@ -27,5 +26,3 @@ public: }; } -} - diff --git a/searchlib/src/vespa/searchlib/aggregation/hitlist.cpp b/searchlib/src/vespa/searchlib/aggregation/hitlist.cpp index b247f49574f..0efe2adfaf9 100644 --- a/searchlib/src/vespa/searchlib/aggregation/hitlist.cpp +++ b/searchlib/src/vespa/searchlib/aggregation/hitlist.cpp @@ -2,9 +2,9 @@ #include "hitlist.h" #include <vespa/vespalib/objects/visit.hpp> +#include <algorithm> -namespace search { -namespace aggregation { +namespace search::aggregation { using vespalib::FieldBase; using vespalib::Serializer; @@ -141,7 +141,6 @@ HitList::set(const ResultNode & rhs) } } -} // this function was added by ../../forcelink.sh void forcelink_file_searchlib_aggregation_hitlist() {} diff --git a/searchlib/src/vespa/searchlib/aggregation/hitlist.h b/searchlib/src/vespa/searchlib/aggregation/hitlist.h index ef0f8d50934..f53dcc63e7c 100644 --- a/searchlib/src/vespa/searchlib/aggregation/hitlist.h +++ b/searchlib/src/vespa/searchlib/aggregation/hitlist.h @@ -5,8 +5,7 @@ #include "vdshit.h" #include <vespa/searchlib/common/identifiable.h> -namespace search { -namespace aggregation { +namespace search::aggregation { class HitList : public expression::ResultNode @@ -71,5 +70,3 @@ public: }; } -} - diff --git a/searchlib/src/vespa/searchlib/aggregation/hitsaggregationresult.cpp b/searchlib/src/vespa/searchlib/aggregation/hitsaggregationresult.cpp index 9feb2998f03..ac12a7a3ffd 100644 --- a/searchlib/src/vespa/searchlib/aggregation/hitsaggregationresult.cpp +++ b/searchlib/src/vespa/searchlib/aggregation/hitsaggregationresult.cpp @@ -2,6 +2,7 @@ #include "hitsaggregationresult.h" #include <vespa/document/fieldvalue/document.h> +#include <cassert> #include <vespa/log/log.h> LOG_SETUP(".searchlib.aggregation.hitsaggregationresult"); diff --git a/searchlib/src/vespa/searchlib/aggregation/maxaggregationresult.h b/searchlib/src/vespa/searchlib/aggregation/maxaggregationresult.h index 3d50c2a61d2..0e2f739798e 100644 --- a/searchlib/src/vespa/searchlib/aggregation/maxaggregationresult.h +++ b/searchlib/src/vespa/searchlib/aggregation/maxaggregationresult.h @@ -4,8 +4,7 @@ #include "aggregationresult.h" #include <vespa/searchlib/expression/singleresultnode.h> -namespace search { -namespace aggregation { +namespace search::aggregation { class MaxAggregationResult : public AggregationResult { @@ -24,4 +23,3 @@ private: }; } -} diff --git a/searchlib/src/vespa/searchlib/aggregation/minaggregationresult.h b/searchlib/src/vespa/searchlib/aggregation/minaggregationresult.h index c51c531af73..b30558684c2 100644 --- a/searchlib/src/vespa/searchlib/aggregation/minaggregationresult.h +++ b/searchlib/src/vespa/searchlib/aggregation/minaggregationresult.h @@ -4,8 +4,7 @@ #include "aggregationresult.h" #include <vespa/searchlib/expression/singleresultnode.h> -namespace search { -namespace aggregation { +namespace search::aggregation { class MinAggregationResult : public AggregationResult { @@ -24,4 +23,3 @@ private: }; } -} diff --git a/searchlib/src/vespa/searchlib/aggregation/modifiers.cpp b/searchlib/src/vespa/searchlib/aggregation/modifiers.cpp index e03caa27ed6..6b6f2a83436 100644 --- a/searchlib/src/vespa/searchlib/aggregation/modifiers.cpp +++ b/searchlib/src/vespa/searchlib/aggregation/modifiers.cpp @@ -8,8 +8,7 @@ using namespace search::expression; -namespace search { -namespace aggregation { +namespace search::aggregation { bool Attribute2DocumentAccessor::check(const vespalib::Identifiable &obj) const { @@ -50,7 +49,6 @@ void Attribute2DocumentAccessor::execute(vespalib::Identifiable &obj) } } -} // this function was added by ../../forcelink.sh void forcelink_file_searchlib_aggregation_modifiers() {} diff --git a/searchlib/src/vespa/searchlib/aggregation/modifiers.h b/searchlib/src/vespa/searchlib/aggregation/modifiers.h index e911aecc57e..27f4b3ce6a4 100644 --- a/searchlib/src/vespa/searchlib/aggregation/modifiers.h +++ b/searchlib/src/vespa/searchlib/aggregation/modifiers.h @@ -4,8 +4,7 @@ #include <vespa/vespalib/objects/objectoperation.h> #include <vespa/vespalib/objects/objectpredicate.h> -namespace search { -namespace aggregation { +namespace search::aggregation { class Attribute2DocumentAccessor : public vespalib::ObjectOperation, public vespalib::ObjectPredicate { @@ -15,5 +14,3 @@ private: }; } -} - diff --git a/searchlib/src/vespa/searchlib/aggregation/perdocexpression.h b/searchlib/src/vespa/searchlib/aggregation/perdocexpression.h index 11c7db46c24..47ba2ea732e 100644 --- a/searchlib/src/vespa/searchlib/aggregation/perdocexpression.h +++ b/searchlib/src/vespa/searchlib/aggregation/perdocexpression.h @@ -38,9 +38,6 @@ #include <vespa/searchlib/expression/debugwaitfunctionnode.h> #include <vespa/searchlib/expression/aggregationrefnode.h> -namespace search { -namespace aggregation { +namespace search::aggregation { } -} - diff --git a/searchlib/src/vespa/searchlib/aggregation/predicates.h b/searchlib/src/vespa/searchlib/aggregation/predicates.h index a123dcf1aa6..cd2b6863b4b 100644 --- a/searchlib/src/vespa/searchlib/aggregation/predicates.h +++ b/searchlib/src/vespa/searchlib/aggregation/predicates.h @@ -5,8 +5,7 @@ #include <vespa/vespalib/objects/objectpredicate.h> #include <vespa/vespalib/objects/objectoperation.h> -namespace search { -namespace aggregation { +namespace search::aggregation { class CountFS4Hits : public vespalib::ObjectPredicate, public vespalib::ObjectOperation @@ -43,5 +42,3 @@ public: }; } -} - diff --git a/searchlib/src/vespa/searchlib/aggregation/rawrank.h b/searchlib/src/vespa/searchlib/aggregation/rawrank.h index 4778ba8600f..a6f50c1291a 100644 --- a/searchlib/src/vespa/searchlib/aggregation/rawrank.h +++ b/searchlib/src/vespa/searchlib/aggregation/rawrank.h @@ -1,11 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -namespace search { -namespace aggregation { +namespace search::aggregation { typedef double RawRank; -} // namespace search::aggregation -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/aggregation/vdshit.cpp b/searchlib/src/vespa/searchlib/aggregation/vdshit.cpp index fab07dd4c70..67c01b58331 100644 --- a/searchlib/src/vespa/searchlib/aggregation/vdshit.cpp +++ b/searchlib/src/vespa/searchlib/aggregation/vdshit.cpp @@ -5,8 +5,7 @@ #include <vespa/vespalib/objects/serializer.hpp> #include <vespa/vespalib/objects/deserializer.hpp> -namespace search { -namespace aggregation { +namespace search::aggregation { using vespalib::FieldBase; using vespalib::Serializer; @@ -43,7 +42,6 @@ VdsHit::visitMembers(vespalib::ObjectVisitor &visitor) const } } -} // this function was added by ../../forcelink.sh void forcelink_file_searchlib_aggregation_vdshit() {} diff --git a/searchlib/src/vespa/searchlib/aggregation/vdshit.h b/searchlib/src/vespa/searchlib/aggregation/vdshit.h index ab4c55507b7..c6ad690d96c 100644 --- a/searchlib/src/vespa/searchlib/aggregation/vdshit.h +++ b/searchlib/src/vespa/searchlib/aggregation/vdshit.h @@ -5,8 +5,7 @@ #include "aggregationresult.h" #include <vespa/vespalib/util/array.h> -namespace search { -namespace aggregation { +namespace search::aggregation { class VdsHit : public Hit { @@ -37,5 +36,3 @@ private: }; } -} - diff --git a/searchlib/src/vespa/searchlib/aggregation/xoraggregationresult.h b/searchlib/src/vespa/searchlib/aggregation/xoraggregationresult.h index e203ce8ab65..99d23702508 100644 --- a/searchlib/src/vespa/searchlib/aggregation/xoraggregationresult.h +++ b/searchlib/src/vespa/searchlib/aggregation/xoraggregationresult.h @@ -4,8 +4,7 @@ #include "aggregationresult.h" #include <vespa/searchlib/expression/integerresultnode.h> -namespace search { -namespace aggregation { +namespace search::aggregation { class XorAggregationResult : public AggregationResult { @@ -25,4 +24,3 @@ private: }; } -} diff --git a/searchlib/src/vespa/searchlib/grouping/collect.cpp b/searchlib/src/vespa/searchlib/grouping/collect.cpp index de9552ae3e1..9b5a9a2aab1 100644 --- a/searchlib/src/vespa/searchlib/grouping/collect.cpp +++ b/searchlib/src/vespa/searchlib/grouping/collect.cpp @@ -2,6 +2,7 @@ #include "collect.h" #include <vespa/vespalib/util/array.hpp> +#include <cassert> namespace search { diff --git a/searchlib/src/vespa/searchlib/grouping/groupengine.cpp b/searchlib/src/vespa/searchlib/grouping/groupengine.cpp index 6138ddd01ad..aa289da068b 100644 --- a/searchlib/src/vespa/searchlib/grouping/groupengine.cpp +++ b/searchlib/src/vespa/searchlib/grouping/groupengine.cpp @@ -4,6 +4,7 @@ #include <vespa/searchlib/expression/nullresultnode.h> #include <vespa/searchlib/common/sort.h> #include <vespa/vespalib/stllike/hash_set.hpp> +#include <cassert> namespace search { diff --git a/searchlib/src/vespa/searchlib/grouping/groupingengine.cpp b/searchlib/src/vespa/searchlib/grouping/groupingengine.cpp index 083ac35c0e2..e494d827390 100644 --- a/searchlib/src/vespa/searchlib/grouping/groupingengine.cpp +++ b/searchlib/src/vespa/searchlib/grouping/groupingengine.cpp @@ -2,6 +2,7 @@ #include "groupingengine.h" #include "groupandcollectengine.h" +#include <cassert> namespace search { diff --git a/searchlib/src/vespa/searchlib/queryeval/multisearch.cpp b/searchlib/src/vespa/searchlib/queryeval/multisearch.cpp index 2e2ff650218..19d744dfd28 100644 --- a/searchlib/src/vespa/searchlib/queryeval/multisearch.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/multisearch.cpp @@ -2,9 +2,9 @@ #include "multisearch.h" #include <vespa/vespalib/objects/visit.hpp> +#include <cassert> -namespace search { -namespace queryeval { +namespace search::queryeval { void MultiSearch::insert(size_t index, SearchIterator::UP search) @@ -80,6 +80,4 @@ MultiSearch::visitMembers(vespalib::ObjectVisitor &visitor) const visit(visitor, "children", _children); } - -} // namespace queryeval -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/queryeval/multisearch.h b/searchlib/src/vespa/searchlib/queryeval/multisearch.h index 2391d3c6d5a..fc1a9ec11cd 100644 --- a/searchlib/src/vespa/searchlib/queryeval/multisearch.h +++ b/searchlib/src/vespa/searchlib/queryeval/multisearch.h @@ -5,8 +5,7 @@ #include "searchiterator.h" #include <vector> -namespace search { -namespace queryeval { +namespace search::queryeval { /** * A virtual intermediate class that serves as the basis for combining searches @@ -53,6 +52,4 @@ private: Children _children; }; -} // namespace queryeval -} // namespace search - +} diff --git a/staging_vespalib/src/tests/stllike/lrucache.cpp b/staging_vespalib/src/tests/stllike/lrucache.cpp index 4047f43237c..7dff35ae842 100644 --- a/staging_vespalib/src/tests/stllike/lrucache.cpp +++ b/staging_vespalib/src/tests/stllike/lrucache.cpp @@ -3,7 +3,6 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/stllike/lrucache_map.hpp> -#include <vespa/vespalib/util/linkedptr.h> using namespace vespalib; @@ -103,8 +102,8 @@ struct SharedHash { TEST("testCacheInsertOverResize") { - typedef vespalib::LinkedPtr<std::string> LS; - typedef lrucache_map< LruParam<int, LS> > Cache; + using LS = std::shared_ptr<std::string>; + using Cache = lrucache_map< LruParam<int, LS> >; Cache cache(100); size_t sum(0); diff --git a/staging_vespalib/src/vespa/vespalib/objects/identifiable.hpp b/staging_vespalib/src/vespa/vespalib/objects/identifiable.hpp index 55db9406d7b..ad31712ede9 100644 --- a/staging_vespalib/src/vespa/vespalib/objects/identifiable.hpp +++ b/staging_vespalib/src/vespa/vespalib/objects/identifiable.hpp @@ -17,7 +17,6 @@ */ #include "identifiable.h" -#include <vespa/vespalib/util/linkedptr.h> namespace vespalib { @@ -121,41 +120,4 @@ public: friend Deserializer & operator >> (Deserializer & is, IdentifiableSharedPtr<T> & agg) { return agg.deserialize(is); } }; -template <typename T> -class IdentifiableLinkedPtr : public LinkedPtr<T> -{ -public: - IdentifiableLinkedPtr(const T &t) : LinkedPtr<T>(t.clone()) {} - IdentifiableLinkedPtr(T * p=NULL) : LinkedPtr<T>(p) { } - int cmp(const IdentifiableLinkedPtr<T> &rhs) const { - const T *a = this->get(); - const T *b = rhs.get(); - if (a == 0) { - return (b == 0) ? 0 : -1; - } - return (b == 0) ? 1 : a->cmp(*b); - } - bool operator < (const IdentifiableLinkedPtr<T> &rhs) const { - return (cmp(rhs) < 0); - } - Serializer & serialize(Serializer & os) const { - if (this->get()) { - os.put(Identifiable::hasObjectField, uint8_t(1)) << *this->get(); - } else { - os.put(Identifiable::hasObjectField, uint8_t(0)); - } - return os; - } - Deserializer & deserialize(Deserializer & is) { - uint8_t hasObject; - is.get(Identifiable::hasObjectField, hasObject); - if (hasObject) { - this->reset(static_cast<T *>(Identifiable::create(is).release())); - } - return is; - } - friend Serializer & operator << (Serializer & os, const IdentifiableLinkedPtr<T> & agg) { return agg.serialize(os); } - friend Deserializer & operator >> (Deserializer & is, IdentifiableLinkedPtr<T> & agg) { return agg.deserialize(is); } -}; - } diff --git a/staging_vespalib/src/vespa/vespalib/objects/visit.hpp b/staging_vespalib/src/vespa/vespalib/objects/visit.hpp index 57d753b82f4..797e77a7244 100644 --- a/staging_vespalib/src/vespa/vespalib/objects/visit.hpp +++ b/staging_vespalib/src/vespa/vespalib/objects/visit.hpp @@ -35,25 +35,11 @@ void visit(vespalib::ObjectVisitor &self, const vespalib::string &name, const st } template<typename T> -void visit(vespalib::ObjectVisitor &self, const vespalib::string &name, const vespalib::LinkedPtr<T> &ptr) { - if (ptr.get()) { - visit(self, name, *ptr); - } else { - self.visitNull(name); - } -} - -template<typename T> void visit(vespalib::ObjectVisitor &self, const vespalib::string &name, const vespalib::IdentifiablePtr<T> &ptr) { visit(self, name, ptr.get()); } template<typename T> -void visit(vespalib::ObjectVisitor &self, const vespalib::string &name, const vespalib::IdentifiableLinkedPtr<T> &ptr) { - visit(self, name, ptr.get()); -} - -template<typename T> void visit(vespalib::ObjectVisitor &self, const vespalib::string &name, const vespalib::IdentifiableSharedPtr<T> &ptr) { visit(self, name, ptr.get()); } diff --git a/vespalib/CMakeLists.txt b/vespalib/CMakeLists.txt index cab5ce0ff4a..112f67f3a70 100644 --- a/vespalib/CMakeLists.txt +++ b/vespalib/CMakeLists.txt @@ -43,7 +43,6 @@ vespa_define_module( src/tests/io/fileutil src/tests/io/mapped_file_input src/tests/left_right_heap - src/tests/linkedptr src/tests/make_fixture_macros src/tests/memory src/tests/net/async_resolver diff --git a/vespalib/src/testlist.txt b/vespalib/src/testlist.txt index 68a1136e025..d21a06654c8 100644 --- a/vespalib/src/testlist.txt +++ b/vespalib/src/testlist.txt @@ -35,7 +35,6 @@ tests/hashmap tests/host_name tests/io/fileutil tests/left_right_heap -tests/linkedptr tests/make_fixture_macros tests/memory tests/net/socket diff --git a/vespalib/src/tests/linkedptr/.gitignore b/vespalib/src/tests/linkedptr/.gitignore deleted file mode 100644 index ca9a6b595b2..00000000000 --- a/vespalib/src/tests/linkedptr/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.depend -Makefile -linkedptr_test -vespalib_linkedptr_test_app diff --git a/vespalib/src/tests/linkedptr/CMakeLists.txt b/vespalib/src/tests/linkedptr/CMakeLists.txt deleted file mode 100644 index be3354f1af4..00000000000 --- a/vespalib/src/tests/linkedptr/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(vespalib_linkedptr_test_app TEST - SOURCES - linkedptr_test.cpp - DEPENDS - vespalib -) -vespa_add_test(NAME vespalib_linkedptr_test_app COMMAND vespalib_linkedptr_test_app) diff --git a/vespalib/src/tests/linkedptr/DESC b/vespalib/src/tests/linkedptr/DESC deleted file mode 100644 index fed98e9b552..00000000000 --- a/vespalib/src/tests/linkedptr/DESC +++ /dev/null @@ -1 +0,0 @@ -Unit test for the LinkedPtr class. diff --git a/vespalib/src/tests/linkedptr/FILES b/vespalib/src/tests/linkedptr/FILES deleted file mode 100644 index 0a10d16f5bc..00000000000 --- a/vespalib/src/tests/linkedptr/FILES +++ /dev/null @@ -1 +0,0 @@ -linkedptr.cpp diff --git a/vespalib/src/tests/linkedptr/linkedptr_test.cpp b/vespalib/src/tests/linkedptr/linkedptr_test.cpp deleted file mode 100644 index 173507c7e18..00000000000 --- a/vespalib/src/tests/linkedptr/linkedptr_test.cpp +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/vespalib/util/linkedptr.h> -#include <vespa/vespalib/testkit/testapp.h> - -using vespalib::LinkedPtr; - - -class Test : public vespalib::TestApp -{ -public: - void testEmpty(); - void testSimple(); - void testCopy(); - void testReset(); - void testAccess(); - void testRelease(); - void testEqual(); - int Main() override; -}; - - -struct Data -{ - int ctorCnt; - int dtorCnt; - Data() : ctorCnt(0), dtorCnt(0) {} -}; - - -class DataRef -{ -private: - Data &_d; - DataRef(const DataRef &); - DataRef &operator=(const DataRef &); -public: - DataRef(Data &d) : _d(d) { ++d.ctorCnt; } - ~DataRef() { ++_d.dtorCnt; } - int getCtorCnt() const { return _d.ctorCnt; } - int getDtorCnt() const { return _d.dtorCnt; } -}; -typedef LinkedPtr<DataRef> PT; - -PT copyPT(const PT &pt) { return pt; } - -void -Test::testEmpty() -{ - PT pt1; - PT pt2(NULL); - EXPECT_TRUE(pt1.get() == NULL); - EXPECT_TRUE(pt2.get() == NULL); -} - -void -Test::testRelease() -{ - { - PT p(NULL); - EXPECT_TRUE(p.release() == NULL); - } - { - Data data; - PT p(new DataRef(data)); - std::unique_ptr<DataRef> ap(p.release()); - EXPECT_TRUE(ap.get() != NULL); - EXPECT_TRUE(p.release() == NULL); - } - { - Data data; - PT p(new DataRef(data)); - PT p2(p); - EXPECT_TRUE(p.release() == NULL); - EXPECT_TRUE(p2.release() == NULL); - EXPECT_TRUE(p.get() != NULL); - EXPECT_TRUE(p2.get() != NULL); - } -} - - -void -Test::testSimple() -{ - Data data; - { - PT pt1(new DataRef(data)); - EXPECT_EQUAL(data.ctorCnt, 1); - EXPECT_EQUAL(data.dtorCnt, 0); - } - EXPECT_EQUAL(data.ctorCnt, 1); - EXPECT_EQUAL(data.dtorCnt, 1); -} - - -void -Test::testCopy() -{ - Data data; - { - PT pt3; - { - PT pt1(new DataRef(data)); - PT pt2(pt1); - EXPECT_TRUE(pt1.get() == pt2.get()); - EXPECT_TRUE(pt3.get() == NULL); - pt3 = pt1; - EXPECT_TRUE(pt3.get() == pt1.get()); - { - PT pt4; - PT pt5 = pt1; - EXPECT_TRUE(pt4.get() == NULL); - EXPECT_TRUE(pt5.get() == pt1.get()); - pt4 = pt5; - EXPECT_TRUE(pt4.get() == pt1.get()); - { - PT pt6 = copyPT(pt3); - PT pt7; - EXPECT_TRUE(pt6.get() == pt1.get()); - EXPECT_TRUE(pt7.get() == NULL); - pt7 = copyPT(pt5); - EXPECT_TRUE(pt7.get() == pt1.get()); - { - PT pt8 = pt1; - EXPECT_TRUE(pt8.get() == pt1.get()); - pt8 = pt8; - EXPECT_TRUE(pt8.get() == pt1.get()); - EXPECT_EQUAL(data.ctorCnt, 1); - EXPECT_EQUAL(data.dtorCnt, 0); - } - EXPECT_EQUAL(data.ctorCnt, 1); - EXPECT_EQUAL(data.dtorCnt, 0); - } - EXPECT_EQUAL(data.ctorCnt, 1); - EXPECT_EQUAL(data.dtorCnt, 0); - } - EXPECT_EQUAL(data.ctorCnt, 1); - EXPECT_EQUAL(data.dtorCnt, 0); - } - EXPECT_EQUAL(data.ctorCnt, 1); - EXPECT_EQUAL(data.dtorCnt, 0); - } - EXPECT_EQUAL(data.ctorCnt, 1); - EXPECT_EQUAL(data.dtorCnt, 1); -} - - -void -Test::testReset() -{ - Data data; - { - PT pt1(new DataRef(data)); - EXPECT_EQUAL(data.ctorCnt, 1); - EXPECT_EQUAL(data.dtorCnt, 0); - pt1.reset(new DataRef(data)); - EXPECT_EQUAL(data.ctorCnt, 2); - EXPECT_EQUAL(data.dtorCnt, 1); - pt1.reset(); - EXPECT_EQUAL(data.ctorCnt, 2); - EXPECT_EQUAL(data.dtorCnt, 2); - pt1.reset(new DataRef(data)); - EXPECT_EQUAL(data.ctorCnt, 3); - EXPECT_EQUAL(data.dtorCnt, 2); - { - PT pt2(pt1); - pt1.reset(new DataRef(data)); - EXPECT_EQUAL(data.ctorCnt, 4); - EXPECT_EQUAL(data.dtorCnt, 2); - } - EXPECT_EQUAL(data.ctorCnt, 4); - EXPECT_EQUAL(data.dtorCnt, 3); - } - EXPECT_EQUAL(data.ctorCnt, 4); - EXPECT_EQUAL(data.dtorCnt, 4); -} - - -void -Test::testAccess() -{ - Data data; - { - PT pt1(new DataRef(data)); - EXPECT_EQUAL(pt1->getCtorCnt(), 1); - EXPECT_EQUAL((*pt1).getDtorCnt(), 0); - } -} - -class A { - int _v; -public: - A(int v) : _v(v) {} - bool operator == (const A & rhs) const { return _v == rhs._v; } -}; -typedef LinkedPtr<A> ALP; - -void -Test::testEqual() -{ - ALP a(new A(1)); - ALP a2(new A(1)); - ALP b(new A(2)); - ALP c; - EXPECT_TRUE(a == a); - EXPECT_TRUE(a2 == a2); - EXPECT_TRUE(a == a2); - EXPECT_TRUE(a2 == a); - EXPECT_TRUE(b == b); - EXPECT_TRUE(c == c); - EXPECT_FALSE(a == b); - EXPECT_FALSE(b == c); - EXPECT_FALSE(a == c); - EXPECT_FALSE(c == a); -} - -int -Test::Main() -{ - TEST_INIT("linkedptr_test"); - testEmpty(); - testSimple(); - testCopy(); - testEqual(); - testReset(); - testAccess(); - testRelease(); - TEST_DONE(); -} - -TEST_APPHOOK(Test) diff --git a/vespalib/src/vespa/vespalib/util/linkedptr.h b/vespalib/src/vespa/vespalib/util/linkedptr.h deleted file mode 100644 index 517208b9ef9..00000000000 --- a/vespalib/src/vespa/vespalib/util/linkedptr.h +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// Copyright (C) 2004 Overture Services Norway AS - -#pragma once - -#include <algorithm> -#include <memory> -#include <cassert> - -namespace vespalib { - -/** - * @brief A LinkedPtr is a smart pointer implementing reference - * linking. - * - * Multiple instances share the ownership of an object by being linked - * together. This has the advantage of not needing external - * book-keeping. However, note that LinkedPtr may only be used to - * share objects within a thread, as there is no internal - * synchronization. - * - * If you need to share an object between threads, take a look at - * std::shared_ptr. - **/ -template <typename T> -class LinkedPtr -{ -private: - - mutable const LinkedPtr *_prev; - mutable const LinkedPtr *_next; - T *_obj; - - /** - * Unlink this pointer - **/ - void unlink() { - if (_prev == this) { - delete _obj; - } else { - _prev->_next = _next; - _next->_prev = _prev; - } - } - - /** - * Link this pointer - **/ - void link(const LinkedPtr &rhs) { - if (rhs._obj != 0) { - _obj = rhs._obj; - _prev = &rhs; - _next = rhs._next; - rhs._next = this; - _next->_prev = this; - } else { - _obj = 0; - _next = this; - _prev = this; - } - } - -public: - /** - * @brief Create a LinkedPtr owning the given object - * - * @param obj the object, may be 0 - **/ - explicit LinkedPtr(T *obj = 0) - : _prev(this), _next(this), _obj(obj) {} - - /** - * @brief Copy constructor - * - * Copying a LinkedPtr will result in a new LinkedPtr sharing the - * ownership of the object held by the original LinkedPtr. - * - * @param rhs copy this - **/ - LinkedPtr(const LinkedPtr &rhs) - : _prev(this), _next(this), _obj(0) - { - link(rhs); - } - - /** - * @brief Delete the pointed to object if we are the last - * LinkedPtr sharing ownership of it - **/ - ~LinkedPtr() { - unlink(); - } - - /** - * @brief Assignment operator - * - * @return reference to this - * @param rhs copy this - **/ - LinkedPtr &operator= (const LinkedPtr &rhs) { - if (_obj == rhs._obj) { - return *this; - } - unlink(); - link(rhs); - return *this; - } - - /** - * @brief Check if this LinkedPtr points to anything - * - * @return true if we point to something - **/ - bool isSet() const { return (_obj != 0); } - - /** - * @brief Obtain the object being pointed to - * - * @return the object (by pointer) - **/ - T *get() const { return _obj; } - - bool operator == (const LinkedPtr & rhs) const { return (_obj == rhs._obj) || - ( (_obj != NULL) && - (rhs._obj != NULL) && - (*_obj == *rhs._obj)); } - - /** - * @brief Access the object being pointed to - * - * This is the preferred way to access the object being pointed to - * as it makes the LinkedPtr look like a naked pointer. - * - * @return the object (by pointer) - **/ - T *operator->() const { return get(); } - - /** - * @brief Obtain the object being pointed to - * - * @return the object (by reference) - **/ - T &operator*() const { return *get(); } - - /** - * @brief Change this pointer - * - * This method makes this LinkedPtr drop its current pointer and - * point to something new. If we are the last owner of the old - * object, it is deleted. The new object will be owned by this - * LinkedPtr (just like when using the constructor). - * - * @param obj the object, may be 0 - **/ - void reset(T *obj = 0) { - unlink(); - _obj = obj; - _next = this; - _prev = this; - } - - /** - * @brief release the object pointed to - * - * This is an operation that can only be done when this is the only item - * in the list. - * - * @return the pointer to the owned object or NULL if it is not the only - * owner. - **/ - T * release() { - T * obj(NULL); - if ((_next == _prev) && (_prev == this)) { - obj = _obj; - _obj = NULL; - } - return obj; - } -}; - -} // namespace vespalib diff --git a/vespalib/src/vespa/vespalib/util/overview.h b/vespalib/src/vespa/vespalib/util/overview.h index 7fc48e2f19e..7849887a14c 100644 --- a/vespalib/src/vespa/vespalib/util/overview.h +++ b/vespalib/src/vespa/vespalib/util/overview.h @@ -37,10 +37,6 @@ * * <BR> vespalib::ReferenceCounter * - * Simple smart pointers (deprecated) - * - * <BR> \ref vespalib::LinkedPtr<T> - * * Advanced pointer utilities * * \ref vespalib::PtrHolder<T> |