diff options
Diffstat (limited to 'vespalib')
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) { |