summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-09-04 13:05:13 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-09-04 13:05:13 +0000
commit8d5731bb1e2f47ca0833897256fb3933ce891eae (patch)
tree5ae0ef83c6bdb392ba9c949382f99f8a89f12504 /vespalib
parent47026cc503f0efc574283ee0106512b759ddb5da (diff)
Simplify how dictionary is populated when loading enum store.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/datastore/i_unique_store_dictionary.h4
-rw-r--r--vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.h1
-rw-r--r--vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp11
3 files changed, 15 insertions, 1 deletions
diff --git a/vespalib/src/vespa/vespalib/datastore/i_unique_store_dictionary.h b/vespalib/src/vespa/vespalib/datastore/i_unique_store_dictionary.h
index a780cb4fe98..25480176143 100644
--- a/vespalib/src/vespa/vespalib/datastore/i_unique_store_dictionary.h
+++ b/vespalib/src/vespa/vespalib/datastore/i_unique_store_dictionary.h
@@ -2,8 +2,9 @@
#pragma once
-#include <vespa/vespalib/util/generationhandler.h>
#include "entryref.h"
+#include <vespa/vespalib/util/arrayref.h>
+#include <vespa/vespalib/util/generationhandler.h>
#include <functional>
namespace search::datastore {
@@ -45,6 +46,7 @@ public:
virtual uint32_t get_num_uniques() const = 0;
virtual vespalib::MemoryUsage get_memory_usage() const = 0;
virtual void build(const std::vector<EntryRef> &refs, const std::vector<uint32_t> &ref_counts, std::function<void(EntryRef)> hold) = 0;
+ virtual void build(const vespalib::ConstArrayRef<EntryRef>& refs) = 0;
virtual void build_with_payload(const std::vector<EntryRef>& refs, const std::vector<uint32_t>& payloads) = 0;
virtual std::unique_ptr<ReadSnapshot> get_read_snapshot() const = 0;
virtual EntryRef get_frozen_root() const = 0;
diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.h b/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.h
index 15b947e283b..d5150aae236 100644
--- a/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.h
+++ b/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.h
@@ -48,6 +48,7 @@ public:
uint32_t get_num_uniques() const override;
vespalib::MemoryUsage get_memory_usage() const override;
void build(const std::vector<EntryRef> &refs, const std::vector<uint32_t> &ref_counts, std::function<void(EntryRef)> hold) override;
+ void build(const vespalib::ConstArrayRef<EntryRef>& refs) override;
void build_with_payload(const std::vector<EntryRef>& refs, const std::vector<uint32_t>& payloads) override;
std::unique_ptr<ReadSnapshot> get_read_snapshot() const override;
EntryRef get_frozen_root() const override;
diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp
index 3784b903ad6..896970ee3f1 100644
--- a/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp
+++ b/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp
@@ -177,6 +177,17 @@ UniqueStoreDictionary<DictionaryT, ParentT>::build(const std::vector<EntryRef> &
template <typename DictionaryT, typename ParentT>
void
+UniqueStoreDictionary<DictionaryT, ParentT>::build(const vespalib::ConstArrayRef<EntryRef>& refs)
+{
+ typename DictionaryType::Builder builder(_dict.getAllocator());
+ for (const auto& ref : refs) {
+ builder.insert(ref, DataType());
+ }
+ _dict.assign(builder);
+}
+
+template <typename DictionaryT, typename ParentT>
+void
UniqueStoreDictionary<DictionaryT, ParentT>::build_with_payload(const std::vector<EntryRef>& refs,
const std::vector<uint32_t>& payloads)
{