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:
authorygorshenin <mipt.vi002@gmail.com>2016-05-31 14:39:48 +0300
committerygorshenin <mipt.vi002@gmail.com>2016-05-31 14:39:48 +0300
commit59f40d7669598a229ffa4f6269e17234f9af9506 (patch)
tree9ed19ec401f41a11243a170e433c6d5222760624 /search
parentd7d2388c454b4046b2053273c29690e75e45468c (diff)
parent4cb85be42ae4b832e7bc67090cca871a577ebf6b (diff)
Merge pull request #3362 from mpimenov/processor_v2
[search] Merged Processor and ProcessorV2.
Diffstat (limited to 'search')
-rw-r--r--search/processor.cpp395
-rw-r--r--search/processor.hpp81
-rw-r--r--search/processor_factory.hpp4
-rw-r--r--search/search.pro2
-rw-r--r--search/search_engine.cpp4
-rw-r--r--search/search_integration_tests/processor_test.cpp (renamed from search/search_integration_tests/search_query_v2_test.cpp)17
-rw-r--r--search/search_integration_tests/search_integration_tests.pro4
-rw-r--r--search/v2/processor_v2.cpp73
-rw-r--r--search/v2/processor_v2.hpp29
9 files changed, 251 insertions, 358 deletions
diff --git a/search/processor.cpp b/search/processor.cpp
index bf74e215d7..d3a4727094 100644
--- a/search/processor.cpp
+++ b/search/processor.cpp
@@ -31,6 +31,8 @@
#include "indexer/search_string_utils.hpp"
#include "indexer/trie_reader.hpp"
+#include "geometry/mercator.hpp"
+
#include "platform/mwm_traits.hpp"
#include "platform/mwm_version.hpp"
#include "platform/preferred_languages.hpp"
@@ -226,9 +228,10 @@ Processor::Processor(Index & index, CategoriesHolder const & categories,
, m_mode(Mode::Everywhere)
, m_worldSearch(true)
, m_suggestsEnabled(true)
- , m_preRanker(kPreResultsCount)
, m_viewportSearch(false)
- , m_keepHouseNumberInQuery(false)
+ , m_keepHouseNumberInQuery(true)
+ , m_preRanker(kPreResultsCount)
+ , m_geocoder(index, infoGetter)
, m_reverseGeocoder(index)
{
// Initialize keywords scorer.
@@ -244,6 +247,136 @@ Processor::Processor(Index & index, CategoriesHolder const & categories,
SetPreferredLocale("en");
}
+void Processor::Init(bool viewportSearch)
+{
+ Reset();
+
+ m_tokens.clear();
+ m_prefix.clear();
+ m_preRanker.Clear();
+ m_viewportSearch = viewportSearch;
+}
+
+void Processor::SetViewport(m2::RectD const & viewport, bool forceUpdate)
+{
+ Reset();
+
+ TMWMVector mwmsInfo;
+ m_index.GetMwmsInfo(mwmsInfo);
+
+ SetViewportByIndex(mwmsInfo, viewport, CURRENT_V, forceUpdate);
+}
+
+void Processor::SetPreferredLocale(string const & locale)
+{
+ ASSERT(!locale.empty(), ());
+
+ LOG(LINFO, ("New preffered locale:", locale));
+
+ int8_t const code = StringUtf8Multilang::GetLangIndex(languages::Normalize(locale));
+ SetLanguage(LANG_CURRENT, code);
+
+ m_currentLocaleCode = CategoriesHolder::MapLocaleToInteger(locale);
+
+ // Default initialization.
+ // If you want to reset input language, call SetInputLocale before search.
+ SetInputLocale(locale);
+
+#ifdef FIND_LOCALITY_TEST
+ m_locality.SetLanguage(code);
+#endif
+}
+
+void Processor::SetInputLocale(string const & locale)
+{
+ if (locale.empty())
+ return;
+
+ LOG(LDEBUG, ("New input locale:", locale));
+ SetLanguage(LANG_INPUT, StringUtf8Multilang::GetLangIndex(languages::Normalize(locale)));
+ m_inputLocaleCode = CategoriesHolder::MapLocaleToInteger(locale);
+}
+
+void Processor::SetQuery(string const & query)
+{
+ m_query = query;
+
+ /// @todo Why Init is separated with SetQuery?
+ ASSERT(m_tokens.empty(), ());
+ ASSERT(m_prefix.empty(), ());
+
+ // Following code splits input query by delimiters except hash tags
+ // first, and then splits result tokens by hashtags. The goal is to
+ // retrieve all tokens that start with a single hashtag and leave
+ // them as is.
+
+ vector<strings::UniString> tokens;
+ {
+ search::DelimitersWithExceptions delims(vector<strings::UniChar>{'#'});
+ SplitUniString(NormalizeAndSimplifyString(query), MakeBackInsertFunctor(tokens), delims);
+ }
+
+ search::Delimiters delims;
+ {
+ buffer_vector<strings::UniString, 32> subTokens;
+ for (auto const & token : tokens)
+ {
+ size_t numHashes = 0;
+ for (; numHashes < token.size() && token[numHashes] == '#'; ++numHashes)
+ ;
+
+ // Splits |token| by hashtags, because all other delimiters are
+ // already removed.
+ subTokens.clear();
+ SplitUniString(token, MakeBackInsertFunctor(subTokens), delims);
+ if (subTokens.empty())
+ continue;
+
+ if (numHashes == 1)
+ m_tokens.push_back(strings::MakeUniString("#") + subTokens[0]);
+ else
+ m_tokens.emplace_back(move(subTokens[0]));
+
+ for (size_t i = 1; i < subTokens.size(); ++i)
+ m_tokens.push_back(move(subTokens[i]));
+ }
+ }
+
+ // Assign prefix with last parsed token.
+ if (!m_tokens.empty() && !delims(strings::LastUniChar(query)))
+ {
+ m_prefix.swap(m_tokens.back());
+ m_tokens.pop_back();
+ }
+
+ int const maxTokensCount = MAX_TOKENS - 1;
+ if (m_tokens.size() > maxTokensCount)
+ m_tokens.resize(maxTokensCount);
+
+ // Assign tokens and prefix to scorer.
+ m_keywordsScorer.SetKeywords(m_tokens.data(), m_tokens.size(), m_prefix);
+
+ // get preffered types to show in results
+ m_prefferedTypes.clear();
+ ForEachCategoryTypes(v2::QuerySliceOnRawStrings<decltype(m_tokens)>(m_tokens, m_prefix),
+ [&](size_t, uint32_t t)
+ {
+ m_prefferedTypes.insert(t);
+ });
+}
+
+void Processor::SetRankPivot(m2::PointD const & pivot)
+{
+ if (!m2::AlmostEqualULPs(pivot, m_pivot))
+ {
+ storage::CountryInfo ci;
+ m_infoGetter.GetRegionInfo(pivot, ci);
+ m_region.swap(ci.m_name);
+ }
+
+ m_pivot = pivot;
+}
+
void Processor::SetLanguage(int id, int8_t lang)
{
m_keywordsScorer.SetLanguage(GetLangIndex(id), lang);
@@ -270,16 +403,6 @@ m2::RectD Processor::GetPivotRect() const
return NormalizeViewport(viewport);
}
-void Processor::SetViewport(m2::RectD const & viewport, bool forceUpdate)
-{
- Reset();
-
- TMWMVector mwmsInfo;
- m_index.GetMwmsInfo(mwmsInfo);
-
- SetViewportByIndex(mwmsInfo, viewport, CURRENT_V, forceUpdate);
-}
-
void Processor::SetViewportByIndex(TMWMVector const & mwmsInfo, m2::RectD const & viewport,
size_t idx, bool forceUpdate)
{
@@ -321,70 +444,8 @@ void Processor::SetViewportByIndex(TMWMVector const & mwmsInfo, m2::RectD const
}
}
-void Processor::SetRankPivot(m2::PointD const & pivot)
-{
- if (!m2::AlmostEqualULPs(pivot, m_pivot))
- {
- storage::CountryInfo ci;
- m_infoGetter.GetRegionInfo(pivot, ci);
- m_region.swap(ci.m_name);
- }
-
- m_pivot = pivot;
-}
-
-void Processor::SetPreferredLocale(string const & locale)
-{
- ASSERT(!locale.empty(), ());
-
- LOG(LINFO, ("New preffered locale:", locale));
-
- int8_t const code = StringUtf8Multilang::GetLangIndex(languages::Normalize(locale));
- SetLanguage(LANG_CURRENT, code);
-
- m_currentLocaleCode = CategoriesHolder::MapLocaleToInteger(locale);
-
- // Default initialization.
- // If you want to reset input language, call SetInputLocale before search.
- SetInputLocale(locale);
-
-#ifdef FIND_LOCALITY_TEST
- m_locality.SetLanguage(code);
-#endif
-}
-
-void Processor::SetInputLocale(string const & locale)
-{
- if (!locale.empty())
- {
- LOG(LDEBUG, ("New input locale:", locale));
-
- SetLanguage(LANG_INPUT, StringUtf8Multilang::GetLangIndex(languages::Normalize(locale)));
-
- m_inputLocaleCode = CategoriesHolder::MapLocaleToInteger(locale);
- }
-}
-
-void Processor::ClearCaches()
-{
- for (size_t i = 0; i < COUNT_V; ++i)
- ClearCache(i);
-
- m_locality.ClearCache();
-}
-
void Processor::ClearCache(size_t ind) { m_viewport[ind].MakeEmpty(); }
-void Processor::Init(bool viewportSearch)
-{
- Reset();
-
- m_tokens.clear();
- m_prefix.clear();
- m_preRanker.Clear();
- m_viewportSearch = viewportSearch;
-}
-
int Processor::GetCategoryLocales(int8_t(&arr)[3]) const
{
static int8_t const enLocaleCode = CategoriesHolder::MapLocaleToInteger("en");
@@ -431,98 +492,35 @@ void Processor::ProcessEmojiIfNeeded(strings::UniString const & token, size_t in
}
}
-void Processor::SetQuery(string const & query)
+void Processor::Search(Results & results, size_t limit)
{
- m_query = query;
-
- /// @todo Why Init is separated with SetQuery?
- ASSERT(m_tokens.empty(), ());
- ASSERT(m_prefix.empty(), ());
-
- // Following code splits input query by delimiters except hash tags
- // first, and then splits result tokens by hashtags. The goal is to
- // retrieve all tokens that start with a single hashtag and leave
- // them as is.
-
- vector<strings::UniString> tokens;
- {
- search::DelimitersWithExceptions delims(vector<strings::UniChar>{'#'});
- SplitUniString(NormalizeAndSimplifyString(query), MakeBackInsertFunctor(tokens), delims);
- }
-
- search::Delimiters delims;
- {
- buffer_vector<strings::UniString, 32> subTokens;
- for (auto const & token : tokens)
- {
- size_t numHashes = 0;
- for (; numHashes < token.size() && token[numHashes] == '#'; ++numHashes)
- ;
-
- // Splits |token| by hashtags, because all other delimiters are
- // already removed.
- subTokens.clear();
- SplitUniString(token, MakeBackInsertFunctor(subTokens), delims);
- if (subTokens.empty())
- continue;
-
- if (numHashes == 1)
- m_tokens.push_back(strings::MakeUniString("#") + subTokens[0]);
- else
- m_tokens.emplace_back(move(subTokens[0]));
+ if (m_tokens.empty())
+ SuggestStrings(results);
- for (size_t i = 1; i < subTokens.size(); ++i)
- m_tokens.push_back(move(subTokens[i]));
- }
- }
-
- // Assign prefix with last parsed token.
- if (!m_tokens.empty() && !delims(strings::LastUniChar(query)))
- {
- m_prefix.swap(m_tokens.back());
- m_tokens.pop_back();
- }
+ v2::Geocoder::Params params;
+ InitParams(params);
+ params.m_mode = m_mode;
- int const maxTokensCount = MAX_TOKENS - 1;
- if (m_tokens.size() > maxTokensCount)
- m_tokens.resize(maxTokensCount);
+ params.m_pivot = GetPivotRect();
+ params.m_accuratePivotCenter = GetPivotPoint();
+ m_geocoder.SetParams(params);
- // Assign tokens and prefix to scorer.
- m_keywordsScorer.SetKeywords(m_tokens.data(), m_tokens.size(), m_prefix);
+ m_geocoder.GoEverywhere(m_preRanker);
- // get preffered types to show in results
- m_prefferedTypes.clear();
- ForEachCategoryTypes(v2::QuerySliceOnRawStrings<decltype(m_tokens)>(m_tokens, m_prefix),
- [&](size_t, uint32_t t)
- {
- m_prefferedTypes.insert(t);
- });
+ FlushResults(params, results, limit);
}
-void Processor::FlushViewportResults(v2::Geocoder::Params const & params, Results & res,
- bool oldHouseSearch)
+void Processor::SearchViewportPoints(Results & results)
{
- vector<IndexedValue> indV;
- vector<FeatureID> streets;
+ v2::Geocoder::Params params;
+ InitParams(params);
+ params.m_pivot = m_viewport[CURRENT_V];
+ params.m_accuratePivotCenter = params.m_pivot.Center();
+ m_geocoder.SetParams(params);
- MakePreResult2(params, indV, streets);
- RemoveDuplicatingLinear(indV);
- if (indV.empty())
- return;
+ m_geocoder.GoInViewport(m_preRanker);
- sort(indV.begin(), indV.end(), my::LessBy(&IndexedValue::GetDistanceToPivot));
-
- for (size_t i = 0; i < indV.size(); ++i)
- {
- if (IsCancelled())
- break;
-
- res.AddResultNoChecks(
- (*(indV[i]))
- .GenerateFinalResult(m_infoGetter, &m_categories, &m_prefferedTypes,
- m_currentLocaleCode,
- nullptr /* Viewport results don't need calculated address */));
- }
+ FlushViewportResults(params, results);
}
void Processor::SearchCoordinates(Results & res) const
@@ -709,8 +707,7 @@ void Processor::MakePreResult2(v2::Geocoder::Params const & params, vector<T> &
});
}
-void Processor::FlushResults(v2::Geocoder::Params const & params, Results & res, bool allMWMs,
- size_t resCount, bool oldHouseSearch)
+void Processor::FlushResults(v2::Geocoder::Params const & params, Results & res, size_t resCount)
{
vector<IndexedValue> indV;
vector<FeatureID> streets;
@@ -722,9 +719,7 @@ void Processor::FlushResults(v2::Geocoder::Params const & params, Results & res,
sort(indV.rbegin(), indV.rend(), my::LessBy(&IndexedValue::GetRank));
- // Do not process suggestions in additional search.
- if (!allMWMs || res.GetCount() == 0)
- ProcessSuggestions(indV, res);
+ ProcessSuggestions(indV, res);
// Emit feature results.
size_t count = res.GetCount();
@@ -741,9 +736,29 @@ void Processor::FlushResults(v2::Geocoder::Params const & params, Results & res,
}
}
-int Processor::GetQueryIndexScale(m2::RectD const & viewport) const
+void Processor::FlushViewportResults(v2::Geocoder::Params const & params, Results & res)
{
- return search::GetQueryIndexScale(viewport);
+ vector<IndexedValue> indV;
+ vector<FeatureID> streets;
+
+ MakePreResult2(params, indV, streets);
+ RemoveDuplicatingLinear(indV);
+ if (indV.empty())
+ return;
+
+ sort(indV.begin(), indV.end(), my::LessBy(&IndexedValue::GetDistanceToPivot));
+
+ for (size_t i = 0; i < indV.size(); ++i)
+ {
+ if (IsCancelled())
+ break;
+
+ res.AddResultNoChecks(
+ (*(indV[i]))
+ .GenerateFinalResult(m_infoGetter, &m_categories, &m_prefferedTypes,
+ m_currentLocaleCode,
+ nullptr /* Viewport results don't need calculated address */));
+ }
}
void Processor::RemoveStringPrefix(string const & str, string & res) const
@@ -1103,7 +1118,7 @@ int GetOldTypeFromIndex(size_t index)
}
} // namespace
-void Processor::InitParams(bool localitySearch, QueryParams & params)
+void Processor::InitParams(QueryParams & params)
{
params.Clear();
@@ -1120,32 +1135,27 @@ void Processor::InitParams(bool localitySearch, QueryParams & params)
params.m_isCategorySynonym.assign(tokensCount + (m_prefix.empty() ? 0 : 1), false);
// Add names of categories (and synonyms).
- if (!localitySearch)
- {
- Classificator const & c = classif();
- auto addSyms = [&](size_t i, uint32_t t)
- {
- QueryParams::TSynonymsVector & v = params.GetTokens(i);
+ Classificator const & c = classif();
+ auto addSyms = [&](size_t i, uint32_t t) {
+ QueryParams::TSynonymsVector & v = params.GetTokens(i);
- uint32_t const index = c.GetIndexForType(t);
- v.push_back(FeatureTypeToString(index));
- params.m_isCategorySynonym[i] = true;
+ uint32_t const index = c.GetIndexForType(t);
+ v.push_back(FeatureTypeToString(index));
+ params.m_isCategorySynonym[i] = true;
- // v2-version MWM has raw classificator types in search index prefix, so
- // do the hack: add synonyms for old convention if needed.
- if (m_supportOldFormat)
+ // v2-version MWM has raw classificator types in search index prefix, so
+ // do the hack: add synonyms for old convention if needed.
+ if (m_supportOldFormat)
+ {
+ int const type = GetOldTypeFromIndex(index);
+ if (type >= 0)
{
- int const type = GetOldTypeFromIndex(index);
- if (type >= 0)
- {
- ASSERT(type == 70 || type > 4000, (type));
- v.push_back(FeatureTypeToString(static_cast<uint32_t>(type)));
- }
+ ASSERT(type == 70 || type > 4000, (type));
+ v.push_back(FeatureTypeToString(static_cast<uint32_t>(type)));
}
- };
- ForEachCategoryTypes(v2::QuerySliceOnRawStrings<decltype(m_tokens)>(m_tokens, m_prefix),
- addSyms);
- }
+ }
+ };
+ ForEachCategoryTypes(v2::QuerySliceOnRawStrings<decltype(m_tokens)>(m_tokens, m_prefix), addSyms);
for (auto & tokens : params.m_tokens)
{
@@ -1159,6 +1169,19 @@ void Processor::InitParams(bool localitySearch, QueryParams & params)
params.m_langs.insert(GetLanguage(i));
}
+void Processor::ClearCaches()
+{
+ for (size_t i = 0; i < COUNT_V; ++i)
+ ClearCache(i);
+
+ m_locality.ClearCache();
+ m_geocoder.ClearCaches();
+}
+
+void Processor::Reset() { m_geocoder.Reset(); }
+
+void Processor::Cancel() { m_geocoder.Cancel(); }
+
void Processor::SuggestStrings(Results & res)
{
if (m_prefix.empty() || !m_suggestsEnabled)
diff --git a/search/processor.hpp b/search/processor.hpp
index e3febba23c..514b2e1994 100644
--- a/search/processor.hpp
+++ b/search/processor.hpp
@@ -50,6 +50,12 @@ namespace search
struct Locality;
struct Region;
struct QueryParams;
+class ReverseGeocoder;
+
+namespace v2
+{
+class Geocoder;
+} // namespace search::v2
namespace impl
{
@@ -79,49 +85,44 @@ public:
/// @param[in] forceUpdate Pass true (default) to recache feature's ids even
/// if viewport is a part of the old cached rect.
void SetViewport(m2::RectD const & viewport, bool forceUpdate);
-
+ void SetPreferredLocale(string const & locale);
+ void SetInputLocale(string const & locale);
+ void SetQuery(string const & query);
// TODO (@y): this function must be removed.
void SetRankPivot(m2::PointD const & pivot);
- inline string const & GetPivotRegion() const { return m_region; }
- inline void SetPosition(m2::PointD const & position) { m_position = position; }
- inline m2::PointD const & GetPosition() const { return m_position; }
-
inline void SetMode(Mode mode) { m_mode = mode; }
inline void SetSearchInWorld(bool b) { m_worldSearch = b; }
inline void SetSuggestsEnabled(bool enabled) { m_suggestsEnabled = enabled; }
+ inline void SetPosition(m2::PointD const & position) { m_position = position; }
+
+ inline string const & GetPivotRegion() const { return m_region; }
+ inline m2::PointD const & GetPosition() const { return m_position; }
/// Suggestions language code, not the same as we use in mwm data
int8_t m_inputLocaleCode, m_currentLocaleCode;
- void SetPreferredLocale(string const & locale);
- void SetInputLocale(string const & locale);
-
- void SetQuery(string const & query);
inline bool IsEmptyQuery() const { return (m_prefix.empty() && m_tokens.empty()); }
- /// @name Different search functions.
+ /// @name Various search functions.
//@{
- virtual void Search(Results & results, size_t limit) = 0;
- virtual void SearchViewportPoints(Results & results) = 0;
+ void Search(Results & results, size_t limit);
+ void SearchViewportPoints(Results & results);
// Tries to generate a (lat, lon) result from |m_query|.
void SearchCoordinates(Results & res) const;
//@}
- // Get scale level to make geometry index query for current viewport.
- virtual int GetQueryIndexScale(m2::RectD const & viewport) const;
-
- virtual void ClearCaches();
-
struct CancelException
{
};
- /// @name This stuff is public for implementation classes in processor.cpp
- /// Do not use it in client code.
- //@{
+ void InitParams(QueryParams & params);
+
+ void ClearCaches();
- void InitParams(bool localitySearch, QueryParams & params);
+ // my::Cancellable overrides:
+ void Reset() override;
+ void Cancel() override;
protected:
enum ViewportID
@@ -161,16 +162,8 @@ protected:
void MakePreResult2(v2::Geocoder::Params const & params, vector<T> & cont,
vector<FeatureID> & streets);
- /// @param allMWMs Deprecated, need to support old search algorithm.
- /// @param oldHouseSearch Deprecated, need to support old search algorithm.
- //@{
- void FlushHouses(Results & res, bool allMWMs, vector<FeatureID> const & streets);
-
- void FlushResults(v2::Geocoder::Params const & params, Results & res, bool allMWMs,
- size_t resCount, bool oldHouseSearch);
- void FlushViewportResults(v2::Geocoder::Params const & params, Results & res,
- bool oldHouseSearch);
- //@}
+ void FlushResults(v2::Geocoder::Params const & params, Results & res, size_t resCount);
+ void FlushViewportResults(v2::Geocoder::Params const & params, Results & res);
void RemoveStringPrefix(string const & str, string & res) const;
void GetSuggestion(string const & name, string & suggest) const;
@@ -221,30 +214,12 @@ protected:
bool m_supportOldFormat;
- template <class TParam>
- class TCompare
- {
- using TFunction = function<bool(TParam const &, TParam const &)>;
- TFunction m_fn;
-
- public:
- TCompare() : m_fn(0) {}
- explicit TCompare(TFunction const & fn) : m_fn(fn) {}
-
- template <class T>
- bool operator()(T const & v1, T const & v2) const
- {
- return m_fn(v1, v2);
- }
- };
-
- using TQueueCompare = TCompare<impl::PreResult1>;
- using TQueue = my::limited_priority_queue<impl::PreResult1, TQueueCompare>;
-
protected:
- PreRanker m_preRanker;
bool m_viewportSearch;
bool m_keepHouseNumberInQuery;
- search::ReverseGeocoder const m_reverseGeocoder;
+
+ PreRanker m_preRanker;
+ v2::Geocoder m_geocoder;
+ ReverseGeocoder const m_reverseGeocoder;
};
} // namespace search
diff --git a/search/processor_factory.hpp b/search/processor_factory.hpp
index 83538df79f..5e0fc0fe78 100644
--- a/search/processor_factory.hpp
+++ b/search/processor_factory.hpp
@@ -1,7 +1,7 @@
#pragma once
+#include "search/processor.hpp"
#include "search/suggest.hpp"
-#include "search/v2/processor_v2.hpp"
#include "std/unique_ptr.hpp"
@@ -21,7 +21,7 @@ public:
vector<Suggest> const & suggests,
storage::CountryInfoGetter const & infoGetter)
{
- return make_unique<v2::ProcessorV2>(index, categories, suggests, infoGetter);
+ return make_unique<Processor>(index, categories, suggests, infoGetter);
}
};
} // namespace search
diff --git a/search/search.pro b/search/search.pro
index 8757ba31cf..504169295d 100644
--- a/search/search.pro
+++ b/search/search.pro
@@ -56,7 +56,6 @@ HEADERS += \
v2/mwm_context.hpp \
v2/nested_rects_cache.hpp \
v2/pre_ranking_info.hpp \
- v2/processor_v2.hpp \
v2/rank_table_cache.hpp \
v2/ranking_info.hpp \
v2/ranking_utils.hpp \
@@ -103,7 +102,6 @@ SOURCES += \
v2/mwm_context.cpp \
v2/nested_rects_cache.cpp \
v2/pre_ranking_info.cpp \
- v2/processor_v2.cpp \
v2/rank_table_cache.cpp \
v2/ranking_info.cpp \
v2/ranking_utils.cpp \
diff --git a/search/search_engine.cpp b/search/search_engine.cpp
index 7bb5ac4cdd..5bfe2f6c42 100644
--- a/search/search_engine.cpp
+++ b/search/search_engine.cpp
@@ -160,9 +160,9 @@ Engine::~Engine()
weak_ptr<ProcessorHandle> Engine::Search(SearchParams const & params, m2::RectD const & viewport)
{
shared_ptr<ProcessorHandle> handle(new ProcessorHandle());
- PostMessage(Message::TYPE_TASK, [this, params, viewport, handle](Processor & query)
+ PostMessage(Message::TYPE_TASK, [this, params, viewport, handle](Processor & processor)
{
- DoSearch(params, viewport, handle, query);
+ DoSearch(params, viewport, handle, processor);
});
return handle;
}
diff --git a/search/search_integration_tests/search_query_v2_test.cpp b/search/search_integration_tests/processor_test.cpp
index 679d3e81a4..4d81c982d9 100644
--- a/search/search_integration_tests/search_query_v2_test.cpp
+++ b/search/search_integration_tests/processor_test.cpp
@@ -30,7 +30,7 @@ namespace search
{
namespace
{
-class ProcessorV2Test : public SearchTest
+class ProcessorTest : public SearchTest
{
public:
unique_ptr<TestSearchRequest> MakeRequest(string const & query)
@@ -53,7 +53,7 @@ public:
}
};
-UNIT_CLASS_TEST(ProcessorV2Test, Smoke)
+UNIT_CLASS_TEST(ProcessorTest, Smoke)
{
string const countryName = "Wonderland";
TestCountry wonderlandCountry(m2::PointD(10, 10), countryName, "en");
@@ -193,7 +193,7 @@ UNIT_CLASS_TEST(ProcessorV2Test, Smoke)
}
}
-UNIT_CLASS_TEST(ProcessorV2Test, SearchInWorld)
+UNIT_CLASS_TEST(ProcessorTest, SearchInWorld)
{
string const countryName = "Wonderland";
TestCountry wonderland(m2::PointD(0, 0), countryName, "en");
@@ -221,7 +221,7 @@ UNIT_CLASS_TEST(ProcessorV2Test, SearchInWorld)
}
}
-UNIT_CLASS_TEST(ProcessorV2Test, SearchByName)
+UNIT_CLASS_TEST(ProcessorTest, SearchByName)
{
string const countryName = "Wonderland";
TestCity london(m2::PointD(1, 1), "London", "en", 100 /* rank */);
@@ -259,7 +259,7 @@ UNIT_CLASS_TEST(ProcessorV2Test, SearchByName)
}
}
-UNIT_CLASS_TEST(ProcessorV2Test, DisableSuggests)
+UNIT_CLASS_TEST(ProcessorTest, DisableSuggests)
{
TestCity london1(m2::PointD(1, 1), "London", "en", 100 /* rank */);
TestCity london2(m2::PointD(-1, -1), "London", "en", 100 /* rank */);
@@ -286,7 +286,7 @@ UNIT_CLASS_TEST(ProcessorV2Test, DisableSuggests)
}
}
-UNIT_CLASS_TEST(ProcessorV2Test, TestRankingInfo)
+UNIT_CLASS_TEST(ProcessorTest, TestRankingInfo)
{
string const countryName = "Wonderland";
@@ -367,7 +367,7 @@ UNIT_CLASS_TEST(ProcessorV2Test, TestRankingInfo)
}
}
-UNIT_CLASS_TEST(ProcessorV2Test, TestPostcodes)
+UNIT_CLASS_TEST(ProcessorTest, TestPostcodes)
{
string const countryName = "Russia";
@@ -441,7 +441,6 @@ UNIT_CLASS_TEST(ProcessorV2Test, TestPostcodes)
{
TRules rules{ExactMatch(countryId, building28), ExactMatch(countryId, building29)};
TEST(ResultsMatch("Долгопрудный первомайская 141701", "ru", rules), ());
-
}
{
TRules rules{ExactMatch(countryId, building28), ExactMatch(countryId, building29)};
@@ -462,7 +461,7 @@ UNIT_CLASS_TEST(ProcessorV2Test, TestPostcodes)
}
}
-UNIT_CLASS_TEST(ProcessorV2Test, TestCategories)
+UNIT_CLASS_TEST(ProcessorTest, TestCategories)
{
string const countryName = "Wonderland";
diff --git a/search/search_integration_tests/search_integration_tests.pro b/search/search_integration_tests/search_integration_tests.pro
index 8b10e50c53..2ede061546 100644
--- a/search/search_integration_tests/search_integration_tests.pro
+++ b/search/search_integration_tests/search_integration_tests.pro
@@ -19,10 +19,10 @@ macx-*: LIBS *= "-framework IOKit"
SOURCES += \
../../testing/testingmain.cpp \
+ generate_tests.cpp \
helpers.cpp \
- search_query_v2_test.cpp \
+ processor_test.cpp \
smoke_test.cpp \
- generate_tests.cpp \
HEADERS += \
helpers.hpp \
diff --git a/search/v2/processor_v2.cpp b/search/v2/processor_v2.cpp
deleted file mode 100644
index 277d859dd7..0000000000
--- a/search/v2/processor_v2.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-#include "search/v2/processor_v2.hpp"
-
-#include "search/dummy_rank_table.hpp"
-
-#include "indexer/rank_table.hpp"
-
-#include "geometry/mercator.hpp"
-#include "geometry/rect2d.hpp"
-
-#include "base/macros.hpp"
-
-namespace search
-{
-namespace v2
-{
-ProcessorV2::ProcessorV2(Index & index, CategoriesHolder const & categories,
- vector<Suggest> const & suggests,
- storage::CountryInfoGetter const & infoGetter)
- : Processor(index, categories, suggests, infoGetter), m_geocoder(index, infoGetter)
-{
- m_keepHouseNumberInQuery = true;
-}
-
-void ProcessorV2::Reset()
-{
- Processor::Reset();
- m_geocoder.Reset();
-}
-
-void ProcessorV2::Cancel()
-{
- Processor::Cancel();
- m_geocoder.Cancel();
-}
-
-void ProcessorV2::Search(Results & results, size_t limit)
-{
- if (m_tokens.empty())
- SuggestStrings(results);
-
- Geocoder::Params params;
- InitParams(false /* localitySearch */, params);
- params.m_mode = m_mode;
-
- params.m_pivot = GetPivotRect();
- params.m_accuratePivotCenter = GetPivotPoint();
- m_geocoder.SetParams(params);
-
- m_geocoder.GoEverywhere(m_preRanker);
-
- FlushResults(params, results, false /* allMWMs */, limit, false /* oldHouseSearch */);
-}
-
-void ProcessorV2::SearchViewportPoints(Results & results)
-{
- Geocoder::Params params;
- InitParams(false /* localitySearch */, params);
- params.m_pivot = m_viewport[CURRENT_V];
- params.m_accuratePivotCenter = params.m_pivot.Center();
- m_geocoder.SetParams(params);
-
- m_geocoder.GoInViewport(m_preRanker);
-
- FlushViewportResults(params, results, false /* oldHouseSearch */);
-}
-
-void ProcessorV2::ClearCaches()
-{
- Processor::ClearCaches();
- m_geocoder.ClearCaches();
-}
-} // namespace v2
-} // namespace search
diff --git a/search/v2/processor_v2.hpp b/search/v2/processor_v2.hpp
deleted file mode 100644
index c76a494458..0000000000
--- a/search/v2/processor_v2.hpp
+++ /dev/null
@@ -1,29 +0,0 @@
-#pragma once
-
-#include "search/processor.hpp"
-#include "search/v2/geocoder.hpp"
-
-namespace search
-{
-namespace v2
-{
-class ProcessorV2 : public Processor
-{
-public:
- ProcessorV2(Index & index, CategoriesHolder const & categories, vector<Suggest> const & suggests,
- storage::CountryInfoGetter const & infoGetter);
-
- // my::Cancellable overrides:
- void Reset() override;
- void Cancel() override;
-
- // Query overrides:
- void Search(Results & results, size_t limit) override;
- void SearchViewportPoints(Results & results) override;
- void ClearCaches() override;
-
-protected:
- Geocoder m_geocoder;
-};
-} // namespace v2
-} // namespace search