[search] Removed processor factory + fixed pybindings build.

This commit is contained in:
Yuri Gorshenin 2017-11-01 15:42:24 +03:00 committed by mpimenov
parent 9620b613fe
commit 64a4f147bd
14 changed files with 24 additions and 62 deletions

View file

@ -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"

View file

@ -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"

View file

@ -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<Index &>(m_model.GetIndex()),
GetDefaultCategories(), *m_infoGetter,
make_unique<search::ProcessorFactory>(), params));
m_searchEngine = make_unique<search::Engine>(const_cast<Index &>(m_model.GetIndex()),
GetDefaultCategories(), *m_infoGetter, params);
}
catch (RootException const & e)
{

View file

@ -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

View file

@ -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<ProcessorFactory> 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<Processor>(index, categories, m_suggests, infoGetter);
processor->SetPreferredLocale(params.m_locale);
m_contexts[i].m_processor = move(processor);
}

View file

@ -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<ProcessorFactory> factory,
Params const & params);
storage::CountryInfoGetter const & infoGetter, Params const & params);
~Engine();
// Posts search request to the queue and returns its handle.

View file

@ -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<Processor> Build(Index & index, CategoriesHolder const & categories,
vector<Suggest> const & suggests,
storage::CountryInfoGetter const & infoGetter)
{
return make_unique<Processor>(index, categories, suggests, infoGetter);
}
};
} // namespace search

View file

@ -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<search::tests_support::TestSearchEngine>(
move(infoGetter), my::make_unique<search::ProcessorFactory>(), search::Engine::Params{});
m_engine = make_shared<search::tests_support::TestSearchEngine>(move(infoGetter),
search::Engine::Params{});
vector<platform::LocalCountryFile> mwms;
platform::FindAllLocalMapsAndCleanup(numeric_limits<int64_t>::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;

View file

@ -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 \

View file

@ -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<storage::CountryInfoGetterForTesting>(), make_unique<ProcessorFactory>(),
Engine::Params())
, m_engine(make_unique<storage::CountryInfoGetterForTesting>(), Engine::Params())
{
indexer::tests_support::SetUpEditorForTesting(make_unique<EditorDelegate>(m_engine));

View file

@ -151,7 +151,7 @@ int main(int argc, char * argv[])
}
classificator::Load();
TestSearchEngine engine(move(infoGetter), make_unique<ProcessorFactory>(), Engine::Params{});
TestSearchEngine engine(move(infoGetter), Engine::Params{});
vector<platform::LocalCountryFile> mwms;
platform::FindAllLocalMapsAndCleanup(numeric_limits<int64_t>::max() /* the latest version */,

View file

@ -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<ProcessorFactory>(), params);
TestSearchEngine engine(move(infoGetter), params);
vector<platform::LocalCountryFile> mwms;
if (!FLAGS_mwm_list_path.empty())

View file

@ -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<storage::CountryInfoGetter> 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)
{
}

View file

@ -25,8 +25,8 @@ class TestSearchEngine : public Index
{
public:
TestSearchEngine(unique_ptr<storage::CountryInfoGetter> infoGetter,
unique_ptr<search::ProcessorFactory> 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); }