From 64a4f147bd7a9acb2d6a3e6809ef172c2696a541 Mon Sep 17 00:00:00 2001 From: Yuri Gorshenin Date: Wed, 1 Nov 2017 15:42:24 +0300 Subject: [PATCH] [search] Removed processor factory + fixed pybindings build. --- feature_list/feature_list.cpp | 2 ++ .../booking_addr_match.cpp | 1 - map/framework.cpp | 6 ++-- search/CMakeLists.txt | 1 - search/engine.cpp | 5 ++-- search/engine.hpp | 4 +-- search/processor_factory.hpp | 28 ------------------- search/pysearch/bindings.cpp | 15 +++++----- search/search.pro | 1 - search/search_integration_tests/helpers.cpp | 4 +-- .../features_collector_tool.cpp | 2 +- .../search_quality_tool.cpp | 3 +- .../test_search_engine.cpp | 10 +++---- .../test_search_engine.hpp | 4 +-- 14 files changed, 24 insertions(+), 62 deletions(-) delete mode 100644 search/processor_factory.hpp diff --git a/feature_list/feature_list.cpp b/feature_list/feature_list.cpp index 11e2f7446c..4f3371f27b 100644 --- a/feature_list/feature_list.cpp +++ b/feature_list/feature_list.cpp @@ -17,9 +17,11 @@ #include "platform/platform.hpp" #include "search/engine.hpp" +#include "search/locality_finder.hpp" #include "search/reverse_geocoder.hpp" #include "search/search_quality/helpers.hpp" +#include "storage/country_info_getter.hpp" #include "storage/index.hpp" #include "storage/storage.hpp" diff --git a/generator/booking_quality_check/booking_addr_match.cpp b/generator/booking_quality_check/booking_addr_match.cpp index 8b491b6144..639a9153a0 100644 --- a/generator/booking_quality_check/booking_addr_match.cpp +++ b/generator/booking_quality_check/booking_addr_match.cpp @@ -3,7 +3,6 @@ #include "map/framework.hpp" -#include "search/processor_factory.hpp" #include "search/ranking_info.hpp" #include "search/result.hpp" #include "search/search_quality/helpers.hpp" diff --git a/map/framework.cpp b/map/framework.cpp index 71b104215d..11cb3d01fa 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -27,7 +27,6 @@ #include "search/geometry_utils.hpp" #include "search/intermediate_result.hpp" #include "search/locality_finder.hpp" -#include "search/processor_factory.hpp" #include "search/reverse_geocoder.hpp" #include "search/viewport_search_params.hpp" @@ -1528,9 +1527,8 @@ void Framework::InitSearchEngine() search::Engine::Params params; params.m_locale = languages::GetCurrentOrig(); params.m_numThreads = 1; - m_searchEngine.reset(new search::Engine(const_cast(m_model.GetIndex()), - GetDefaultCategories(), *m_infoGetter, - make_unique(), params)); + m_searchEngine = make_unique(const_cast(m_model.GetIndex()), + GetDefaultCategories(), *m_infoGetter, params); } catch (RootException const & e) { diff --git a/search/CMakeLists.txt b/search/CMakeLists.txt index 2594b4895a..0078413f2b 100644 --- a/search/CMakeLists.txt +++ b/search/CMakeLists.txt @@ -96,7 +96,6 @@ set( pre_ranking_info.hpp processor.cpp processor.hpp - processor_factory.hpp projection_on_street.cpp projection_on_street.hpp query_params.cpp diff --git a/search/engine.cpp b/search/engine.cpp index c2acd59e69..2426492bb1 100644 --- a/search/engine.cpp +++ b/search/engine.cpp @@ -91,8 +91,7 @@ Engine::Params::Params(string const & locale, size_t numThreads) // Engine ------------------------------------------------------------------------------------------ Engine::Engine(Index & index, CategoriesHolder const & categories, - storage::CountryInfoGetter const & infoGetter, unique_ptr factory, - Params const & params) + storage::CountryInfoGetter const & infoGetter, Params const & params) : m_shutdown(false) { InitSuggestions doInit; @@ -102,7 +101,7 @@ Engine::Engine(Index & index, CategoriesHolder const & categories, m_contexts.resize(params.m_numThreads); for (size_t i = 0; i < params.m_numThreads; ++i) { - auto processor = factory->Build(index, categories, m_suggests, infoGetter); + auto processor = make_unique(index, categories, m_suggests, infoGetter); processor->SetPreferredLocale(params.m_locale); m_contexts[i].m_processor = move(processor); } diff --git a/search/engine.hpp b/search/engine.hpp index 09de8f37b9..a274a11baf 100644 --- a/search/engine.hpp +++ b/search/engine.hpp @@ -1,6 +1,5 @@ #pragma once -#include "search/processor_factory.hpp" #include "search/result.hpp" #include "search/search_params.hpp" #include "search/suggest.hpp" @@ -91,8 +90,7 @@ public: // Doesn't take ownership of index and categories. Engine(Index & index, CategoriesHolder const & categories, - storage::CountryInfoGetter const & infoGetter, unique_ptr factory, - Params const & params); + storage::CountryInfoGetter const & infoGetter, Params const & params); ~Engine(); // Posts search request to the queue and returns its handle. diff --git a/search/processor_factory.hpp b/search/processor_factory.hpp deleted file mode 100644 index b8946f6d23..0000000000 --- a/search/processor_factory.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include "search/processor.hpp" -#include "search/search_params.hpp" -#include "search/suggest.hpp" - -#include "std/unique_ptr.hpp" - -namespace storage -{ -class CountryInfoGetter; -} - -namespace search -{ -class ProcessorFactory -{ -public: - virtual ~ProcessorFactory() = default; - - virtual unique_ptr Build(Index & index, CategoriesHolder const & categories, - vector const & suggests, - storage::CountryInfoGetter const & infoGetter) - { - return make_unique(index, categories, suggests, infoGetter); - } -}; -} // namespace search diff --git a/search/pysearch/bindings.cpp b/search/pysearch/bindings.cpp index 1715f156af..fd081f48ee 100644 --- a/search/pysearch/bindings.cpp +++ b/search/pysearch/bindings.cpp @@ -1,5 +1,4 @@ #include "search/engine.hpp" -#include "search/processor_factory.hpp" #include "search/search_tests_support/test_search_engine.hpp" #include "search/search_tests_support/test_search_request.hpp" @@ -147,8 +146,8 @@ struct SearchEngineProxy auto infoGetter = storage::CountryInfoReader::CreateCountryInfoReader(platform); infoGetter->InitAffiliationsInfo(&*g_affiliations); - m_engine = make_shared( - move(infoGetter), my::make_unique(), search::Engine::Params{}); + m_engine = make_shared(move(infoGetter), + search::Engine::Params{}); vector mwms; platform::FindAllLocalMapsAndCleanup(numeric_limits::max() /* the latest version */, @@ -168,14 +167,14 @@ struct SearchEngineProxy sp.m_query = params.m_query; sp.m_inputLocale = params.m_locale; sp.m_mode = search::Mode::Everywhere; - sp.SetPosition(MercatorBounds::YToLat(params.m_position.m_y), - MercatorBounds::XToLon(params.m_position.m_x)); - sp.m_suggestsEnabled = false; + sp.m_position = m2::PointD(params.m_position.m_x, params.m_position.m_y); + sp.m_needAddress = true; auto const & bottomLeft = params.m_viewport.m_min; auto const & topRight = params.m_viewport.m_max; - m2::RectD const viewport(bottomLeft.m_x, bottomLeft.m_y, topRight.m_x, topRight.m_y); - search::tests_support::TestSearchRequest request(*m_engine, sp, viewport); + sp.m_viewport = m2::RectD(bottomLeft.m_x, bottomLeft.m_y, topRight.m_x, topRight.m_y); + + search::tests_support::TestSearchRequest request(*m_engine, sp); request.Run(); boost::python::list results; diff --git a/search/search.pro b/search/search.pro index ca83706afa..4fa1b53cf9 100644 --- a/search/search.pro +++ b/search/search.pro @@ -61,7 +61,6 @@ HEADERS += \ pre_ranker.hpp \ pre_ranking_info.hpp \ processor.hpp \ - processor_factory.hpp \ projection_on_street.hpp \ query_params.hpp \ query_saver.hpp \ diff --git a/search/search_integration_tests/helpers.cpp b/search/search_integration_tests/helpers.cpp index d585a90fc9..4ae09fc387 100644 --- a/search/search_integration_tests/helpers.cpp +++ b/search/search_integration_tests/helpers.cpp @@ -1,7 +1,6 @@ #include "search/search_integration_tests/helpers.hpp" #include "search/editor_delegate.hpp" -#include "search/processor_factory.hpp" #include "search/search_tests_support/test_search_request.hpp" #include "indexer/classificator_loader.hpp" @@ -28,8 +27,7 @@ TestWithClassificator::TestWithClassificator() SearchTest::SearchTest() : m_platform(GetPlatform()) , m_scopedLog(LDEBUG) - , m_engine(make_unique(), make_unique(), - Engine::Params()) + , m_engine(make_unique(), Engine::Params()) { indexer::tests_support::SetUpEditorForTesting(make_unique(m_engine)); diff --git a/search/search_quality/features_collector_tool/features_collector_tool.cpp b/search/search_quality/features_collector_tool/features_collector_tool.cpp index 09b8d3b20c..5c7a82072d 100644 --- a/search/search_quality/features_collector_tool/features_collector_tool.cpp +++ b/search/search_quality/features_collector_tool/features_collector_tool.cpp @@ -151,7 +151,7 @@ int main(int argc, char * argv[]) } classificator::Load(); - TestSearchEngine engine(move(infoGetter), make_unique(), Engine::Params{}); + TestSearchEngine engine(move(infoGetter), Engine::Params{}); vector mwms; platform::FindAllLocalMapsAndCleanup(numeric_limits::max() /* the latest version */, diff --git a/search/search_quality/search_quality_tool/search_quality_tool.cpp b/search/search_quality/search_quality_tool/search_quality_tool.cpp index ba7f16d22f..8d4dd71faa 100644 --- a/search/search_quality/search_quality_tool/search_quality_tool.cpp +++ b/search/search_quality/search_quality_tool/search_quality_tool.cpp @@ -8,7 +8,6 @@ #include "geometry/mercator.hpp" #include "geometry/point2d.hpp" -#include "search/processor_factory.hpp" #include "search/ranking_info.hpp" #include "search/result.hpp" #include "search/search_quality/helpers.hpp" @@ -378,7 +377,7 @@ int main(int argc, char * argv[]) Engine::Params params; params.m_locale = FLAGS_locale; params.m_numThreads = FLAGS_num_threads; - TestSearchEngine engine(move(infoGetter), make_unique(), params); + TestSearchEngine engine(move(infoGetter), params); vector mwms; if (!FLAGS_mwm_list_path.empty()) diff --git a/search/search_tests_support/test_search_engine.cpp b/search/search_tests_support/test_search_engine.cpp index ac87596aff..6eaec449aa 100644 --- a/search/search_tests_support/test_search_engine.cpp +++ b/search/search_tests_support/test_search_engine.cpp @@ -2,6 +2,8 @@ #include "indexer/categories_holder.hpp" +#include "storage/country_info_getter.hpp" + #include "platform/platform.hpp" namespace search @@ -9,19 +11,17 @@ namespace search namespace tests_support { TestSearchEngine::TestSearchEngine(unique_ptr infoGetter, - unique_ptr<::search::ProcessorFactory> factory, Engine::Params const & params) : m_platform(GetPlatform()) , m_infoGetter(move(infoGetter)) - , m_engine(*this, GetDefaultCategories(), *m_infoGetter, move(factory), params) + , m_engine(*this, GetDefaultCategories(), *m_infoGetter, params) { } -TestSearchEngine::TestSearchEngine(unique_ptr<::search::ProcessorFactory> factory, - Engine::Params const & params) +TestSearchEngine::TestSearchEngine(Engine::Params const & params) : m_platform(GetPlatform()) , m_infoGetter(storage::CountryInfoReader::CreateCountryInfoReader(m_platform)) - , m_engine(*this, GetDefaultCategories(), *m_infoGetter, move(factory), params) + , m_engine(*this, GetDefaultCategories(), *m_infoGetter, params) { } diff --git a/search/search_tests_support/test_search_engine.hpp b/search/search_tests_support/test_search_engine.hpp index 15515bb44d..585e758cfe 100644 --- a/search/search_tests_support/test_search_engine.hpp +++ b/search/search_tests_support/test_search_engine.hpp @@ -25,8 +25,8 @@ class TestSearchEngine : public Index { public: TestSearchEngine(unique_ptr infoGetter, - unique_ptr factory, Engine::Params const & params); - TestSearchEngine(unique_ptr<::search::ProcessorFactory> factory, Engine::Params const & params); + Engine::Params const & params); + TestSearchEngine(Engine::Params const & params); ~TestSearchEngine() override; void SetLocale(string const & locale) { m_engine.SetLocale(locale); }