aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-04-26 00:49:59 +0200
committerGitHub <noreply@github.com>2024-04-26 00:49:59 +0200
commit3e9c0852a76a0e7264f570bd6e0d45bf2117c3d4 (patch)
treef16b7c275b624dbea4cfbb481c2bc0ebfe7acf70
parent132dd98f94821183ec49ac2774a54bf0dc4904fd (diff)
parent1205b1e49be43416e4bf27df141db1983075a7ed (diff)
Merge pull request #31051 from vespa-engine/balder/use-std-vector
Use std::vector
-rw-r--r--searchlib/src/vespa/searchlib/grouping/collect.cpp11
-rw-r--r--searchlib/src/vespa/searchlib/grouping/collect.h18
-rw-r--r--vespalib/src/vespa/vespalib/data/memorydatastore.h1
-rw-r--r--vespalib/src/vespa/vespalib/objects/nbostream.h8
-rw-r--r--vespalib/src/vespa/vespalib/util/rcuvector.h2
5 files changed, 16 insertions, 24 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.
};
}
diff --git a/vespalib/src/vespa/vespalib/data/memorydatastore.h b/vespalib/src/vespa/vespalib/data/memorydatastore.h
index 0bf2becf7c3..3682e3629e3 100644
--- a/vespalib/src/vespa/vespalib/data/memorydatastore.h
+++ b/vespalib/src/vespa/vespalib/data/memorydatastore.h
@@ -2,7 +2,6 @@
#pragma once
#include <vespa/vespalib/util/alloc.h>
-#include <vespa/vespalib/util/array.h>
#include <vector>
#include <mutex>
diff --git a/vespalib/src/vespa/vespalib/objects/nbostream.h b/vespalib/src/vespa/vespalib/objects/nbostream.h
index ab02e7c1f05..f66c261ae91 100644
--- a/vespalib/src/vespa/vespalib/objects/nbostream.h
+++ b/vespalib/src/vespa/vespalib/objects/nbostream.h
@@ -107,17 +107,13 @@ public:
}
template <typename T, typename U>
- nbostream &
- operator<<(const std::pair<T, U> &val)
- {
+ nbostream & operator<<(const std::pair<T, U> &val) {
*this << val.first << val.second;
return *this;
}
template <typename T, typename U>
- nbostream &
- operator>>(std::pair<T, U> &val)
- {
+ nbostream & operator>>(std::pair<T, U> &val) {
*this >> val.first >> val.second;
return *this;
}
diff --git a/vespalib/src/vespa/vespalib/util/rcuvector.h b/vespalib/src/vespa/vespalib/util/rcuvector.h
index dcd3fcd8052..787fb2d00c6 100644
--- a/vespalib/src/vespa/vespalib/util/rcuvector.h
+++ b/vespalib/src/vespa/vespalib/util/rcuvector.h
@@ -19,7 +19,7 @@ class RcuVectorHeld : public GenerationHeldBase
public:
RcuVectorHeld(size_t size, T&& data);
- ~RcuVectorHeld();
+ ~RcuVectorHeld() override;
};