Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/search
diff options
context:
space:
mode:
authorMaxim Pimenov <m@maps.me>2016-06-21 16:38:24 +0300
committerMaxim Pimenov <m@maps.me>2016-06-21 16:56:32 +0300
commitb9f00fa291e5930d9bab44d505b86c40a949745a (patch)
tree668c22604f94910f4c04aaa64c35b6642ca12af8 /search
parent0f3a21406dcfa4b7edc427246fed299b0276c178 (diff)
Review fixes.
Diffstat (limited to 'search')
-rw-r--r--search/intermediate_result.hpp1
-rw-r--r--search/processor.cpp13
-rw-r--r--search/processor.hpp8
-rw-r--r--search/ranker.cpp58
-rw-r--r--search/ranker.hpp6
5 files changed, 41 insertions, 45 deletions
diff --git a/search/intermediate_result.hpp b/search/intermediate_result.hpp
index 76bb97ff43..925a0892f8 100644
--- a/search/intermediate_result.hpp
+++ b/search/intermediate_result.hpp
@@ -191,5 +191,4 @@ public:
inline double GetDistanceToPivot() const { return m_distanceToPivot; }
};
-
} // namespace search
diff --git a/search/processor.cpp b/search/processor.cpp
index cfcc509822..50ff2cc7a3 100644
--- a/search/processor.cpp
+++ b/search/processor.cpp
@@ -152,6 +152,7 @@ Processor::Processor(Index & index, CategoriesHolder const & categories,
, m_worldSearch(true)
, m_suggestsEnabled(true)
, m_preRanker(kPreResultsCount)
+ , m_ranker(m_preRanker, *this)
, m_geocoder(index, infoGetter, static_cast<my::Cancellable const &>(*this))
, m_reverseGeocoder(index)
{
@@ -166,8 +167,6 @@ Processor::Processor(Index & index, CategoriesHolder const & categories,
m_keywordsScorer.SetLanguages(langPriorities);
SetPreferredLocale("en");
-
- m_ranker = make_unique<Ranker>(m_preRanker, *this);
}
void Processor::Init(bool viewportSearch)
@@ -175,7 +174,7 @@ void Processor::Init(bool viewportSearch)
m_tokens.clear();
m_prefix.clear();
m_preRanker.Clear();
- m_ranker->Init(viewportSearch);
+ m_ranker.Init(viewportSearch);
}
void Processor::SetViewport(m2::RectD const & viewport, bool forceUpdate)
@@ -393,7 +392,7 @@ void Processor::ForEachCategoryType(StringSliceBase const & slice,
}
// template <class ToDo>
-void Processor::ProcessEmojiIfNeeded(strings::UniString const & token, size_t ind,
+void Processor::ProcessEmojiIfNeeded(strings::UniString const & token, size_t index,
function<void(size_t, uint32_t)> const & fn) const
{
// Special process of 2 codepoints emoji (e.g. black guy on a bike).
@@ -403,7 +402,7 @@ void Processor::ProcessEmojiIfNeeded(strings::UniString const & token, size_t in
static int8_t const enLocaleCode = CategoriesHolder::MapLocaleToInteger("en");
m_categories.ForEachTypeByName(enLocaleCode, strings::UniString(1, token[0]),
- bind<void>(fn, ind, _1));
+ bind<void>(fn, index, _1));
}
}
@@ -422,7 +421,7 @@ void Processor::Search(Results & results, size_t limit)
m_geocoder.GoEverywhere(m_preRanker);
- m_ranker->FlushResults(params, results, limit);
+ m_ranker.FlushResults(params, results, limit);
}
void Processor::SearchViewportPoints(Results & results)
@@ -436,7 +435,7 @@ void Processor::SearchViewportPoints(Results & results)
m_geocoder.GoInViewport(m_preRanker);
- m_ranker->FlushViewportResults(params, results);
+ m_ranker.FlushViewportResults(params, results);
}
void Processor::SearchCoordinates(Results & res) const
diff --git a/search/processor.hpp b/search/processor.hpp
index 1cdadb22f1..0a0de1b566 100644
--- a/search/processor.hpp
+++ b/search/processor.hpp
@@ -130,12 +130,12 @@ protected:
friend string DebugPrint(ViewportID viewportId);
- friend class FeatureLoader;
friend class BestNameFinder;
friend class DoFindLocality;
+ friend class FeatureLoader;
friend class HouseCompFactory;
- friend class Ranker;
friend class PreResult2Maker;
+ friend class Ranker;
int GetCategoryLocales(int8_t(&arr)[3]) const;
@@ -144,7 +144,7 @@ protected:
function<void(size_t /* tokenId */, uint32_t /* typeId */)> const & fn) const;
void ProcessEmojiIfNeeded(
- strings::UniString const & token, size_t ind,
+ strings::UniString const & token, size_t index,
function<void(size_t /* tokenId */, uint32_t /* typeId */)> const & fn) const;
using TMWMVector = vector<shared_ptr<MwmInfo>>;
@@ -210,7 +210,7 @@ protected:
bool m_viewportSearch;
PreRanker m_preRanker;
- unique_ptr<Ranker> m_ranker;
+ Ranker m_ranker;
Geocoder m_geocoder;
ReverseGeocoder const m_reverseGeocoder;
};
diff --git a/search/ranker.cpp b/search/ranker.cpp
index 801c373dbf..8507cc5ff4 100644
--- a/search/ranker.cpp
+++ b/search/ranker.cpp
@@ -29,22 +29,22 @@ void UpdateNameScore(vector<strings::UniString> const & tokens, TSlice const & s
bestScore = score;
}
-void RemoveDuplicatingLinear(vector<IndexedValue> & indV)
+void RemoveDuplicatingLinear(vector<IndexedValue> & values)
{
PreResult2::LessLinearTypesF lessCmp;
PreResult2::EqualLinearTypesF equalCmp;
- sort(indV.begin(), indV.end(), [&lessCmp](IndexedValue const & lhs, IndexedValue const & rhs)
+ sort(values.begin(), values.end(), [&lessCmp](IndexedValue const & lhs, IndexedValue const & rhs)
{
return lessCmp(*lhs, *rhs);
});
- indV.erase(unique(indV.begin(), indV.end(),
- [&equalCmp](IndexedValue const & lhs, IndexedValue const & rhs)
- {
- return equalCmp(*lhs, *rhs);
- }),
- indV.end());
+ values.erase(unique(values.begin(), values.end(),
+ [&equalCmp](IndexedValue const & lhs, IndexedValue const & rhs)
+ {
+ return equalCmp(*lhs, *rhs);
+ }),
+ values.end());
}
} // namespace
@@ -179,14 +179,14 @@ public:
}
};
-bool Ranker::IsResultExists(PreResult2 const & p, vector<IndexedValue> const & indV)
+bool Ranker::IsResultExists(PreResult2 const & p, vector<IndexedValue> const & values)
{
PreResult2::StrictEqualF equalCmp(p);
// Do not insert duplicating results.
- return indV.end() != find_if(indV.begin(), indV.end(), [&equalCmp](IndexedValue const & iv)
- {
- return equalCmp(*iv);
- });
+ return values.end() != find_if(values.begin(), values.end(), [&equalCmp](IndexedValue const & iv)
+ {
+ return equalCmp(*iv);
+ });
}
void Ranker::MakePreResult2(Geocoder::Params const & params, vector<IndexedValue> & cont,
@@ -216,28 +216,28 @@ void Ranker::MakePreResult2(Geocoder::Params const & params, vector<IndexedValue
void Ranker::FlushResults(Geocoder::Params const & params, Results & res, size_t resCount)
{
- vector<IndexedValue> indV;
+ vector<IndexedValue> values;
vector<FeatureID> streets;
- MakePreResult2(params, indV, streets);
- RemoveDuplicatingLinear(indV);
- if (indV.empty())
+ MakePreResult2(params, values, streets);
+ RemoveDuplicatingLinear(values);
+ if (values.empty())
return;
- sort(indV.rbegin(), indV.rend(), my::LessBy(&IndexedValue::GetRank));
+ sort(values.rbegin(), values.rend(), my::LessBy(&IndexedValue::GetRank));
- m_processor.ProcessSuggestions(indV, res);
+ m_processor.ProcessSuggestions(values, res);
// Emit feature results.
size_t count = res.GetCount();
- for (size_t i = 0; i < indV.size() && count < resCount; ++i)
+ for (size_t i = 0; i < values.size() && count < resCount; ++i)
{
if (m_processor.IsCancelled())
break;
- LOG(LDEBUG, (indV[i]));
+ LOG(LDEBUG, (values[i]));
- auto const & preResult2 = *indV[i];
+ auto const & preResult2 = *values[i];
if (res.AddResult(m_processor.MakeResult(preResult2)))
++count;
}
@@ -245,23 +245,23 @@ void Ranker::FlushResults(Geocoder::Params const & params, Results & res, size_t
void Ranker::FlushViewportResults(Geocoder::Params const & params, Results & res)
{
- vector<IndexedValue> indV;
+ vector<IndexedValue> values;
vector<FeatureID> streets;
- MakePreResult2(params, indV, streets);
- RemoveDuplicatingLinear(indV);
- if (indV.empty())
+ MakePreResult2(params, values, streets);
+ RemoveDuplicatingLinear(values);
+ if (values.empty())
return;
- sort(indV.begin(), indV.end(), my::LessBy(&IndexedValue::GetDistanceToPivot));
+ sort(values.begin(), values.end(), my::LessBy(&IndexedValue::GetDistanceToPivot));
- for (size_t i = 0; i < indV.size(); ++i)
+ for (size_t i = 0; i < values.size(); ++i)
{
if (m_processor.IsCancelled())
break;
res.AddResultNoChecks(
- (*(indV[i]))
+ (*(values[i]))
.GenerateFinalResult(m_processor.m_infoGetter, &m_processor.m_categories,
&m_processor.m_prefferedTypes, m_processor.m_currentLocaleCode,
nullptr /* Viewport results don't need calculated address */));
diff --git a/search/ranker.hpp b/search/ranker.hpp
index c01dacb958..84b760acf0 100644
--- a/search/ranker.hpp
+++ b/search/ranker.hpp
@@ -3,7 +3,6 @@
#include "search/geocoder.hpp"
#include "search/intermediate_result.hpp"
#include "search/mode.hpp"
-#include "search/processor.hpp"
#include "indexer/feature_decl.hpp"
@@ -22,9 +21,9 @@ public:
{
}
- void Init(bool viewportSearch) { m_viewportSearch = viewportSearch; }
+ inline void Init(bool viewportSearch) { m_viewportSearch = viewportSearch; }
- bool IsResultExists(PreResult2 const & p, vector<IndexedValue> const & indV);
+ bool IsResultExists(PreResult2 const & p, vector<IndexedValue> const & values);
void MakePreResult2(Geocoder::Params const & params, vector<IndexedValue> & cont,
vector<FeatureID> & streets);
@@ -41,5 +40,4 @@ private:
// todo(@m) Remove.
Processor & m_processor;
};
-
} // namespace search