diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-03-14 18:17:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 18:17:24 +0100 |
commit | d8ce9e0e76d317c32b703a899c78e78720be708d (patch) | |
tree | 388716daa313ac58eec25b613a8cffef78eae268 | |
parent | d7ade13fee737d8b214bb87c164684fdfcb6970f (diff) | |
parent | 992e6a6bbe7fb7ae5d122c65c07843655a78cb57 (diff) |
Merge pull request #26442 from vespa-engine/balder/less-use-of-vespalib-array
Prefer std::vector
12 files changed, 22 insertions, 89 deletions
diff --git a/searchlib/src/vespa/searchlib/aggregation/fs4hit.h b/searchlib/src/vespa/searchlib/aggregation/fs4hit.h index 9a3bceb22d4..af09d3ff26b 100644 --- a/searchlib/src/vespa/searchlib/aggregation/fs4hit.h +++ b/searchlib/src/vespa/searchlib/aggregation/fs4hit.h @@ -19,16 +19,15 @@ public: DECLARE_IDENTIFIABLE_NS2(search, aggregation, FS4Hit); DECLARE_NBO_SERIALIZE; FS4Hit() noexcept : Hit(), _path(0), _docId(0), _globalId(), _distributionKey(-1) {} - FS4Hit(DocId docId, HitRank rank) + FS4Hit(DocId docId, HitRank rank) noexcept : Hit(rank), _path(0), _docId(docId), _globalId(), _distributionKey(-1) {} FS4Hit *clone() const override { return new FS4Hit(*this); } void visitMembers(vespalib::ObjectVisitor &visitor) const override; - uint32_t getPath() const { return _path; } - FS4Hit &setPath(uint32_t val) { _path = val; return *this; } - uint32_t getDocId() const { return _docId; } - const document::GlobalId & getGlobalId() const { return _globalId; } - FS4Hit &setGlobalId(const document::GlobalId & globalId) { _globalId = globalId; return *this; } - FS4Hit &setDistributionKey(uint32_t val) { _distributionKey = val; return *this; } + uint32_t getPath() const noexcept { return _path; } + uint32_t getDocId() const noexcept { return _docId; } + const document::GlobalId & getGlobalId() const noexcept { return _globalId; } + FS4Hit &setGlobalId(const document::GlobalId & globalId) noexcept { _globalId = globalId; return *this; } + FS4Hit &setDistributionKey(uint32_t val) noexcept { _distributionKey = val; return *this; } bool operator < (const FS4Hit &b) const { return cmp(b) < 0; } }; diff --git a/searchlib/src/vespa/searchlib/aggregation/vdshit.h b/searchlib/src/vespa/searchlib/aggregation/vdshit.h index c2f55f8a0bb..8908eda6574 100644 --- a/searchlib/src/vespa/searchlib/aggregation/vdshit.h +++ b/searchlib/src/vespa/searchlib/aggregation/vdshit.h @@ -3,32 +3,31 @@ #include "hit.h" #include "aggregationresult.h" -#include <vespa/vespalib/util/array.h> namespace search::aggregation { class VdsHit : public Hit { public: - using Summary = vespalib::Array<uint8_t>; + using Summary = std::vector<uint8_t>; using DocId = vespalib::string; DECLARE_IDENTIFIABLE_NS2(search, aggregation, VdsHit); DECLARE_NBO_SERIALIZE; - VdsHit() : Hit(), _docId(), _summary() {} - VdsHit(DocId docId, HitRank rank) : Hit(rank), _docId(docId), _summary() {} + VdsHit() noexcept : Hit(), _docId(), _summary() {} + VdsHit(DocId docId, HitRank rank) noexcept : Hit(rank), _docId(docId), _summary() {} ~VdsHit(); VdsHit *clone() const override { return new VdsHit(*this); } void visitMembers(vespalib::ObjectVisitor &visitor) const override; - const DocId & getDocId() const { return _docId; } - const Summary & getSummary() const { return _summary; } - VdsHit & setDocId(DocId & docId) { _docId = docId; return *this; } - VdsHit & setSummary(const void * buf, size_t sz) { + const DocId & getDocId() const noexcept { return _docId; } + const Summary & getSummary() const noexcept { return _summary; } + VdsHit & setDocId(DocId & docId) noexcept { _docId = docId; return *this; } + VdsHit & setSummary(const void * buf, size_t sz) noexcept { const uint8_t * v(static_cast<const uint8_t *>(buf)); Summary n(v, v+sz); _summary.swap(n); return *this; } - bool operator < (const VdsHit &b) const { return cmp(b) < 0; } + bool operator < (const VdsHit &b) const noexcept { return cmp(b) < 0; } private: DocId _docId; diff --git a/searchlib/src/vespa/searchlib/grouping/collect.cpp b/searchlib/src/vespa/searchlib/grouping/collect.cpp index 11e297fef2a..9085b08d0f2 100644 --- a/searchlib/src/vespa/searchlib/grouping/collect.cpp +++ b/searchlib/src/vespa/searchlib/grouping/collect.cpp @@ -4,12 +4,10 @@ #include <vespa/vespalib/util/array.hpp> #include <cassert> -namespace search { +using namespace search::expression; +using namespace search::aggregation; -using namespace expression; -using namespace aggregation; - -namespace grouping { +namespace search::grouping { Collect::ResultAccessor::ResultAccessor(const AggregationResult & aggregator, size_t offset) : _bluePrint(&aggregator), @@ -109,7 +107,6 @@ Collect::preFill(GroupRef gr, const Group & g) } } -} // this function was added by ../../forcelink.sh void forcelink_file_searchlib_grouping_collect() {} diff --git a/searchlib/src/vespa/searchlib/grouping/collect.h b/searchlib/src/vespa/searchlib/grouping/collect.h index 5c27fd7e431..34906e90324 100644 --- a/searchlib/src/vespa/searchlib/grouping/collect.h +++ b/searchlib/src/vespa/searchlib/grouping/collect.h @@ -3,9 +3,9 @@ #include "groupref.h" #include <vespa/searchlib/aggregation/group.h> +#include <vespa/vespalib/util/array.h> -namespace search { -namespace grouping { +namespace search::grouping { class Collect { @@ -105,4 +105,3 @@ private: }; } -} diff --git a/streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.h b/streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.h index bde23efad5a..55aabf3c0cf 100644 --- a/streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.h +++ b/streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.h @@ -5,6 +5,7 @@ #include <vespa/searchlib/query/streaming/query.h> #include <vespa/vsm/common/document.h> #include <vespa/vsm/common/storagedocument.h> +#include <vespa/vespalib/util/array.h> namespace vsm { diff --git a/vespalib/src/tests/objects/nbostream/nbostream_test.cpp b/vespalib/src/tests/objects/nbostream/nbostream_test.cpp index 5d7f5c0504b..20ea2bf5aaa 100644 --- a/vespalib/src/tests/objects/nbostream/nbostream_test.cpp +++ b/vespalib/src/tests/objects/nbostream/nbostream_test.cpp @@ -216,16 +216,6 @@ TEST_F("Test serializing vespalib::string", Fixture) f.assertSerialize(exp, val); } -TEST_F("Test serializing vespalib::Array", Fixture) -{ - vespalib::Array<int16_t> val; - val.resize(2); - val[0] = 0x0123; - val[1] = 0x4567; - ExpBuffer exp({ 0x00, 0x00, 0x00, 0x02, 0x01, 0x23, 0x45, 0x67 }); - f.assertSerialize(exp, val); -} - TEST_F("Test serializing std::vector", Fixture) { std::vector<int16_t> val({ 0x0123, 0x4567 }); diff --git a/vespalib/src/vespa/vespalib/objects/deserializer.h b/vespalib/src/vespa/vespalib/objects/deserializer.h index e59d3e07581..dcb1b5176cb 100644 --- a/vespalib/src/vespa/vespalib/objects/deserializer.h +++ b/vespalib/src/vespa/vespalib/objects/deserializer.h @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/vespalib/util/array.h> #include <vespa/vespalib/stllike/string.h> #include <vector> #include <cstdint> @@ -44,11 +43,7 @@ public: Deserializer & operator >> (double & value) { return get(value); } Deserializer & operator >> (string & value) { return get(value); } template <typename T> - Deserializer & operator >> (vespalib::Array<T> & v); - template <typename T> Deserializer & operator >> (std::vector<T> & v); - }; } - diff --git a/vespalib/src/vespa/vespalib/objects/deserializer.hpp b/vespalib/src/vespa/vespalib/objects/deserializer.hpp index b90867fa153..cf9bd5b0a48 100644 --- a/vespalib/src/vespa/vespalib/objects/deserializer.hpp +++ b/vespalib/src/vespa/vespalib/objects/deserializer.hpp @@ -7,18 +7,6 @@ namespace vespalib { template <typename T> Deserializer & -Deserializer::operator >> (vespalib::Array<T> & v) { - uint32_t sz; - get(sz); - v.resize(sz); - for(size_t i(0); i < sz; i++) { - (*this) >> v[i]; - } - return *this; -} - -template <typename T> -Deserializer & Deserializer::operator >> (std::vector<T> & v) { uint32_t sz; get(sz); diff --git a/vespalib/src/vespa/vespalib/objects/nbostream.h b/vespalib/src/vespa/vespalib/objects/nbostream.h index 12d4fac04cc..bf2adc7b486 100644 --- a/vespalib/src/vespa/vespalib/objects/nbostream.h +++ b/vespalib/src/vespa/vespalib/objects/nbostream.h @@ -87,25 +87,6 @@ public: return *this; } template <typename T> - nbostream & operator << (const vespalib::Array<T> & v) { - uint32_t sz(v.size()); - (*this) << sz; - for(size_t i(0); i < sz; i++) { - (*this) << v[i]; - } - return *this; - } - template <typename T> - nbostream & operator >> (vespalib::Array<T> & v) { - uint32_t sz; - (*this) >> sz; - v.resize(sz); - for(size_t i(0); i < sz; i++) { - (*this) >> v[i]; - } - return *this; - } - template <typename T> nbostream & operator << (const std::vector<T> & v) { uint32_t sz(v.size()); (*this) << sz; @@ -175,8 +156,6 @@ public: } void swap(Buffer & buf); void swap(nbostream & os); - /** extract the underlying Array<char>; nbostream will be empty afterwards. */ - Buffer extract_buffer() { Buffer rv; swap(rv); return rv; } /** * This flag can be used to tell that a buffer will live at least as long as * any objects it will be the backing for. In those cases there is no need for diff --git a/vespalib/src/vespa/vespalib/objects/serializer.h b/vespalib/src/vespa/vespalib/objects/serializer.h index f10d03b1c04..f8a43ab104a 100644 --- a/vespalib/src/vespa/vespalib/objects/serializer.h +++ b/vespalib/src/vespa/vespalib/objects/serializer.h @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/vespalib/util/array.h> #include <vespa/vespalib/stllike/string.h> #include <vector> #include <cstdint> @@ -42,10 +41,7 @@ public: Serializer & operator << (double value) { return put(value); } Serializer & operator << (stringref value) { return put(value); } template <typename T> - Serializer & operator << (const vespalib::Array<T> & v); - template <typename T> Serializer & operator << (const std::vector<T> & v); }; } - diff --git a/vespalib/src/vespa/vespalib/objects/serializer.hpp b/vespalib/src/vespa/vespalib/objects/serializer.hpp index 87c02ddf693..1962ddd4359 100644 --- a/vespalib/src/vespa/vespalib/objects/serializer.hpp +++ b/vespalib/src/vespa/vespalib/objects/serializer.hpp @@ -9,16 +9,6 @@ namespace vespalib { template <typename T> Serializer & -Serializer::operator << (const vespalib::Array<T> & v) { - uint32_t sz(v.size()); - put(sz); - for(size_t i(0); i < sz; i++) { - (*this) << v[i]; - } - return *this; -} -template <typename T> -Serializer & Serializer::operator << (const std::vector<T> & v) { uint32_t sz(v.size()); put(sz); diff --git a/vespalib/src/vespa/vespalib/objects/visit.hpp b/vespalib/src/vespa/vespalib/objects/visit.hpp index e3a82b212c0..9838e331823 100644 --- a/vespalib/src/vespa/vespalib/objects/visit.hpp +++ b/vespalib/src/vespa/vespalib/objects/visit.hpp @@ -2,9 +2,9 @@ #pragma once #include "visit.h" -#include <vector> -#include <vespa/vespalib/util/stringfmt.h> #include "objectvisitor.h" +#include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/array.h> #include "identifiable.hpp" template<typename T> |