diff options
author | Arsentiy Milchakov <milcars@mapswithme.com> | 2018-06-29 14:20:03 +0300 |
---|---|---|
committer | Ilya Zverev <ilya@zverev.info> | 2018-07-03 16:22:29 +0300 |
commit | 141363f6f1190056c770f583ef95a3f008a030eb (patch) | |
tree | 3f1aade4e828b941cbedcbd2aaae0c6e8c4f3b78 /search | |
parent | 8acc647b03a707dcac598288ad6dae2d9d344f77 (diff) |
[indexer][search] load popularity ranks table into pre-ranker
Diffstat (limited to 'search')
-rw-r--r-- | search/geocoder.cpp | 2 | ||||
-rw-r--r-- | search/intermediate_result.hpp | 11 | ||||
-rw-r--r-- | search/locality_finder.cpp | 2 | ||||
-rw-r--r-- | search/pre_ranker.cpp | 7 | ||||
-rw-r--r-- | search/pre_ranking_info.cpp | 1 | ||||
-rw-r--r-- | search/pre_ranking_info.hpp | 3 | ||||
-rw-r--r-- | search/rank_table_cache.cpp | 2 | ||||
-rw-r--r-- | search/ranker.cpp | 1 | ||||
-rw-r--r-- | search/ranking_info.cpp | 3 | ||||
-rw-r--r-- | search/ranking_info.hpp | 3 | ||||
-rw-r--r-- | search/result.cpp | 5 | ||||
-rw-r--r-- | search/result.hpp | 2 |
12 files changed, 33 insertions, 9 deletions
diff --git a/search/geocoder.cpp b/search/geocoder.cpp index 69b98d5050..941e53eb49 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -145,7 +145,7 @@ private: { if (m_table) return; - m_table = search::RankTable::Load(m_value.m_cont); + m_table = search::RankTable::Load(m_value.m_cont, RANKS_FILE_TAG); if (!m_table) m_table = make_unique<search::DummyRankTable>(); } diff --git a/search/intermediate_result.hpp b/search/intermediate_result.hpp index 15f0c97658..8b5b10de6b 100644 --- a/search/intermediate_result.hpp +++ b/search/intermediate_result.hpp @@ -34,11 +34,12 @@ public: static bool LessRank(PreRankerResult const & r1, PreRankerResult const & r2); static bool LessDistance(PreRankerResult const & r1, PreRankerResult const & r2); - inline FeatureID GetId() const { return m_id; } - inline double GetDistance() const { return m_info.m_distanceToPivot; } - inline uint8_t GetRank() const { return m_info.m_rank; } - inline PreRankingInfo & GetInfo() { return m_info; } - inline PreRankingInfo const & GetInfo() const { return m_info; } + FeatureID GetId() const { return m_id; } + double GetDistance() const { return m_info.m_distanceToPivot; } + uint8_t GetRank() const { return m_info.m_rank; } + uint8_t GetPopularity() const { return m_info.m_popularity; } + PreRankingInfo & GetInfo() { return m_info; } + PreRankingInfo const & GetInfo() const { return m_info; } private: friend class RankerResult; diff --git a/search/locality_finder.cpp b/search/locality_finder.cpp index 52e9b2f977..bbe5c9354e 100644 --- a/search/locality_finder.cpp +++ b/search/locality_finder.cpp @@ -243,7 +243,7 @@ void LocalityFinder::LoadVicinity(m2::PointD const & p, bool loadCities, bool lo { auto const & value = *handle.GetValue<MwmValue>(); if (!m_ranks) - m_ranks = RankTable::Load(value.m_cont); + m_ranks = RankTable::Load(value.m_cont, RANKS_FILE_TAG); if (!m_ranks) m_ranks = make_unique<DummyRankTable>(); diff --git a/search/pre_ranker.cpp b/search/pre_ranker.cpp index d1a9cdf107..6648c59f3b 100644 --- a/search/pre_ranker.cpp +++ b/search/pre_ranker.cpp @@ -71,6 +71,7 @@ void PreRanker::FillMissingFieldsInPreResults() MwmSet::MwmId mwmId; MwmSet::MwmHandle mwmHandle; unique_ptr<RankTable> ranks = make_unique<DummyRankTable>(); + unique_ptr<RankTable> popularityRanks = make_unique<DummyRankTable>(); unique_ptr<LazyCentersTable> centers; m_pivotFeatures.SetPosition(m_params.m_accuratePivotCenter, m_params.m_scale); @@ -86,7 +87,9 @@ void PreRanker::FillMissingFieldsInPreResults() centers.reset(); if (mwmHandle.IsAlive()) { - ranks = RankTable::Load(mwmHandle.GetValue<MwmValue>()->m_cont); + ranks = RankTable::Load(mwmHandle.GetValue<MwmValue>()->m_cont, RANKS_FILE_TAG); + popularityRanks = RankTable::Load(mwmHandle.GetValue<MwmValue>()->m_cont, + POPULARITY_RANKS_FILE_TAG); centers = make_unique<LazyCentersTable>(*mwmHandle.GetValue<MwmValue>()); } if (!ranks) @@ -94,6 +97,8 @@ void PreRanker::FillMissingFieldsInPreResults() } info.m_rank = ranks->Get(id.m_index); + if (popularityRanks) + info.m_popularity = popularityRanks->Get(id.m_index); m2::PointD center; if (centers && centers->Get(id.m_index, center)) diff --git a/search/pre_ranking_info.cpp b/search/pre_ranking_info.cpp index c3df59e300..2b05f68d5c 100644 --- a/search/pre_ranking_info.cpp +++ b/search/pre_ranking_info.cpp @@ -18,6 +18,7 @@ std::string DebugPrint(PreRankingInfo const & info) os << "m_tokenRange[" << DebugPrint(type) << "]:" << DebugPrint(info.m_tokenRange[i]) << ","; } os << "m_rank:" << static_cast<int>(info.m_rank) << ","; + os << "m_popularity:" << static_cast<int>(info.m_popularity) << ","; os << "m_type:" << info.m_type; os << "]"; return os.str(); diff --git a/search/pre_ranking_info.hpp b/search/pre_ranking_info.hpp index 36cd702a94..b19a76dd1d 100644 --- a/search/pre_ranking_info.hpp +++ b/search/pre_ranking_info.hpp @@ -56,6 +56,9 @@ struct PreRankingInfo // Rank of the feature. uint8_t m_rank = 0; + // Popularity rank of the feature. + uint8_t m_popularity = 0; + // Search type for the feature. Model::Type m_type = Model::TYPE_COUNT; }; diff --git a/search/rank_table_cache.cpp b/search/rank_table_cache.cpp index b91087b7de..109f16dcc2 100644 --- a/search/rank_table_cache.cpp +++ b/search/rank_table_cache.cpp @@ -14,7 +14,7 @@ RankTable const & RankTableCache::Get(DataSource & dataSource, TId const & mwmId return *it->second; TKey handle(dataSource.GetMwmHandleById(mwmId)); - auto table = RankTable::Load(handle.GetValue<MwmValue>()->m_cont); + auto table = RankTable::Load(handle.GetValue<MwmValue>()->m_cont, RANKS_FILE_TAG); if (!table) table.reset(new DummyRankTable()); diff --git a/search/ranker.cpp b/search/ranker.cpp index d0e7e3744c..2d679db1bc 100644 --- a/search/ranker.cpp +++ b/search/ranker.cpp @@ -259,6 +259,7 @@ class RankerResultMaker info.m_distanceToPivot = MercatorBounds::DistanceOnEarth(center, pivot); info.m_rank = preInfo.m_rank; + info.m_popularity = preInfo.m_popularity; info.m_type = preInfo.m_type; info.m_allTokensUsed = preInfo.m_allTokensUsed; diff --git a/search/ranking_info.cpp b/search/ranking_info.cpp index fa884e0579..57c72d8d8a 100644 --- a/search/ranking_info.cpp +++ b/search/ranking_info.cpp @@ -48,6 +48,7 @@ void RankingInfo::PrintCSVHeader(ostream & os) { os << "DistanceToPivot" << ",Rank" + << ",Popularity" << ",NameScore" << ",ErrorsMade" << ",SearchType" @@ -62,6 +63,7 @@ string DebugPrint(RankingInfo const & info) os << "RankingInfo ["; os << "m_distanceToPivot:" << info.m_distanceToPivot << ","; os << "m_rank:" << static_cast<int>(info.m_rank) << ","; + os << "m_popularity:" << static_cast<int>(info.m_popularity) << ","; os << "m_nameScore:" << DebugPrint(info.m_nameScore) << ","; os << "m_errorsMade:" << DebugPrint(info.m_errorsMade) << ","; os << "m_type:" << DebugPrint(info.m_type) << ","; @@ -77,6 +79,7 @@ void RankingInfo::ToCSV(ostream & os) const os << fixed; os << m_distanceToPivot << ","; os << static_cast<int>(m_rank) << ","; + os << static_cast<int>(m_popularity) << ","; os << DebugPrint(m_nameScore) << ","; os << GetErrorsMade() << ","; os << DebugPrint(m_type) << ","; diff --git a/search/ranking_info.hpp b/search/ranking_info.hpp index efe7da45b7..da8e86f9bd 100644 --- a/search/ranking_info.hpp +++ b/search/ranking_info.hpp @@ -23,6 +23,9 @@ struct RankingInfo // Rank of the feature. uint8_t m_rank = 0; + // Popularity rank of the feature. + uint8_t m_popularity = 0; + // Score for the feature's name. NameScore m_nameScore = NAME_SCORE_ZERO; diff --git a/search/result.cpp b/search/result.cpp index 23f0c59ff7..28c0392f7a 100644 --- a/search/result.cpp +++ b/search/result.cpp @@ -274,6 +274,11 @@ void Results::InsertResult(vector<Result>::iterator where, Result && result) m_results.insert(where, move(result)); } +std::string DebugPrint(search::Results const & results) +{ + return ::my::impl::DebugPrintSequence(results.begin(), results.end()); +} + // AddressInfo ------------------------------------------------------------------------------------- bool AddressInfo::IsEmptyName() const { diff --git a/search/result.hpp b/search/result.hpp index f8b06190bd..379b965f76 100644 --- a/search/result.hpp +++ b/search/result.hpp @@ -246,6 +246,8 @@ private: HotelsClassifier m_hotelsClassif; }; +std::string DebugPrint(search::Results const & results); + struct AddressInfo { enum class Type { Default, SearchResult }; |