diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-04-25 14:44:04 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2024-04-25 14:44:04 +0000 |
commit | 1205b1e49be43416e4bf27df141db1983075a7ed (patch) | |
tree | 02de29365a697f56d785a168a007ff7a9bec0ac0 /searchlib | |
parent | 16ac700c95696e3c22c123816428ac877a86f233 (diff) |
Use std::vector
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/grouping/collect.cpp | 11 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/grouping/collect.h | 18 |
2 files changed, 13 insertions, 16 deletions
diff --git a/searchlib/src/vespa/searchlib/grouping/collect.cpp b/searchlib/src/vespa/searchlib/grouping/collect.cpp index d0a9a38bf7d..464362602f2 100644 --- a/searchlib/src/vespa/searchlib/grouping/collect.cpp +++ b/searchlib/src/vespa/searchlib/grouping/collect.cpp @@ -1,7 +1,6 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "collect.h" -#include <vespa/vespalib/util/array.hpp> #include <cassert> using namespace search::expression; @@ -48,8 +47,7 @@ Collect::~Collect() assert((_aggrBacking.size() % _aggregatorSize) == 0); for (size_t i(0), m(_aggrBacking.size()/_aggregatorSize); i < m; i++) { uint8_t * base(&_aggrBacking[ i * _aggregatorSize]); - for (size_t j(0), k(_aggregator.size()); j < k; j++) { - ResultAccessor & r = _aggregator[j]; + for (auto & r : _aggregator) { r.destroy(base); } } @@ -74,8 +72,8 @@ void Collect::collect(GroupRef gr, uint32_t docId, double rank) { uint8_t * base(&_aggrBacking[getAggrBase(gr)]); - for (size_t i(0), m(_aggregator.size()); i < m; i++) { - _aggregator[i].aggregate(base, docId, rank); + for (auto & i : _aggregator) { + i.aggregate(base, docId, rank); } } @@ -86,8 +84,7 @@ Collect::createCollectors(GroupRef gr) if (offset == _aggrBacking.size()) { _aggrBacking.resize(getAggrBase(GroupRef(gr.getRef() + 1))); uint8_t * base(&_aggrBacking[offset]); - for (size_t i(0), m(_aggregator.size()); i < m; i++) { - ResultAccessor & r = _aggregator[i]; + for (auto & r : _aggregator) { r.create(base); } } diff --git a/searchlib/src/vespa/searchlib/grouping/collect.h b/searchlib/src/vespa/searchlib/grouping/collect.h index 3566d21f821..932cf559156 100644 --- a/searchlib/src/vespa/searchlib/grouping/collect.h +++ b/searchlib/src/vespa/searchlib/grouping/collect.h @@ -13,7 +13,7 @@ public: Collect(const Collect &) = delete; Collect & operator = (const Collect &) = delete; protected: - Collect(const aggregation::Group & protoType); + explicit Collect(const aggregation::Group & protoType); ~Collect(); void preFill(GroupRef gr, const aggregation::Group & r); void createCollectors(GroupRef gr); @@ -55,9 +55,9 @@ private: */ class ResultAccessor { public: - ResultAccessor() : _bluePrint(NULL), _aggregator(NULL), _offset(0) { } + ResultAccessor() noexcept : _bluePrint(nullptr), _aggregator(nullptr), _offset(0) { } ResultAccessor(const aggregation::AggregationResult & aggregator, size_t offset); - void setResult(const expression::ResultNode & result, uint8_t * base) { + void setResult(const expression::ResultNode & result, uint8_t * base) const { result.encode(base+_offset); } const expression::ResultNode & getResult(expression::ResultNode & result, const uint8_t * base) const { @@ -86,8 +86,8 @@ private: mutable vespalib::IdentifiablePtr<aggregation::AggregationResult> _aggregator; uint32_t _offset; }; - using AggregatorBacking = vespalib::Array<uint8_t>; - using ResultAccessorList = vespalib::Array<ResultAccessor>; + using AggregatorBacking = std::vector<uint8_t>; + using ResultAccessorList = std::vector<ResultAccessor>; class SortInfo { public: SortInfo() noexcept : _index(0), _sign(1) { } @@ -98,10 +98,10 @@ private: uint8_t _index; // Which index in the aggragators should be used for sorting this level. int8_t _sign; // And which way. positive number -> ascending, negative number descending. }; - size_t _aggregatorSize; // This is the bytesize required to store the aggrgate values per bucket. - ResultAccessorList _aggregator; // These are the accessors to use when accessing the results. - AggregatorBacking _aggrBacking; // This is the storage for the accessors. - std::vector<SortInfo> _sortInfo; // Generated cheap sortInfo, to avoid accessing more complicated data. + size_t _aggregatorSize; // This is the bytesize required to store the aggrgate values per bucket. + ResultAccessorList _aggregator; // These are the accessors to use when accessing the results. + AggregatorBacking _aggrBacking; // This is the storage for the accessors. + std::vector<SortInfo> _sortInfo; // Generated cheap sortInfo, to avoid accessing more complicated data. }; } |