aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-06-12 15:52:06 +0200
committerGitHub <noreply@github.com>2023-06-12 15:52:06 +0200
commitfbc1d03e255878b20a5c7e36e355ecd635f3a930 (patch)
treed93234c54611abf30954e4eca78248ace7de9ca2
parent9bfaff78c9f768f0b0dc904520aa1419dbf6f210 (diff)
parente55d06ac12241499f3b02031fad2eb245637e806 (diff)
Merge pull request #27381 from vespa-engine/toregge/pass-array-size-to-alloc-array-member-function
Pass array size to allocArray member function.
-rw-r--r--vespalib/src/tests/datastore/datastore/datastore_test.cpp4
-rw-r--r--vespalib/src/vespa/vespalib/btree/btreestore.hpp4
-rw-r--r--vespalib/src/vespa/vespalib/datastore/allocator.h2
-rw-r--r--vespalib/src/vespa/vespalib/datastore/allocator.hpp4
-rw-r--r--vespalib/src/vespa/vespalib/datastore/free_list_allocator.h2
-rw-r--r--vespalib/src/vespa/vespalib/datastore/free_list_allocator.hpp8
6 files changed, 12 insertions, 12 deletions
diff --git a/vespalib/src/tests/datastore/datastore/datastore_test.cpp b/vespalib/src/tests/datastore/datastore/datastore_test.cpp
index 9e27ed37dd3..fb7a38aacb6 100644
--- a/vespalib/src/tests/datastore/datastore/datastore_test.cpp
+++ b/vespalib/src/tests/datastore/datastore/datastore_test.cpp
@@ -87,7 +87,7 @@ public:
while (sizes.size() < bufs) {
RefType iRef = (_type.getArraySize() == 1) ?
(_store.template allocator<DataType>(_typeId).alloc().ref) :
- (_store.template allocator<DataType>(_typeId).allocArray().ref);
+ (_store.template allocator<DataType>(_typeId).allocArray(_type.getArraySize()).ref);
int bufferId = iRef.bufferId();
if (bufferId != prevBufferId) {
if (prevBufferId >= 0) {
@@ -126,7 +126,7 @@ public:
while (buffers.size() < bufs) {
RefType iRef = (_type.getArraySize() == 1) ?
(_store.template allocator<DataType>(_typeId).alloc().ref) :
- (_store.template allocator<DataType>(_typeId).allocArray().ref);
+ (_store.template allocator<DataType>(_typeId).allocArray(_type.getArraySize()).ref);
int buffer_id = iRef.bufferId();
if (buffers.empty() || buffers.back() != buffer_id) {
buffers.push_back(buffer_id);
diff --git a/vespalib/src/vespa/vespalib/btree/btreestore.hpp b/vespalib/src/vespa/vespalib/btree/btreestore.hpp
index 90c302af5e4..36c47e8bfb0 100644
--- a/vespalib/src/vespa/vespalib/btree/btreestore.hpp
+++ b/vespalib/src/vespa/vespalib/btree/btreestore.hpp
@@ -74,7 +74,7 @@ allocNewKeyData(uint32_t clusterSize)
{
assert(clusterSize >= 1 && clusterSize <= clusterLimit);
uint32_t typeId = clusterSize - 1;
- return _store.allocator<KeyDataType>(typeId).allocArray();
+ return _store.allocator<KeyDataType>(typeId).allocArray(clusterSize);
}
@@ -87,7 +87,7 @@ allocKeyData(uint32_t clusterSize)
{
assert(clusterSize >= 1 && clusterSize <= clusterLimit);
uint32_t typeId = clusterSize - 1;
- return _store.freeListAllocator<KeyDataType, datastore::DefaultReclaimer<KeyDataType>>(typeId).allocArray();
+ return _store.freeListAllocator<KeyDataType, datastore::DefaultReclaimer<KeyDataType>>(typeId).allocArray(clusterSize);
}
diff --git a/vespalib/src/vespa/vespalib/datastore/allocator.h b/vespalib/src/vespa/vespalib/datastore/allocator.h
index 30938bdc1c1..209ce1a5f26 100644
--- a/vespalib/src/vespa/vespalib/datastore/allocator.h
+++ b/vespalib/src/vespa/vespalib/datastore/allocator.h
@@ -30,7 +30,7 @@ public:
HandleType alloc(Args && ... args);
HandleType allocArray(ConstArrayRef array);
- HandleType allocArray();
+ HandleType allocArray(size_t array_size);
};
}
diff --git a/vespalib/src/vespa/vespalib/datastore/allocator.hpp b/vespalib/src/vespa/vespalib/datastore/allocator.hpp
index fa97ef9a5f5..20b22a032f0 100644
--- a/vespalib/src/vespa/vespalib/datastore/allocator.hpp
+++ b/vespalib/src/vespa/vespalib/datastore/allocator.hpp
@@ -52,14 +52,14 @@ Allocator<EntryT, RefT>::allocArray(ConstArrayRef array)
template <typename EntryT, typename RefT>
typename Allocator<EntryT, RefT>::HandleType
-Allocator<EntryT, RefT>::allocArray()
+Allocator<EntryT, RefT>::allocArray(size_t array_size)
{
_store.ensure_buffer_capacity(_typeId, 1);
uint32_t buffer_id = _store.primary_buffer_id(_typeId);
BufferState &state = _store.getBufferState(buffer_id);
assert(state.isActive());
RefT ref(state.size(), buffer_id);
- auto array_size = state.getArraySize();
+ assert(array_size == state.getArraySize());
EntryT *buf = _store.template getEntryArray<EntryT>(ref, array_size);
for (size_t i = 0; i < array_size; ++i) {
new (static_cast<void *>(buf + i)) EntryT();
diff --git a/vespalib/src/vespa/vespalib/datastore/free_list_allocator.h b/vespalib/src/vespa/vespalib/datastore/free_list_allocator.h
index dc2d1ea3c34..6d28d76726f 100644
--- a/vespalib/src/vespa/vespalib/datastore/free_list_allocator.h
+++ b/vespalib/src/vespa/vespalib/datastore/free_list_allocator.h
@@ -29,7 +29,7 @@ public:
HandleType alloc(Args && ... args);
HandleType allocArray(ConstArrayRef array);
- HandleType allocArray();
+ HandleType allocArray(size_t array_size);
};
}
diff --git a/vespalib/src/vespa/vespalib/datastore/free_list_allocator.hpp b/vespalib/src/vespa/vespalib/datastore/free_list_allocator.hpp
index 4e69db08a3c..6429f433aaf 100644
--- a/vespalib/src/vespa/vespalib/datastore/free_list_allocator.hpp
+++ b/vespalib/src/vespa/vespalib/datastore/free_list_allocator.hpp
@@ -83,16 +83,16 @@ FreeListAllocator<EntryT, RefT, ReclaimerT>::allocArray(ConstArrayRef array)
template <typename EntryT, typename RefT, typename ReclaimerT>
typename Allocator<EntryT, RefT>::HandleType
-FreeListAllocator<EntryT, RefT, ReclaimerT>::allocArray()
+FreeListAllocator<EntryT, RefT, ReclaimerT>::allocArray(size_t array_size)
{
auto& free_list = _store.getFreeList(_typeId);
if (free_list.empty()) {
- return ParentType::allocArray();
+ return ParentType::allocArray(array_size);
}
RefT ref = free_list.pop_entry();
auto& state = _store.getBufferState(ref.bufferId());
- auto size = state.getArraySize();
- EntryT *buf = _store.template getEntryArray<EntryT>(ref, size);
+ assert(array_size == state.getArraySize());
+ EntryT *buf = _store.template getEntryArray<EntryT>(ref, array_size);
return HandleType(ref, buf);
}