diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-09-30 19:17:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-30 19:17:36 +0200 |
commit | aeaa3c2da60259a8ba80345591657922c90c1993 (patch) | |
tree | 6b06c7c9d4c7ed536b2830024ad1bbea6a9bb837 | |
parent | 6caed45ce0696660bcf5b6be6695f4102f4f5d1a (diff) | |
parent | fe941b66cc2df07361239042eab9ef27e05ca86b (diff) |
Merge pull request #24277 from vespa-engine/toregge/pass-type-mapper-reference-to-buffer-type-handlers-for-array-store
Pass type mapper to buffer type handlers for array store.
5 files changed, 10 insertions, 6 deletions
diff --git a/vespalib/src/vespa/vespalib/datastore/array_store.hpp b/vespalib/src/vespa/vespalib/datastore/array_store.hpp index c1623b4322a..308afd2b122 100644 --- a/vespalib/src/vespa/vespalib/datastore/array_store.hpp +++ b/vespalib/src/vespa/vespalib/datastore/array_store.hpp @@ -23,7 +23,7 @@ ArrayStore<EntryT, RefT, TypeMapperT>::initArrayTypes(const ArrayStoreConfig &cf for (uint32_t type_id = 1; type_id <= _maxSmallArrayTypeId; ++type_id) { const AllocSpec &spec = cfg.spec_for_type_id(type_id); size_t arraySize = _mapper.get_array_size(type_id); - _smallArrayTypes.emplace_back(arraySize, spec, memory_allocator); + _smallArrayTypes.emplace_back(arraySize, spec, memory_allocator, _mapper); uint32_t act_type_id = _store.addType(&_smallArrayTypes.back()); assert(type_id == act_type_id); } @@ -44,7 +44,7 @@ ArrayStore<EntryT, RefT, TypeMapperT>::ArrayStore(const ArrayStoreConfig &cfg, s _store(), _mapper(std::move(mapper)), _smallArrayTypes(), - _largeArrayType(cfg.spec_for_type_id(0), memory_allocator) + _largeArrayType(cfg.spec_for_type_id(0), memory_allocator, _mapper) { initArrayTypes(cfg, std::move(memory_allocator)); _store.init_primary_buffers(); diff --git a/vespalib/src/vespa/vespalib/datastore/large_array_buffer_type.h b/vespalib/src/vespa/vespalib/datastore/large_array_buffer_type.h index ccaedaa9b64..87083b2a878 100644 --- a/vespalib/src/vespa/vespalib/datastore/large_array_buffer_type.h +++ b/vespalib/src/vespa/vespalib/datastore/large_array_buffer_type.h @@ -11,6 +11,8 @@ namespace vespalib::alloc { class MemoryAllocator; } namespace vespalib::datastore { +template <typename EntryT> class ArrayStoreTypeMapper; + /* * Class representing buffer type for large arrays in ArrayStore */ @@ -24,7 +26,7 @@ class LargeArrayBufferType : public BufferType<Array<EntryT>> using CleanContext = typename ParentType::CleanContext; std::shared_ptr<alloc::MemoryAllocator> _memory_allocator; public: - LargeArrayBufferType(const AllocSpec& spec, std::shared_ptr<alloc::MemoryAllocator> memory_allocator) noexcept; + LargeArrayBufferType(const AllocSpec& spec, std::shared_ptr<alloc::MemoryAllocator> memory_allocator, ArrayStoreTypeMapper<EntryT>& mapper) noexcept; ~LargeArrayBufferType() override; void cleanHold(void* buffer, size_t offset, ElemCount numElems, CleanContext cleanCtx) override; const vespalib::alloc::MemoryAllocator* get_memory_allocator() const override; diff --git a/vespalib/src/vespa/vespalib/datastore/large_array_buffer_type.hpp b/vespalib/src/vespa/vespalib/datastore/large_array_buffer_type.hpp index 3042bbff73f..f4d1d1c90a1 100644 --- a/vespalib/src/vespa/vespalib/datastore/large_array_buffer_type.hpp +++ b/vespalib/src/vespa/vespalib/datastore/large_array_buffer_type.hpp @@ -8,7 +8,7 @@ namespace vespalib::datastore { template <typename EntryT> -LargeArrayBufferType<EntryT>::LargeArrayBufferType(const AllocSpec& spec, std::shared_ptr<alloc::MemoryAllocator> memory_allocator) noexcept +LargeArrayBufferType<EntryT>::LargeArrayBufferType(const AllocSpec& spec, std::shared_ptr<alloc::MemoryAllocator> memory_allocator, ArrayStoreTypeMapper<EntryT>&) noexcept : BufferType<Array<EntryT>>(1u, spec.minArraysInBuffer, spec.maxArraysInBuffer, spec.numArraysForNewBuffer, spec.allocGrowFactor), _memory_allocator(std::move(memory_allocator)) { diff --git a/vespalib/src/vespa/vespalib/datastore/small_array_buffer_type.h b/vespalib/src/vespa/vespalib/datastore/small_array_buffer_type.h index 4e4568c3d16..f6cb860348d 100644 --- a/vespalib/src/vespa/vespalib/datastore/small_array_buffer_type.h +++ b/vespalib/src/vespa/vespalib/datastore/small_array_buffer_type.h @@ -10,6 +10,8 @@ namespace vespalib::alloc { class MemoryAllocator; } namespace vespalib::datastore { +template <typename EntryT> class ArrayStoreTypeMapper; + /* * Class representing buffer type for small arrays in ArrayStore */ @@ -23,7 +25,7 @@ public: SmallArrayBufferType& operator=(const SmallArrayBufferType&) = delete; SmallArrayBufferType(SmallArrayBufferType&&) noexcept = default; SmallArrayBufferType& operator=(SmallArrayBufferType&&) noexcept = default; - SmallArrayBufferType(uint32_t array_size, const AllocSpec& spec, std::shared_ptr<alloc::MemoryAllocator> memory_allocator) noexcept; + SmallArrayBufferType(uint32_t array_size, const AllocSpec& spec, std::shared_ptr<alloc::MemoryAllocator> memory_allocator, ArrayStoreTypeMapper<EntryT>& mapper) noexcept; ~SmallArrayBufferType() override; const vespalib::alloc::MemoryAllocator* get_memory_allocator() const override; }; diff --git a/vespalib/src/vespa/vespalib/datastore/small_array_buffer_type.hpp b/vespalib/src/vespa/vespalib/datastore/small_array_buffer_type.hpp index 414804417eb..9068b8db7b1 100644 --- a/vespalib/src/vespa/vespalib/datastore/small_array_buffer_type.hpp +++ b/vespalib/src/vespa/vespalib/datastore/small_array_buffer_type.hpp @@ -7,7 +7,7 @@ namespace vespalib::datastore { template <typename EntryT> -SmallArrayBufferType<EntryT>::SmallArrayBufferType(uint32_t array_size, const AllocSpec& spec, std::shared_ptr<alloc::MemoryAllocator> memory_allocator) noexcept +SmallArrayBufferType<EntryT>::SmallArrayBufferType(uint32_t array_size, const AllocSpec& spec, std::shared_ptr<alloc::MemoryAllocator> memory_allocator, ArrayStoreTypeMapper<EntryT>&) noexcept : BufferType<EntryT>(array_size, spec.minArraysInBuffer, spec.maxArraysInBuffer, spec.numArraysForNewBuffer, spec.allocGrowFactor), _memory_allocator(std::move(memory_allocator)) { |