summaryrefslogtreecommitdiffstats
path: root/searchlib/src
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-04-20 19:55:47 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-04-20 19:55:47 +0000
commitefc1a91225774ea9dbec3ddaf81bf4b51c0f3eea (patch)
treee3ea262f8fb3210b825f1d083c3b5464766096c2 /searchlib/src
parent0e05bdd705bb6fca9c5c69bc1c975f7c88416a07 (diff)
Select Comparator based on match settings of dictionary.
Diffstat (limited to 'searchlib/src')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumcomparator.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.h6
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.hpp7
5 files changed, 14 insertions, 11 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp b/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp
index 368de359c85..335a53d3ae8 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp
@@ -46,9 +46,9 @@ EnumStoreStringComparator::EnumStoreStringComparator(const DataStoreType& data_s
{
}
-EnumStoreStringComparator::EnumStoreStringComparator(const DataStoreType& data_store, const char* fallback_value, bool prefix)
+EnumStoreStringComparator::EnumStoreStringComparator(const DataStoreType& data_store, bool fold, const char* fallback_value, bool prefix)
: ParentType(data_store, fallback_value),
- _fold(true),
+ _fold(fold),
_prefix(prefix),
_prefix_len(0)
{
diff --git a/searchlib/src/vespa/searchlib/attribute/enumcomparator.h b/searchlib/src/vespa/searchlib/attribute/enumcomparator.h
index 018ec1b4ff4..e822e08cfdc 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumcomparator.h
+++ b/searchlib/src/vespa/searchlib/attribute/enumcomparator.h
@@ -51,7 +51,7 @@ public:
: EnumStoreStringComparator(data_store, false, fallback_value)
{}
EnumStoreStringComparator(const DataStoreType& data_store, bool fold, const char* fallback_value);
- EnumStoreStringComparator(const DataStoreType& data_store, const char* fallback_value, bool prefix);
+ EnumStoreStringComparator(const DataStoreType& data_store, bool fold, const char* fallback_value, bool prefix);
bool less(const vespalib::datastore::EntryRef lhs, const vespalib::datastore::EntryRef rhs) const override;
bool equal(const vespalib::datastore::EntryRef lhs, const vespalib::datastore::EntryRef rhs) const override;
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.cpp b/searchlib/src/vespa/searchlib/attribute/enumstore.cpp
index 9da3906ac85..b07515a675e 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstore.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumstore.cpp
@@ -40,7 +40,7 @@ EnumStoreT<const char*>::load_unique_value(const void* src, size_t available, In
}
std::unique_ptr<vespalib::datastore::IUniqueStoreDictionary>
-make_enum_store_dictionary(IEnumStore &store, bool has_postings, const search::DictionaryConfig & dict_cfg,
+make_enum_store_dictionary(IEnumStore &store, bool has_postings, const DictionaryConfig & dict_cfg,
std::unique_ptr<EntryComparator> compare,
std::unique_ptr<EntryComparator> folded_compare)
{
@@ -51,9 +51,9 @@ make_enum_store_dictionary(IEnumStore &store, bool has_postings, const search::D
return std::make_unique<EnumStoreFoldedDictionary>(store, std::move(compare), std::move(folded_compare));
} else {
switch (dict_cfg.getType()) {
- case search::DictionaryConfig::Type::HASH:
+ case DictionaryConfig::Type::HASH:
return std::make_unique<EnumStoreDictionary<NoBTreeDictionary, ShardedHashMap>>(store, std::move(compare));
- case search::DictionaryConfig::Type::BTREE_AND_HASH:
+ case DictionaryConfig::Type::BTREE_AND_HASH:
return std::make_unique<EnumStoreDictionary<EnumPostingTree, ShardedHashMap>>(store, std::move(compare));
default:
return std::make_unique<EnumStoreDictionary<EnumPostingTree>>(store, std::move(compare));
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.h b/searchlib/src/vespa/searchlib/attribute/enumstore.h
index 618faf84d9b..d83382e18d0 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstore.h
+++ b/searchlib/src/vespa/searchlib/attribute/enumstore.h
@@ -53,6 +53,7 @@ public:
private:
UniqueStoreType _store;
IEnumStoreDictionary* _dict;
+ bool _is_folded;
ComparatorType _comparator;
ComparatorType _foldedComparator;
vespalib::MemoryUsage _cached_values_memory_usage;
@@ -91,6 +92,7 @@ public:
}
uint32_t get_num_uniques() const override { return _dict->get_num_uniques(); }
+ bool is_folded() const { return _is_folded;}
vespalib::MemoryUsage get_values_memory_usage() const override { return _store.get_allocator().get_data_store().getMemoryUsage(); }
vespalib::MemoryUsage get_dictionary_memory_usage() const override { return _dict->get_memory_usage(); }
@@ -215,12 +217,12 @@ public:
template <typename Type>
ComparatorType
make_folded_comparator(const Type& fallback_value) const {
- return ComparatorType(_store.get_data_store(), true, fallback_value);
+ return ComparatorType(_store.get_data_store(), is_folded(), fallback_value);
}
template<typename Type>
ComparatorType
make_folded_comparator_prefix(const Type& fallback_value) const {
- return ComparatorType(_store.get_data_store(), fallback_value, true);
+ return ComparatorType(_store.get_data_store(), is_folded(), fallback_value, true);
}
template<typename Type>
std::vector<IEnumStore::EnumHandle>
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp
index ef9362174de..485c82ecc8d 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp
@@ -71,17 +71,18 @@ EnumStoreT<EntryT>::load_unique_value(const void* src, size_t available, Index&
}
template <typename EntryT>
-EnumStoreT<EntryT>::EnumStoreT(bool has_postings, const search::DictionaryConfig & dict_cfg)
+EnumStoreT<EntryT>::EnumStoreT(bool has_postings, const DictionaryConfig & dict_cfg)
: _store(),
_dict(),
+ _is_folded(dict_cfg.getMatch() == DictionaryConfig::Match::UNCASED),
_comparator(_store.get_data_store()),
- _foldedComparator(make_optionally_folded_comparator(true)),
+ _foldedComparator(make_optionally_folded_comparator(is_folded())),
_cached_values_memory_usage(),
_cached_values_address_space_usage(0, 0, (1ull << 32))
{
_store.set_dictionary(make_enum_store_dictionary(*this, has_postings, dict_cfg,
allocate_comparator(),
- allocate_optionally_folded_comparator(true)));
+ allocate_optionally_folded_comparator(is_folded())));
_dict = static_cast<IEnumStoreDictionary*>(&_store.get_dictionary());
}