diff options
author | Geir Storli <geirst@verizonmedia.com> | 2020-02-05 10:12:22 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2020-02-05 10:12:22 +0000 |
commit | dafacc957b8809d7b003a5909a76c99c83e88cc0 (patch) | |
tree | 07b9a92141d5745bf623f433794d16f67f787a51 /vespalib | |
parent | 166b192424bc38e16243adb2f925c6b7ff6d1e64 (diff) |
Add function to array store that returns a writeable reference to an array.
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/datastore/array_store.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/datastore/array_store.h b/vespalib/src/vespa/vespalib/datastore/array_store.h index d5fef404a43..4c289c04564 100644 --- a/vespalib/src/vespa/vespalib/datastore/array_store.h +++ b/vespalib/src/vespa/vespalib/datastore/array_store.h @@ -25,6 +25,7 @@ template <typename EntryT, typename RefT = EntryRefT<19> > class ArrayStore { public: + using ArrayRef = vespalib::ArrayRef<EntryT>; using ConstArrayRef = vespalib::ConstArrayRef<EntryT>; using DataStoreType = DataStoreT<RefT>; using SmallArrayType = BufferType<EntryT>; @@ -82,6 +83,17 @@ public: return getLargeArray(internalRef); } } + + /** + * Returns a writeable reference to the given array. + * + * NOTE: Use with care if reader threads are accessing arrays at the same time. + * If so, replacing an element in the array should be an atomic operation. + */ + ArrayRef get_writable(EntryRef ref) { + return vespalib::unconstify(get(ref)); + } + void remove(EntryRef ref); ICompactionContext::UP compactWorst(bool compactMemory, bool compactAddressSpace); vespalib::MemoryUsage getMemoryUsage() const { return _store.getMemoryUsage(); } |