diff options
author | Tor Egge <Tor.Egge@yahooinc.com> | 2022-04-06 14:37:32 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@yahooinc.com> | 2022-04-06 14:37:32 +0200 |
commit | bd880deb08ddca54e5fce63763e86af59bfbce88 (patch) | |
tree | f1f873cdcc2730ab7b34a45918b544b51ddffee0 /vespalib | |
parent | 3c4cddd0b08666e497996e7f5b499e5a86fc68eb (diff) |
Add MultiValueMappingReadView, used by readers to get limited read access
to a MultiValueMapping.
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/arrayref.h | 2 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/rcuvector.h | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/vespalib/src/vespa/vespalib/util/arrayref.h b/vespalib/src/vespa/vespalib/util/arrayref.h index db3b39f400d..bc1fc540a6c 100644 --- a/vespalib/src/vespa/vespalib/util/arrayref.h +++ b/vespalib/src/vespa/vespalib/util/arrayref.h @@ -42,7 +42,7 @@ public: ConstArrayRef(const SmallVector<T, N> &v) noexcept : _v(&v[0]), _sz(v.size()) { } ConstArrayRef(const ArrayRef<T> & v) noexcept : _v(&v[0]), _sz(v.size()) { } ConstArrayRef(const Array<T> &v) noexcept : _v(&v[0]), _sz(v.size()) { } - ConstArrayRef() noexcept : _v(nullptr), _sz(0) {} + constexpr ConstArrayRef() noexcept : _v(nullptr), _sz(0) {} const T & operator [] (size_t i) const { return _v[i]; } size_t size() const { return _sz; } bool empty() const { return _sz == 0; } diff --git a/vespalib/src/vespa/vespalib/util/rcuvector.h b/vespalib/src/vespa/vespalib/util/rcuvector.h index 09957d14aaf..e3e17d8edf0 100644 --- a/vespalib/src/vespa/vespalib/util/rcuvector.h +++ b/vespalib/src/vespa/vespalib/util/rcuvector.h @@ -4,6 +4,7 @@ #include "alloc.h" #include "array.h" +#include "arrayref.h" #include "generationholder.h" #include "growstrategy.h" #include "memoryusage.h" @@ -148,6 +149,15 @@ public: const T& get_elem_ref(size_t i) const noexcept { return _data[i]; } // Called from writer only + /* + * Readers holding a generation guard can call get_read_view() to + * get a read view to the rcu vector. Array bound (read_size) must + * be specified by reader, cf. committed docid limit in attribute vectors. + */ + ConstArrayRef<T> get_read_view(size_t read_size) const noexcept { + return ConstArrayRef<T>(&acquire_elem_ref(0), read_size); + } + void reset(); void shrink(size_t newSize) __attribute__((noinline)); void replaceVector(ArrayType replacement); |