diff options
author | Maxim Pimenov <m@maps.me> | 2016-05-27 12:32:04 +0300 |
---|---|---|
committer | Maxim Pimenov <m@maps.me> | 2016-05-27 18:30:44 +0300 |
commit | f227a2f797c447ec1f20974874e709978d5dade4 (patch) | |
tree | 80e2b6a01e5235df1621731fc8377f444f2aa35a /search | |
parent | 2a1b48ae4afaea61750de088a7470734727d676a (diff) |
[search] Merged Processor and ProcessorV2.
Diffstat (limited to 'search')
-rw-r--r-- | search/intermediate_result.hpp | 1 | ||||
-rw-r--r-- | search/processor.cpp | 353 | ||||
-rw-r--r-- | search/processor.hpp | 74 | ||||
-rw-r--r-- | search/processor_factory.hpp | 4 | ||||
-rw-r--r-- | search/search.pro | 2 | ||||
-rw-r--r-- | search/search_engine.cpp | 4 | ||||
-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.pro | 4 | ||||
-rw-r--r-- | search/v2/processor_v2.cpp | 73 | ||||
-rw-r--r-- | search/v2/processor_v2.hpp | 29 |
10 files changed, 240 insertions, 321 deletions
diff --git a/search/intermediate_result.hpp b/search/intermediate_result.hpp index 1a4d744281..07172b6366 100644 --- a/search/intermediate_result.hpp +++ b/search/intermediate_result.hpp @@ -1,4 +1,5 @@ #pragma once + #include "search/result.hpp" #include "search/v2/pre_ranking_info.hpp" #include "search/v2/ranking_info.hpp" diff --git a/search/processor.cpp b/search/processor.cpp index bf74e215d7..30ef79a680 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,138 @@ 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()) + { + 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 +405,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 +446,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 +494,40 @@ void Processor::ProcessEmojiIfNeeded(strings::UniString const & token, size_t in } } -void Processor::SetQuery(string const & query) +int Processor::GetQueryIndexScale(m2::RectD const & viewport) const { - 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])); + return search::GetQueryIndexScale(viewport); +} - for (size_t i = 1; i < subTokens.size(); ++i) - m_tokens.push_back(move(subTokens[i])); - } - } +void Processor::Search(Results & results, size_t limit) +{ + if (m_tokens.empty()) + SuggestStrings(results); - // 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(false /* localitySearch */, 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, false /* allMWMs */, limit, false /* oldHouseSearch */); } -void Processor::FlushViewportResults(v2::Geocoder::Params const & params, Results & res, - bool oldHouseSearch) +void Processor::SearchViewportPoints(Results & results) { - 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)); + v2::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); - for (size_t i = 0; i < indV.size(); ++i) - { - if (IsCancelled()) - break; + m_geocoder.GoInViewport(m_preRanker); - res.AddResultNoChecks( - (*(indV[i])) - .GenerateFinalResult(m_infoGetter, &m_categories, &m_prefferedTypes, - m_currentLocaleCode, - nullptr /* Viewport results don't need calculated address */)); - } + FlushViewportResults(params, results, false /* oldHouseSearch */); } void Processor::SearchCoordinates(Results & res) const @@ -741,9 +746,30 @@ 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, + bool oldHouseSearch) { - 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 @@ -1159,6 +1185,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..5b4800433e 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,50 +85,48 @@ 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; } + + // Get scale level to make geometry index query for current viewport. + int GetQueryIndexScale(m2::RectD const & viewport) const; /// 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(bool localitySearch, QueryParams & params); + void ClearCaches(); + + // my::Cancellable overrides: + void Reset() override; + void Cancel() override; + protected: enum ViewportID { @@ -164,8 +168,6 @@ protected: /// @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, @@ -221,30 +223,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..e322d6bf10 100644 --- a/search/processor_factory.hpp +++ b/search/processor_factory.hpp @@ -1,7 +1,7 @@ #pragma once #include "search/suggest.hpp" -#include "search/v2/processor_v2.hpp" +#include "search/processor.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 |