summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@yahooinc.com>2023-04-18 12:08:09 +0200
committerGitHub <noreply@github.com>2023-04-18 12:08:09 +0200
commit0f0f13ad8d1b60442d805a63323e5b1bbb3218a1 (patch)
treef0e7d02f05f6b5d9cb61a491a615ac9970be6a89
parent1b04e62f32af429653203c855f272e894e4d6007 (diff)
parenta532b5ffe86668b11d7bfddd6c213e4c9d211c68 (diff)
Merge pull request #26762 from vespa-engine/toregge/pass-default-value-to-enum-store
Pass default value to enum store.
-rw-r--r--searchlib/src/tests/attribute/enumstore/enumstore_test.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumattribute.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.hpp6
4 files changed, 6 insertions, 8 deletions
diff --git a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp
index e9260a55f57..2b01c266e80 100644
--- a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp
+++ b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp
@@ -390,7 +390,7 @@ TEST(EnumStoreTest, address_space_usage_is_reported)
TEST(EnumStoreTest, provided_memory_allocator_is_used)
{
AllocStats stats;
- NumericEnumStore ses(false, DictionaryConfig::Type::BTREE, std::make_unique<MemoryAllocatorObserver>(stats));
+ NumericEnumStore ses(false, DictionaryConfig::Type::BTREE, std::make_unique<MemoryAllocatorObserver>(stats), attribute::getUndefined<NumericEnumStore::EntryType>());
EXPECT_EQ(AllocStats(1, 0), stats);
}
diff --git a/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp
index a28a100cde5..f0f518f64f7 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp
@@ -15,7 +15,7 @@ EnumAttribute<B>::
EnumAttribute(const vespalib::string &baseFileName,
const AttributeVector::Config &cfg)
: B(baseFileName, cfg),
- _enumStore(cfg.fastSearch(), cfg.get_dictionary_config(), this->get_memory_allocator())
+ _enumStore(cfg.fastSearch(), cfg.get_dictionary_config(), this->get_memory_allocator(), this->_defaultValue._data.raw())
{
this->setEnum(true);
}
@@ -96,5 +96,3 @@ EnumAttribute<B>::cache_change_data_entry_ref(const Change& c) const
}
} // namespace search
-
-
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.h b/searchlib/src/vespa/searchlib/attribute/enumstore.h
index 4bc17a9092f..f6467194d74 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstore.h
+++ b/searchlib/src/vespa/searchlib/attribute/enumstore.h
@@ -80,7 +80,7 @@ private:
std::unique_ptr<EntryComparator> allocate_optionally_folded_comparator(bool folded) const;
ComparatorType make_optionally_folded_comparator(bool folded) const;
public:
- EnumStoreT(bool has_postings, const search::DictionaryConfig& dict_cfg, std::shared_ptr<vespalib::alloc::MemoryAllocator> memory_allocator);
+ EnumStoreT(bool has_postings, const search::DictionaryConfig& dict_cfg, std::shared_ptr<vespalib::alloc::MemoryAllocator> memory_allocator, EntryType default_value);
EnumStoreT(bool has_postings, const search::DictionaryConfig & dict_cfg);
~EnumStoreT() override;
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp
index 373102076d5..c0eebee8e94 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp
@@ -73,14 +73,14 @@ EnumStoreT<EntryT>::load_unique_value(const void* src, size_t available, Index&
}
template <typename EntryT>
-EnumStoreT<EntryT>::EnumStoreT(bool has_postings, const DictionaryConfig& dict_cfg, std::shared_ptr<vespalib::alloc::MemoryAllocator> memory_allocator)
+EnumStoreT<EntryT>::EnumStoreT(bool has_postings, const DictionaryConfig& dict_cfg, std::shared_ptr<vespalib::alloc::MemoryAllocator> memory_allocator, EntryType default_value)
: _store(std::move(memory_allocator)),
_dict(),
_is_folded(dict_cfg.getMatch() == DictionaryConfig::Match::UNCASED),
_comparator(_store.get_data_store()),
_foldedComparator(make_optionally_folded_comparator(is_folded())),
_compaction_spec(),
- _default_value(attribute::getUndefined<EntryT>()),
+ _default_value(default_value),
_default_value_ref()
{
_store.set_dictionary(make_enum_store_dictionary(*this, has_postings, dict_cfg,
@@ -92,7 +92,7 @@ EnumStoreT<EntryT>::EnumStoreT(bool has_postings, const DictionaryConfig& dict_c
template <typename EntryT>
EnumStoreT<EntryT>::EnumStoreT(bool has_postings, const DictionaryConfig& dict_cfg)
- : EnumStoreT<EntryT>(has_postings, dict_cfg, {})
+ : EnumStoreT<EntryT>(has_postings, dict_cfg, {}, attribute::getUndefined<EntryType>())
{
}