diff options
author | Arsentiy Milchakov <milcars@mapswithme.com> | 2017-10-19 10:16:45 +0300 |
---|---|---|
committer | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2017-11-09 10:46:46 +0300 |
commit | ddb6fc5115554b69d9ef2440ab605cc67dbf7ac1 (patch) | |
tree | a85483c739bd401f7e25f1e643b0d417139cb06d /indexer/ftraits.hpp | |
parent | 86c9598fb685e66d8c1a8073c0952d403992a2a7 (diff) |
[ugc] separate container for excluded types is added
Diffstat (limited to 'indexer/ftraits.hpp')
-rw-r--r-- | indexer/ftraits.hpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/indexer/ftraits.hpp b/indexer/ftraits.hpp index a7c05c0d42..7900f43afc 100644 --- a/indexer/ftraits.hpp +++ b/indexer/ftraits.hpp @@ -19,13 +19,18 @@ namespace ftraits { -template <typename Base, typename Value, bool allowDuplications = false> +template <typename Base, typename Value> class TraitsBase { public: static Value GetValue(feature::TypesHolder const & types) { static Base instance; + + auto const excluded = instance.m_excluded.Find(types); + if (instance.m_excluded.IsValid(excluded)) + return Base::GetEmptyValue(); + auto const it = instance.m_matcher.Find(types); if (!instance.m_matcher.IsValid(it)) return Base::GetEmptyValue(); @@ -34,7 +39,8 @@ public: } protected: - ftypes::Matcher<std::unordered_map<uint32_t, Value>, allowDuplications> m_matcher; + ftypes::HashMapMatcher<uint32_t, Value> m_matcher; + ftypes::HashSetMatcher<uint32_t> m_excluded; }; enum UGCType @@ -60,7 +66,7 @@ struct UGCItem UGCRatingCategories m_categories; }; -class UGC : public TraitsBase<UGC, UGCItem, true> +class UGC : public TraitsBase<UGC, UGCItem> { friend class TraitsBase; @@ -77,7 +83,12 @@ class UGC : public TraitsBase<UGC, UGCItem, true> ASSERT_EQUAL(row.size(), 5, ()); UGCItem item(ReadMasks(row), ParseByWhitespaces(row[kCategoriesPos])); - m_matcher.AppendType(ParseByWhitespaces(row[kTypePos]), std::move(item)); + auto typePath = ParseByWhitespaces(row[kTypePos]); + + if (IsUGCAvailable(item.m_mask)) + m_matcher.AppendType(std::move(typePath), std::move(item)); + else + m_excluded.AppendType(std::move(typePath)); }); } |