summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@verizonmedia.com>2020-09-04 15:56:36 +0000
committerTor Brede Vekterli <vekterli@verizonmedia.com>2020-09-04 15:57:34 +0000
commit248e1a26010de03a51e1662015899dd1554d163f (patch)
treed603040c5d1fd4f415a1eaae3600a507a73577a0 /vespalib
parentca28ce90eaf1c4f247ce70533bb5937bce8755a6 (diff)
Reintroduce DataStore ctor taking explicit min_arrays argument
Lets caller specify a reasonable minimum array count without needing to create an explicit buffer. Use explicit `min_arrays=1024` for content node bucket DB `DataStore`. Reduces default memory footprint of an empty (or sparsely populated) content node bucket DB with a factor of more than 1200x.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/datastore/datastore.h3
-rw-r--r--vespalib/src/vespa/vespalib/datastore/datastore.hpp6
2 files changed, 8 insertions, 1 deletions
diff --git a/vespalib/src/vespa/vespalib/datastore/datastore.h b/vespalib/src/vespa/vespalib/datastore/datastore.h
index e67d9049f0b..686b07766ac 100644
--- a/vespalib/src/vespa/vespalib/datastore/datastore.h
+++ b/vespalib/src/vespa/vespalib/datastore/datastore.h
@@ -108,7 +108,8 @@ public:
DataStore(const DataStore &rhs) = delete;
DataStore &operator=(const DataStore &rhs) = delete;
DataStore();
- DataStore(BufferTypeUP type);
+ explicit DataStore(uint32_t min_arrays);
+ explicit DataStore(BufferTypeUP type);
~DataStore();
EntryRef addEntry(const EntryType &e);
diff --git a/vespalib/src/vespa/vespalib/datastore/datastore.hpp b/vespalib/src/vespa/vespalib/datastore/datastore.hpp
index b66a3b78603..f4e37804317 100644
--- a/vespalib/src/vespa/vespalib/datastore/datastore.hpp
+++ b/vespalib/src/vespa/vespalib/datastore/datastore.hpp
@@ -138,6 +138,12 @@ DataStore<EntryType, RefT>::DataStore()
}
template <typename EntryType, typename RefT>
+DataStore<EntryType, RefT>::DataStore(uint32_t min_arrays)
+ : DataStore(std::make_unique<BufferType<EntryType>>(1, min_arrays, RefType::offsetSize()))
+{
+}
+
+template <typename EntryType, typename RefT>
DataStore<EntryType, RefT>::DataStore(BufferTypeUP type)
: ParentType(),
_type(std::move(type))