diff options
Diffstat (limited to 'searchcommon')
3 files changed, 42 insertions, 11 deletions
diff --git a/searchcommon/src/tests/attribute/config/attribute_config_test.cpp b/searchcommon/src/tests/attribute/config/attribute_config_test.cpp index 98b2bfe5c90..12a9837629d 100644 --- a/searchcommon/src/tests/attribute/config/attribute_config_test.cpp +++ b/searchcommon/src/tests/attribute/config/attribute_config_test.cpp @@ -111,10 +111,18 @@ TEST("Test GrowStrategy consistency") { TEST("DictionaryConfig") { using Type = DictionaryConfig::Type; + using Match = DictionaryConfig::Match; EXPECT_EQUAL(Type::BTREE, DictionaryConfig().getType()); + EXPECT_EQUAL(Match::UNCASED, DictionaryConfig().getMatch()); + EXPECT_EQUAL(Type::BTREE, DictionaryConfig(Type::BTREE).getType()); + EXPECT_EQUAL(Match::UNCASED, DictionaryConfig(Type::BTREE).getMatch()); + EXPECT_EQUAL(Match::UNCASED, DictionaryConfig(Type::BTREE, Match::UNCASED).getMatch()); + EXPECT_EQUAL(Match::CASED, DictionaryConfig(Type::BTREE, Match::CASED).getMatch()); + EXPECT_EQUAL(Type::HASH, DictionaryConfig(Type::HASH).getType()); EXPECT_EQUAL(Type::BTREE_AND_HASH, DictionaryConfig(Type::BTREE_AND_HASH).getType()); + EXPECT_EQUAL(DictionaryConfig(Type::BTREE), DictionaryConfig(Type::BTREE)); EXPECT_EQUAL(DictionaryConfig(Type::HASH), DictionaryConfig(Type::HASH)); EXPECT_EQUAL(DictionaryConfig(Type::BTREE_AND_HASH), DictionaryConfig(Type::BTREE_AND_HASH)); diff --git a/searchcommon/src/vespa/searchcommon/common/dictionary_config.cpp b/searchcommon/src/vespa/searchcommon/common/dictionary_config.cpp index a6a0255f96d..0156a7f9d8c 100644 --- a/searchcommon/src/vespa/searchcommon/common/dictionary_config.cpp +++ b/searchcommon/src/vespa/searchcommon/common/dictionary_config.cpp @@ -8,13 +8,30 @@ namespace search { std::ostream& operator<<(std::ostream& os, const DictionaryConfig & cfg) { - switch(cfg.getType()) { - case DictionaryConfig::Type::BTREE: - return os << "BTREE"; - case DictionaryConfig::Type::HASH: - return os << "HASH"; - case DictionaryConfig::Type::BTREE_AND_HASH: - return os << "BTREE_AND_HASH"; + return os << cfg.getType() << "," << cfg.getMatch(); +} + +std::ostream& +operator<<(std::ostream& os, DictionaryConfig::Type type) { + + switch (type) { + case DictionaryConfig::Type::BTREE: + return os << "BTREE"; + case DictionaryConfig::Type::HASH: + return os << "HASH"; + case DictionaryConfig::Type::BTREE_AND_HASH: + return os << "BTREE_AND_HASH"; + } + assert(false); +} + +std::ostream& +operator<<(std::ostream& os, DictionaryConfig::Match match) { + switch(match) { + case DictionaryConfig::Match::CASED: + return os << "CASE_SENSTITIVE"; + case DictionaryConfig::Match::UNCASED: + return os << "CASE_INSENSTITIVE"; } assert(false); } diff --git a/searchcommon/src/vespa/searchcommon/common/dictionary_config.h b/searchcommon/src/vespa/searchcommon/common/dictionary_config.h index c35f7eaafef..b429b910d4e 100644 --- a/searchcommon/src/vespa/searchcommon/common/dictionary_config.h +++ b/searchcommon/src/vespa/searchcommon/common/dictionary_config.h @@ -12,14 +12,20 @@ namespace search { class DictionaryConfig { public: enum class Type { BTREE, HASH, BTREE_AND_HASH }; - DictionaryConfig() noexcept : _type(Type::BTREE) {} - DictionaryConfig(Type ordering) noexcept : _type(ordering) {} + enum class Match { CASED, UNCASED }; + DictionaryConfig() noexcept : _type(Type::BTREE), _match(Match::UNCASED) {} + DictionaryConfig(Type type) noexcept : _type(type), _match(Match::UNCASED) {} + DictionaryConfig(Type type, Match match) noexcept : _type(type), _match(match) {} Type getType() const { return _type; } - bool operator == (const DictionaryConfig & b) const { return _type == b._type; } + Match getMatch() const { return _match; } + bool operator == (const DictionaryConfig & b) const { return (_type == b._type) && (_match == b._match); } private: - Type _type; + Type _type; + Match _match; }; std::ostream& operator<<(std::ostream& os, const DictionaryConfig & cfg); +std::ostream& operator<<(std::ostream& os, DictionaryConfig::Type type); +std::ostream& operator<<(std::ostream& os, DictionaryConfig::Match match); } // namespace search |