forked from organicmaps/organicmaps
[search] Renamed Query to Processor.
This commit is contained in:
parent
8c86074330
commit
618b8f8c5c
32 changed files with 489 additions and 489 deletions
|
@ -13,10 +13,10 @@
|
|||
|
||||
#include "search/geometry_utils.hpp"
|
||||
#include "search/intermediate_result.hpp"
|
||||
#include "search/processor_factory.hpp"
|
||||
#include "search/result.hpp"
|
||||
#include "search/reverse_geocoder.hpp"
|
||||
#include "search/search_engine.hpp"
|
||||
#include "search/search_query_factory.hpp"
|
||||
|
||||
#include "storage/storage_helpers.hpp"
|
||||
|
||||
|
@ -134,7 +134,7 @@ void ParseSetGpsTrackMinAccuracyCommand(string const & query)
|
|||
}
|
||||
|
||||
// Cancels search query by |handle|.
|
||||
void CancelQuery(weak_ptr<search::QueryHandle> & handle)
|
||||
void CancelQuery(weak_ptr<search::ProcessorHandle> & handle)
|
||||
{
|
||||
auto queryHandle = handle.lock();
|
||||
if (queryHandle)
|
||||
|
@ -518,7 +518,7 @@ bool Framework::OnCountryFileDelete(storage::TCountryId const & countryId, stora
|
|||
if (countryId == m_lastReportedCountry)
|
||||
m_lastReportedCountry = kInvalidCountryId;
|
||||
|
||||
if(auto handle = m_lastQueryHandle.lock())
|
||||
if (auto handle = m_lastProcessorHandle.lock())
|
||||
handle->Cancel();
|
||||
|
||||
m2::RectD rect = MercatorBounds::FullRect();
|
||||
|
@ -1117,8 +1117,8 @@ bool Framework::Search(search::SearchParams const & params)
|
|||
m_lastQueryViewport = viewport;
|
||||
|
||||
// Cancels previous search request (if any) and initiates new search request.
|
||||
CancelQuery(m_lastQueryHandle);
|
||||
m_lastQueryHandle = m_searchEngine->Search(m_lastQueryParams, m_lastQueryViewport);
|
||||
CancelQuery(m_lastProcessorHandle);
|
||||
m_lastProcessorHandle = m_searchEngine->Search(m_lastQueryParams, m_lastQueryViewport);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1256,7 +1256,7 @@ void Framework::InitSearchEngine()
|
|||
params.m_numThreads = 1;
|
||||
m_searchEngine.reset(new search::Engine(const_cast<Index &>(m_model.GetIndex()),
|
||||
GetDefaultCategories(), *m_infoGetter,
|
||||
make_unique<search::SearchQueryFactory>(), params));
|
||||
make_unique<search::SearchProcessorFactory>(), params));
|
||||
}
|
||||
catch (RootException const & e)
|
||||
{
|
||||
|
@ -1445,7 +1445,7 @@ void Framework::CancelInteractiveSearch()
|
|||
if (IsInteractiveSearchActive())
|
||||
{
|
||||
m_lastInteractiveSearchParams.Clear();
|
||||
CancelQuery(m_lastQueryHandle);
|
||||
CancelQuery(m_lastProcessorHandle);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -398,8 +398,8 @@ private:
|
|||
search::SearchParams m_lastQueryParams;
|
||||
m2::RectD m_lastQueryViewport;
|
||||
|
||||
// A handle for the latest search query.
|
||||
weak_ptr<search::QueryHandle> m_lastQueryHandle;
|
||||
// A handle for the latest search processor.
|
||||
weak_ptr<search::ProcessorHandle> m_lastProcessorHandle;
|
||||
|
||||
// Returns true when |params| and |viewport| are almost the same as
|
||||
// the latest search query's params and viewport.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
#include "search/processor.hpp"
|
||||
#include "search/query_params.hpp"
|
||||
#include "search/search_common.hpp"
|
||||
#include "search/search_index_values.hpp"
|
||||
#include "search/search_query.hpp"
|
||||
#include "search/search_query_params.hpp"
|
||||
#include "search/v2/token_slice.hpp"
|
||||
|
||||
#include "indexer/trie.hpp"
|
||||
|
@ -305,7 +305,7 @@ private:
|
|||
// Calls toDo for each feature corresponding to at least one synonym.
|
||||
// *NOTE* toDo may be called several times for the same feature.
|
||||
template <typename TValue, typename ToDo>
|
||||
void MatchTokenInTrie(SearchQueryParams::TSynonymsVector const & syns,
|
||||
void MatchTokenInTrie(QueryParams::TSynonymsVector const & syns,
|
||||
TrieRootPrefix<TValue> const & trieRoot, ToDo && toDo)
|
||||
{
|
||||
for (auto const & syn : syns)
|
||||
|
@ -319,7 +319,7 @@ void MatchTokenInTrie(SearchQueryParams::TSynonymsVector const & syns,
|
|||
// synonym as a prefix.
|
||||
// *NOTE* toDo may be called serveral times for the same feature.
|
||||
template <typename TValue, typename ToDo>
|
||||
void MatchTokenPrefixInTrie(SearchQueryParams::TSynonymsVector const & syns,
|
||||
void MatchTokenPrefixInTrie(QueryParams::TSynonymsVector const & syns,
|
||||
TrieRootPrefix<TValue> const & trieRoot, ToDo && toDo)
|
||||
{
|
||||
for (auto const & syn : syns)
|
||||
|
@ -332,7 +332,7 @@ void MatchTokenPrefixInTrie(SearchQueryParams::TSynonymsVector const & syns,
|
|||
// Fills holder with features whose names correspond to tokens list up to synonyms.
|
||||
// *NOTE* the same feature may be put in the same holder's slot several times.
|
||||
template <typename TValue, typename THolder>
|
||||
void MatchTokensInTrie(vector<SearchQueryParams::TSynonymsVector> const & tokens,
|
||||
void MatchTokensInTrie(vector<QueryParams::TSynonymsVector> const & tokens,
|
||||
TrieRootPrefix<TValue> const & trieRoot, THolder && holder)
|
||||
{
|
||||
holder.Resize(tokens.size());
|
||||
|
@ -347,8 +347,8 @@ void MatchTokensInTrie(vector<SearchQueryParams::TSynonymsVector> const & tokens
|
|||
// also, last holder's slot will be filled with features corresponding to prefixTokens.
|
||||
// *NOTE* the same feature may be put in the same holder's slot several times.
|
||||
template <typename TValue, typename THolder>
|
||||
void MatchTokensAndPrefixInTrie(vector<SearchQueryParams::TSynonymsVector> const & tokens,
|
||||
SearchQueryParams::TSynonymsVector const & prefixTokens,
|
||||
void MatchTokensAndPrefixInTrie(vector<QueryParams::TSynonymsVector> const & tokens,
|
||||
QueryParams::TSynonymsVector const & prefixTokens,
|
||||
TrieRootPrefix<TValue> const & trieRoot, THolder && holder)
|
||||
{
|
||||
MatchTokensInTrie(tokens, trieRoot, holder);
|
||||
|
@ -362,7 +362,7 @@ void MatchTokensAndPrefixInTrie(vector<SearchQueryParams::TSynonymsVector> const
|
|||
// token from a search query.
|
||||
// *NOTE* query prefix will be treated as a complete token in the function.
|
||||
template <typename TValue, typename THolder>
|
||||
bool MatchCategoriesInTrie(SearchQueryParams const & params,
|
||||
bool MatchCategoriesInTrie(QueryParams const & params,
|
||||
trie::Iterator<ValueList<TValue>> const & trieRoot, THolder && holder)
|
||||
{
|
||||
uint32_t langIx = 0;
|
||||
|
@ -387,7 +387,7 @@ bool MatchCategoriesInTrie(SearchQueryParams const & params,
|
|||
// Calls toDo with trie root prefix and language code on each language
|
||||
// allowed by params.
|
||||
template <typename TValue, typename ToDo>
|
||||
void ForEachLangPrefix(SearchQueryParams const & params,
|
||||
void ForEachLangPrefix(QueryParams const & params,
|
||||
trie::Iterator<ValueList<TValue>> const & trieRoot, ToDo && toDo)
|
||||
{
|
||||
ASSERT_LESS(trieRoot.m_edge.size(), numeric_limits<uint32_t>::max(), ());
|
||||
|
@ -409,7 +409,7 @@ void ForEachLangPrefix(SearchQueryParams const & params,
|
|||
// Calls toDo for each feature whose description contains *ALL* tokens from a search query.
|
||||
// Each feature will be passed to toDo only once.
|
||||
template <typename TValue, typename TFilter, typename ToDo>
|
||||
void MatchFeaturesInTrie(SearchQueryParams const & params,
|
||||
void MatchFeaturesInTrie(QueryParams const & params,
|
||||
trie::Iterator<ValueList<TValue>> const & trieRoot, TFilter const & filter,
|
||||
ToDo && toDo)
|
||||
{
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#include "search_query.hpp"
|
||||
#include "processor.hpp"
|
||||
|
||||
#include "search/dummy_rank_table.hpp"
|
||||
#include "search/geometry_utils.hpp"
|
||||
#include "search/intermediate_result.hpp"
|
||||
#include "search/latlon_match.hpp"
|
||||
#include "search/locality.hpp"
|
||||
#include "search/query_params.hpp"
|
||||
#include "search/region.hpp"
|
||||
#include "search/search_common.hpp"
|
||||
#include "search/search_index_values.hpp"
|
||||
#include "search/search_query_params.hpp"
|
||||
#include "search/search_string_intersection.hpp"
|
||||
#include "search/v2/pre_ranking_info.hpp"
|
||||
#include "search/v2/ranking_info.hpp"
|
||||
|
@ -60,7 +60,6 @@
|
|||
|
||||
namespace search
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
/// This indexes should match the initialization routine below.
|
||||
|
@ -91,17 +90,17 @@ ftypes::Type GetLocalityIndex(feature::TypesHolder const & types)
|
|||
Type const type = IsLocalityChecker::Instance().GetType(types);
|
||||
switch (type)
|
||||
{
|
||||
case NONE:
|
||||
case COUNTRY:
|
||||
case STATE:
|
||||
case CITY:
|
||||
return type;
|
||||
case TOWN:
|
||||
return CITY;
|
||||
case VILLAGE:
|
||||
return NONE;
|
||||
case LOCALITY_COUNT:
|
||||
return type;
|
||||
case NONE:
|
||||
case COUNTRY:
|
||||
case STATE:
|
||||
case CITY:
|
||||
return type;
|
||||
case TOWN:
|
||||
return CITY;
|
||||
case VILLAGE:
|
||||
return NONE;
|
||||
case LOCALITY_COUNT:
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,11 +147,10 @@ void RemoveDuplicatingLinear(vector<IndexedValue> & indV)
|
|||
impl::PreResult2::LessLinearTypesF lessCmp;
|
||||
impl::PreResult2::EqualLinearTypesF equalCmp;
|
||||
|
||||
sort(indV.begin(), indV.end(),
|
||||
[&lessCmp](IndexedValue const & lhs, IndexedValue const & rhs)
|
||||
{
|
||||
return lessCmp(*lhs, *rhs);
|
||||
});
|
||||
sort(indV.begin(), indV.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)
|
||||
|
@ -164,12 +162,12 @@ void RemoveDuplicatingLinear(vector<IndexedValue> & indV)
|
|||
|
||||
m2::RectD NormalizeViewport(m2::RectD viewport)
|
||||
{
|
||||
m2::RectD minViewport =
|
||||
MercatorBounds::RectByCenterXYAndSizeInMeters(viewport.Center(), Query::kMinViewportRadiusM);
|
||||
m2::RectD minViewport = MercatorBounds::RectByCenterXYAndSizeInMeters(
|
||||
viewport.Center(), Processor::kMinViewportRadiusM);
|
||||
viewport.Add(minViewport);
|
||||
|
||||
m2::RectD maxViewport =
|
||||
MercatorBounds::RectByCenterXYAndSizeInMeters(viewport.Center(), Query::kMaxViewportRadiusM);
|
||||
m2::RectD maxViewport = MercatorBounds::RectByCenterXYAndSizeInMeters(
|
||||
viewport.Center(), Processor::kMaxViewportRadiusM);
|
||||
VERIFY(viewport.Intersect(maxViewport), ());
|
||||
return viewport;
|
||||
}
|
||||
|
@ -208,14 +206,15 @@ inline strings::UniString RemoveHashtag(strings::UniString const & s)
|
|||
} // namespace
|
||||
|
||||
// static
|
||||
size_t const Query::kPreResultsCount;
|
||||
size_t const Processor::kPreResultsCount;
|
||||
|
||||
// static
|
||||
double const Query::kMinViewportRadiusM = 5.0 * 1000;
|
||||
double const Query::kMaxViewportRadiusM = 50.0 * 1000;
|
||||
double const Processor::kMinViewportRadiusM = 5.0 * 1000;
|
||||
double const Processor::kMaxViewportRadiusM = 50.0 * 1000;
|
||||
|
||||
Query::Query(Index & index, CategoriesHolder const & categories, vector<Suggest> const & suggests,
|
||||
storage::CountryInfoGetter const & infoGetter)
|
||||
Processor::Processor(Index & index, CategoriesHolder const & categories,
|
||||
vector<Suggest> const & suggests,
|
||||
storage::CountryInfoGetter const & infoGetter)
|
||||
: m_index(index)
|
||||
, m_categories(categories)
|
||||
, m_suggests(suggests)
|
||||
|
@ -234,29 +233,28 @@ Query::Query(Index & index, CategoriesHolder const & categories, vector<Suggest>
|
|||
{
|
||||
// Initialize keywords scorer.
|
||||
// Note! This order should match the indexes arrays above.
|
||||
vector<vector<int8_t> > langPriorities = {
|
||||
{-1}, // future current lang
|
||||
{-1}, // future input lang
|
||||
{StringUtf8Multilang::kInternationalCode, StringUtf8Multilang::kEnglishCode},
|
||||
{StringUtf8Multilang::kDefaultCode}
|
||||
};
|
||||
vector<vector<int8_t>> langPriorities = {
|
||||
{-1}, // future current lang
|
||||
{-1}, // future input lang
|
||||
{StringUtf8Multilang::kInternationalCode, StringUtf8Multilang::kEnglishCode},
|
||||
{StringUtf8Multilang::kDefaultCode}};
|
||||
|
||||
m_keywordsScorer.SetLanguages(langPriorities);
|
||||
|
||||
SetPreferredLocale("en");
|
||||
}
|
||||
|
||||
void Query::SetLanguage(int id, int8_t lang)
|
||||
void Processor::SetLanguage(int id, int8_t lang)
|
||||
{
|
||||
m_keywordsScorer.SetLanguage(GetLangIndex(id), lang);
|
||||
}
|
||||
|
||||
int8_t Query::GetLanguage(int id) const
|
||||
int8_t Processor::GetLanguage(int id) const
|
||||
{
|
||||
return m_keywordsScorer.GetLanguage(GetLangIndex(id));
|
||||
}
|
||||
|
||||
m2::PointD Query::GetPivotPoint() const
|
||||
m2::PointD Processor::GetPivotPoint() const
|
||||
{
|
||||
m2::RectD const & viewport = m_viewport[CURRENT_V];
|
||||
if (viewport.IsPointInside(GetPosition()))
|
||||
|
@ -264,7 +262,7 @@ m2::PointD Query::GetPivotPoint() const
|
|||
return viewport.Center();
|
||||
}
|
||||
|
||||
m2::RectD Query::GetPivotRect() const
|
||||
m2::RectD Processor::GetPivotRect() const
|
||||
{
|
||||
m2::RectD const & viewport = m_viewport[CURRENT_V];
|
||||
if (viewport.IsPointInside(GetPosition()))
|
||||
|
@ -272,7 +270,7 @@ m2::RectD Query::GetPivotRect() const
|
|||
return NormalizeViewport(viewport);
|
||||
}
|
||||
|
||||
void Query::SetViewport(m2::RectD const & viewport, bool forceUpdate)
|
||||
void Processor::SetViewport(m2::RectD const & viewport, bool forceUpdate)
|
||||
{
|
||||
Reset();
|
||||
|
||||
|
@ -282,8 +280,8 @@ void Query::SetViewport(m2::RectD const & viewport, bool forceUpdate)
|
|||
SetViewportByIndex(mwmsInfo, viewport, CURRENT_V, forceUpdate);
|
||||
}
|
||||
|
||||
void Query::SetViewportByIndex(TMWMVector const & mwmsInfo, m2::RectD const & viewport, size_t idx,
|
||||
bool forceUpdate)
|
||||
void Processor::SetViewportByIndex(TMWMVector const & mwmsInfo, m2::RectD const & viewport,
|
||||
size_t idx, bool forceUpdate)
|
||||
{
|
||||
ASSERT(idx < COUNT_V, (idx));
|
||||
|
||||
|
@ -323,7 +321,7 @@ void Query::SetViewportByIndex(TMWMVector const & mwmsInfo, m2::RectD const & vi
|
|||
}
|
||||
}
|
||||
|
||||
void Query::SetRankPivot(m2::PointD const & pivot)
|
||||
void Processor::SetRankPivot(m2::PointD const & pivot)
|
||||
{
|
||||
if (!m2::AlmostEqualULPs(pivot, m_pivot))
|
||||
{
|
||||
|
@ -335,7 +333,7 @@ void Query::SetRankPivot(m2::PointD const & pivot)
|
|||
m_pivot = pivot;
|
||||
}
|
||||
|
||||
void Query::SetPreferredLocale(string const & locale)
|
||||
void Processor::SetPreferredLocale(string const & locale)
|
||||
{
|
||||
ASSERT(!locale.empty(), ());
|
||||
|
||||
|
@ -355,7 +353,7 @@ void Query::SetPreferredLocale(string const & locale)
|
|||
#endif
|
||||
}
|
||||
|
||||
void Query::SetInputLocale(string const & locale)
|
||||
void Processor::SetInputLocale(string const & locale)
|
||||
{
|
||||
if (!locale.empty())
|
||||
{
|
||||
|
@ -367,7 +365,7 @@ void Query::SetInputLocale(string const & locale)
|
|||
}
|
||||
}
|
||||
|
||||
void Query::ClearCaches()
|
||||
void Processor::ClearCaches()
|
||||
{
|
||||
for (size_t i = 0; i < COUNT_V; ++i)
|
||||
ClearCache(i);
|
||||
|
@ -375,12 +373,9 @@ void Query::ClearCaches()
|
|||
m_locality.ClearCache();
|
||||
}
|
||||
|
||||
void Query::ClearCache(size_t ind)
|
||||
{
|
||||
m_viewport[ind].MakeEmpty();
|
||||
}
|
||||
void Processor::ClearCache(size_t ind) { m_viewport[ind].MakeEmpty(); }
|
||||
|
||||
void Query::Init(bool viewportSearch)
|
||||
void Processor::Init(bool viewportSearch)
|
||||
{
|
||||
Reset();
|
||||
|
||||
|
@ -390,7 +385,7 @@ void Query::Init(bool viewportSearch)
|
|||
m_viewportSearch = viewportSearch;
|
||||
}
|
||||
|
||||
int Query::GetCategoryLocales(int8_t (&arr) [3]) const
|
||||
int Processor::GetCategoryLocales(int8_t(&arr)[3]) const
|
||||
{
|
||||
static int8_t const enLocaleCode = CategoriesHolder::MapLocaleToInteger("en");
|
||||
|
||||
|
@ -407,7 +402,7 @@ int Query::GetCategoryLocales(int8_t (&arr) [3]) const
|
|||
}
|
||||
|
||||
template <class ToDo>
|
||||
void Query::ForEachCategoryTypes(v2::QuerySlice const & slice, ToDo toDo) const
|
||||
void Processor::ForEachCategoryTypes(v2::QuerySlice const & slice, ToDo toDo) const
|
||||
{
|
||||
int8_t arrLocales[3];
|
||||
int const localesCount = GetCategoryLocales(arrLocales);
|
||||
|
@ -422,7 +417,8 @@ void Query::ForEachCategoryTypes(v2::QuerySlice const & slice, ToDo toDo) const
|
|||
}
|
||||
|
||||
template <class ToDo>
|
||||
void Query::ProcessEmojiIfNeeded(strings::UniString const & token, size_t ind, ToDo & toDo) const
|
||||
void Processor::ProcessEmojiIfNeeded(strings::UniString const & token, size_t ind,
|
||||
ToDo & toDo) const
|
||||
{
|
||||
// Special process of 2 codepoints emoji (e.g. black guy on a bike).
|
||||
// Only emoji synonyms can have one codepoint.
|
||||
|
@ -435,7 +431,7 @@ void Query::ProcessEmojiIfNeeded(strings::UniString const & token, size_t ind, T
|
|||
}
|
||||
}
|
||||
|
||||
void Query::SetQuery(string const & query)
|
||||
void Processor::SetQuery(string const & query)
|
||||
{
|
||||
m_query = query;
|
||||
|
||||
|
@ -503,8 +499,8 @@ void Query::SetQuery(string const & query)
|
|||
});
|
||||
}
|
||||
|
||||
void Query::FlushViewportResults(v2::Geocoder::Params const & params, Results & res,
|
||||
bool oldHouseSearch)
|
||||
void Processor::FlushViewportResults(v2::Geocoder::Params const & params, Results & res,
|
||||
bool oldHouseSearch)
|
||||
{
|
||||
vector<IndexedValue> indV;
|
||||
vector<FeatureID> streets;
|
||||
|
@ -521,13 +517,15 @@ void Query::FlushViewportResults(v2::Geocoder::Params const & params, Results &
|
|||
if (IsCancelled())
|
||||
break;
|
||||
|
||||
res.AddResultNoChecks((*(indV[i])).GenerateFinalResult(m_infoGetter, &m_categories,
|
||||
&m_prefferedTypes, m_currentLocaleCode,
|
||||
nullptr /* Viewport results don't need calculated address */));
|
||||
res.AddResultNoChecks(
|
||||
(*(indV[i]))
|
||||
.GenerateFinalResult(m_infoGetter, &m_categories, &m_prefferedTypes,
|
||||
m_currentLocaleCode,
|
||||
nullptr /* Viewport results don't need calculated address */));
|
||||
}
|
||||
}
|
||||
|
||||
void Query::SearchCoordinates(Results & res) const
|
||||
void Processor::SearchCoordinates(Results & res) const
|
||||
{
|
||||
double lat, lon;
|
||||
if (MatchLatLonDegree(m_query, lat, lon))
|
||||
|
@ -554,7 +552,7 @@ namespace impl
|
|||
{
|
||||
class PreResult2Maker
|
||||
{
|
||||
Query & m_query;
|
||||
Processor & m_processor;
|
||||
v2::Geocoder::Params const & m_params;
|
||||
|
||||
unique_ptr<Index::FeaturesLoaderGuard> m_pFV;
|
||||
|
@ -564,14 +562,14 @@ class PreResult2Maker
|
|||
string & country)
|
||||
{
|
||||
if (m_pFV.get() == 0 || m_pFV->GetId() != id.m_mwmId)
|
||||
m_pFV.reset(new Index::FeaturesLoaderGuard(m_query.m_index, id.m_mwmId));
|
||||
m_pFV.reset(new Index::FeaturesLoaderGuard(m_processor.m_index, id.m_mwmId));
|
||||
|
||||
m_pFV->GetFeatureByIndex(id.m_index, f);
|
||||
f.SetID(id);
|
||||
|
||||
center = feature::GetCenter(f);
|
||||
|
||||
m_query.GetBestMatchName(f, name);
|
||||
m_processor.GetBestMatchName(f, name);
|
||||
|
||||
// country (region) name is a file name if feature isn't from World.mwm
|
||||
if (m_pFV->IsWorld())
|
||||
|
@ -613,12 +611,12 @@ class PreResult2Maker
|
|||
|
||||
feature::TypesHolder holder(ft);
|
||||
vector<pair<size_t, size_t>> matched(slice.Size());
|
||||
m_query.ForEachCategoryTypes(v2::QuerySliceOnTokens(slice), [&](size_t i, uint32_t t)
|
||||
{
|
||||
++matched[i].second;
|
||||
if (holder.Has(t))
|
||||
++matched[i].first;
|
||||
});
|
||||
m_processor.ForEachCategoryTypes(v2::QuerySliceOnTokens(slice), [&](size_t i, uint32_t t)
|
||||
{
|
||||
++matched[i].second;
|
||||
if (holder.Has(t))
|
||||
++matched[i].first;
|
||||
});
|
||||
|
||||
info.m_pureCats = all_of(matched.begin(), matched.end(), [](pair<size_t, size_t> const & m)
|
||||
{
|
||||
|
@ -638,18 +636,19 @@ class PreResult2Maker
|
|||
case v2::SearchModel::SEARCH_TYPE_VILLAGE: return rank /= 1.5;
|
||||
case v2::SearchModel::SEARCH_TYPE_CITY:
|
||||
{
|
||||
if (m_query.GetViewport(Query::CURRENT_V).IsPointInside(center))
|
||||
if (m_processor.GetViewport(Processor::CURRENT_V).IsPointInside(center))
|
||||
return rank * 2;
|
||||
|
||||
storage::CountryInfo info;
|
||||
if (country.empty())
|
||||
m_query.m_infoGetter.GetRegionInfo(center, info);
|
||||
m_processor.m_infoGetter.GetRegionInfo(center, info);
|
||||
else
|
||||
m_query.m_infoGetter.GetRegionInfo(country, info);
|
||||
if (info.IsNotEmpty() && info.m_name == m_query.GetPivotRegion())
|
||||
m_processor.m_infoGetter.GetRegionInfo(country, info);
|
||||
if (info.IsNotEmpty() && info.m_name == m_processor.GetPivotRegion())
|
||||
return rank *= 1.7;
|
||||
}
|
||||
case v2::SearchModel::SEARCH_TYPE_COUNTRY: return rank /= 1.5;
|
||||
case v2::SearchModel::SEARCH_TYPE_COUNTRY:
|
||||
return rank /= 1.5;
|
||||
|
||||
// For all other search types, rank should be zero for now.
|
||||
default: return 0;
|
||||
|
@ -657,8 +656,8 @@ class PreResult2Maker
|
|||
}
|
||||
|
||||
public:
|
||||
explicit PreResult2Maker(Query & q, v2::Geocoder::Params const & params)
|
||||
: m_query(q), m_params(params)
|
||||
explicit PreResult2Maker(Processor & q, v2::Geocoder::Params const & params)
|
||||
: m_processor(q), m_params(params)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -671,8 +670,8 @@ public:
|
|||
|
||||
LoadFeature(res1.GetId(), ft, center, name, country);
|
||||
|
||||
auto res2 = make_unique<impl::PreResult2>(ft, &res1, center, m_query.GetPosition() /* pivot */,
|
||||
name, country);
|
||||
auto res2 = make_unique<impl::PreResult2>(ft, &res1, center,
|
||||
m_processor.GetPosition() /* pivot */, name, country);
|
||||
|
||||
search::v2::RankingInfo info;
|
||||
InitRankingInfo(ft, center, res1, info);
|
||||
|
@ -685,32 +684,33 @@ public:
|
|||
} // namespace impl
|
||||
|
||||
template <class T>
|
||||
void Query::MakePreResult2(v2::Geocoder::Params const & params, vector<T> & cont,
|
||||
vector<FeatureID> & streets)
|
||||
void Processor::MakePreResult2(v2::Geocoder::Params const & params, vector<T> & cont,
|
||||
vector<FeatureID> & streets)
|
||||
{
|
||||
m_preRanker.Filter(m_viewportSearch);
|
||||
|
||||
// Makes PreResult2 vector.
|
||||
impl::PreResult2Maker maker(*this, params);
|
||||
m_preRanker.ForEach([&](impl::PreResult1 const & r)
|
||||
{
|
||||
auto p = maker(r);
|
||||
if (!p)
|
||||
return;
|
||||
m_preRanker.ForEach(
|
||||
[&](impl::PreResult1 const & r)
|
||||
{
|
||||
auto p = maker(r);
|
||||
if (!p)
|
||||
return;
|
||||
|
||||
if (params.m_mode == Mode::Viewport && !params.m_pivot.IsPointInside(p->GetCenter()))
|
||||
return;
|
||||
if (params.m_mode == Mode::Viewport && !params.m_pivot.IsPointInside(p->GetCenter()))
|
||||
return;
|
||||
|
||||
if (p->IsStreet())
|
||||
streets.push_back(p->GetID());
|
||||
if (p->IsStreet())
|
||||
streets.push_back(p->GetID());
|
||||
|
||||
if (!IsResultExists(*p, cont))
|
||||
cont.push_back(IndexedValue(move(p)));
|
||||
});
|
||||
if (!IsResultExists(*p, cont))
|
||||
cont.push_back(IndexedValue(move(p)));
|
||||
});
|
||||
}
|
||||
|
||||
void Query::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, bool allMWMs,
|
||||
size_t resCount, bool oldHouseSearch)
|
||||
{
|
||||
vector<IndexedValue> indV;
|
||||
vector<FeatureID> streets;
|
||||
|
@ -741,12 +741,12 @@ void Query::FlushResults(v2::Geocoder::Params const & params, Results & res, boo
|
|||
}
|
||||
}
|
||||
|
||||
int Query::GetQueryIndexScale(m2::RectD const & viewport) const
|
||||
int Processor::GetQueryIndexScale(m2::RectD const & viewport) const
|
||||
{
|
||||
return search::GetQueryIndexScale(viewport);
|
||||
}
|
||||
|
||||
void Query::RemoveStringPrefix(string const & str, string & res) const
|
||||
void Processor::RemoveStringPrefix(string const & str, string & res) const
|
||||
{
|
||||
search::Delimiters delims;
|
||||
// Find start iterator of prefix in input query.
|
||||
|
@ -767,7 +767,7 @@ void Query::RemoveStringPrefix(string const & str, string & res) const
|
|||
res.assign(str.begin(), iter.base());
|
||||
}
|
||||
|
||||
void Query::GetSuggestion(string const & name, string & suggest) const
|
||||
void Processor::GetSuggestion(string const & name, string & suggest) const
|
||||
{
|
||||
// Splits result's name.
|
||||
search::Delimiters delims;
|
||||
|
@ -813,7 +813,7 @@ void Query::GetSuggestion(string const & name, string & suggest) const
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void Query::ProcessSuggestions(vector<T> & vec, Results & res) const
|
||||
void Processor::ProcessSuggestions(vector<T> & vec, Results & res) const
|
||||
{
|
||||
if (m_prefix.empty() || !m_suggestsEnabled)
|
||||
return;
|
||||
|
@ -824,7 +824,7 @@ void Query::ProcessSuggestions(vector<T> & vec, Results & res) const
|
|||
impl::PreResult2 const & r = **i;
|
||||
|
||||
ftypes::Type const type = GetLocalityIndex(r.GetTypes());
|
||||
if ((type == ftypes::COUNTRY || type == ftypes::CITY) || r.IsStreet())
|
||||
if ((type == ftypes::COUNTRY || type == ftypes::CITY) || r.IsStreet())
|
||||
{
|
||||
string suggest;
|
||||
GetSuggestion(r.GetName(), suggest);
|
||||
|
@ -848,6 +848,7 @@ class BestNameFinder
|
|||
KeywordLangMatcher::ScoreT m_score;
|
||||
string & m_name;
|
||||
KeywordLangMatcher const & m_keywordsScorer;
|
||||
|
||||
public:
|
||||
BestNameFinder(string & name, KeywordLangMatcher const & keywordsScorer)
|
||||
: m_score(), m_name(name), m_keywordsScorer(keywordsScorer)
|
||||
|
@ -867,7 +868,7 @@ public:
|
|||
};
|
||||
} // namespace impl
|
||||
|
||||
void Query::GetBestMatchName(FeatureType const & f, string & name) const
|
||||
void Processor::GetBestMatchName(FeatureType const & f, string & name) const
|
||||
{
|
||||
impl::BestNameFinder finder(name, m_keywordsScorer);
|
||||
UNUSED_VALUE(f.ForEachName(finder));
|
||||
|
@ -885,7 +886,7 @@ public:
|
|||
|
||||
ValueT const & operator*() const
|
||||
{
|
||||
ASSERT( m_val != 0 || m_i != m_end, ("dereferencing of empty iterator") );
|
||||
ASSERT(m_val != 0 || m_i != m_end, ("dereferencing of empty iterator"));
|
||||
if (m_i != m_end)
|
||||
return *m_i;
|
||||
|
||||
|
@ -912,24 +913,17 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
class AssignHighlightRange
|
||||
{
|
||||
Result & m_res;
|
||||
public:
|
||||
AssignHighlightRange(Result & res)
|
||||
: m_res(res)
|
||||
{
|
||||
}
|
||||
|
||||
void operator() (pair<uint16_t, uint16_t> const & range)
|
||||
{
|
||||
m_res.AddHighlightRange(range);
|
||||
}
|
||||
public:
|
||||
AssignHighlightRange(Result & res) : m_res(res) {}
|
||||
|
||||
void operator()(pair<uint16_t, uint16_t> const & range) { m_res.AddHighlightRange(range); }
|
||||
};
|
||||
|
||||
|
||||
Result Query::MakeResult(impl::PreResult2 const & r) const
|
||||
Result Processor::MakeResult(impl::PreResult2 const & r) const
|
||||
{
|
||||
Result res = r.GenerateFinalResult(m_infoGetter, &m_categories, &m_prefferedTypes,
|
||||
m_currentLocaleCode, &m_reverseGeocoder);
|
||||
|
@ -948,7 +942,7 @@ Result Query::MakeResult(impl::PreResult2 const & r) const
|
|||
return res;
|
||||
}
|
||||
|
||||
void Query::MakeResultHighlight(Result & res) const
|
||||
void Processor::MakeResultHighlight(Result & res) const
|
||||
{
|
||||
using TIter = buffer_vector<strings::UniString, 32>::const_iterator;
|
||||
using TCombinedIter = CombinedIter<TIter, strings::UniString>;
|
||||
|
@ -961,155 +955,155 @@ void Query::MakeResultHighlight(Result & res) const
|
|||
|
||||
namespace
|
||||
{
|
||||
int GetOldTypeFromIndex(size_t index)
|
||||
{
|
||||
// "building" has old type value = 70
|
||||
ASSERT_NOT_EQUAL(index, 70, ());
|
||||
int GetOldTypeFromIndex(size_t index)
|
||||
{
|
||||
// "building" has old type value = 70
|
||||
ASSERT_NOT_EQUAL(index, 70, ());
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case 156: return 4099;
|
||||
case 98: return 4163;
|
||||
case 374: return 4419;
|
||||
case 188: return 4227;
|
||||
case 100: return 6147;
|
||||
case 107: return 4547;
|
||||
case 96: return 5059;
|
||||
case 60: return 6275;
|
||||
case 66: return 5251;
|
||||
case 161: return 4120;
|
||||
case 160: return 4376;
|
||||
case 159: return 4568;
|
||||
case 16: return 4233;
|
||||
case 178: return 5654;
|
||||
case 227: return 4483;
|
||||
case 111: return 5398;
|
||||
case 256: return 5526;
|
||||
case 702: return 263446;
|
||||
case 146: return 4186;
|
||||
case 155: return 4890;
|
||||
case 141: return 4570;
|
||||
case 158: return 4762;
|
||||
case 38: return 5891;
|
||||
case 63: return 4291;
|
||||
case 270: return 4355;
|
||||
case 327: return 4675;
|
||||
case 704: return 4611;
|
||||
case 242: return 4739;
|
||||
case 223: return 4803;
|
||||
case 174: return 4931;
|
||||
case 137: return 5123;
|
||||
case 186: return 5187;
|
||||
case 250: return 5315;
|
||||
case 104: return 4299;
|
||||
case 113: return 5379;
|
||||
case 206: return 4867;
|
||||
case 184: return 5443;
|
||||
case 125: return 5507;
|
||||
case 170: return 5571;
|
||||
case 25: return 5763;
|
||||
case 118: return 5827;
|
||||
case 76: return 6019;
|
||||
case 116: return 6083;
|
||||
case 108: return 6211;
|
||||
case 35: return 6339;
|
||||
case 180: return 6403;
|
||||
case 121: return 6595;
|
||||
case 243: return 6659;
|
||||
case 150: return 6723;
|
||||
case 175: return 6851;
|
||||
case 600: return 4180;
|
||||
case 348: return 4244;
|
||||
case 179: return 4116;
|
||||
case 77: return 4884;
|
||||
case 387: return 262164;
|
||||
case 214: return 4308;
|
||||
case 289: return 4756;
|
||||
case 264: return 4692;
|
||||
case 93: return 4500;
|
||||
case 240: return 4564;
|
||||
case 127: return 4820;
|
||||
case 29: return 4436;
|
||||
case 20: return 4948;
|
||||
case 18: return 4628;
|
||||
case 293: return 4372;
|
||||
case 22: return 4571;
|
||||
case 3: return 4699;
|
||||
case 51: return 4635;
|
||||
case 89: return 4123;
|
||||
case 307: return 5705;
|
||||
case 15: return 5321;
|
||||
case 6: return 4809;
|
||||
case 58: return 6089;
|
||||
case 26: return 5513;
|
||||
case 187: return 5577;
|
||||
case 1: return 5769;
|
||||
case 12: return 5897;
|
||||
case 244: return 5961;
|
||||
case 8: return 6153;
|
||||
case 318: return 6217;
|
||||
case 2: return 6025;
|
||||
case 30: return 5833;
|
||||
case 7: return 6281;
|
||||
case 65: return 6409;
|
||||
case 221: return 6473;
|
||||
case 54: return 4937;
|
||||
case 69: return 5385;
|
||||
case 4: return 6537;
|
||||
case 200: return 5257;
|
||||
case 195: return 5129;
|
||||
case 120: return 5193;
|
||||
case 56: return 5904;
|
||||
case 5: return 6864;
|
||||
case 169: return 4171;
|
||||
case 61: return 5707;
|
||||
case 575: return 5968;
|
||||
case 563: return 5456;
|
||||
case 13: return 6992;
|
||||
case 10: return 4811;
|
||||
case 109: return 4236;
|
||||
case 67: return 4556;
|
||||
case 276: return 4442;
|
||||
case 103: return 4506;
|
||||
case 183: return 4440;
|
||||
case 632: return 4162;
|
||||
case 135: return 4098;
|
||||
case 205: return 5004;
|
||||
case 87: return 4684;
|
||||
case 164: return 4940;
|
||||
case 201: return 4300;
|
||||
case 68: return 4620;
|
||||
case 101: return 5068;
|
||||
case 0: return 70;
|
||||
case 737: return 4102;
|
||||
case 703: return 5955;
|
||||
case 705: return 6531;
|
||||
case 706: return 5635;
|
||||
case 707: return 5699;
|
||||
case 708: return 4995;
|
||||
case 715: return 4298;
|
||||
case 717: return 4362;
|
||||
case 716: return 4490;
|
||||
case 718: return 4234;
|
||||
case 719: return 4106;
|
||||
case 722: return 4240;
|
||||
case 723: return 6480;
|
||||
case 725: return 4312;
|
||||
case 726: return 4248;
|
||||
case 727: return 4184;
|
||||
case 728: return 4504;
|
||||
case 732: return 4698;
|
||||
case 733: return 4378;
|
||||
case 734: return 4634;
|
||||
case 166: return 4250;
|
||||
case 288: return 4314;
|
||||
case 274: return 4122;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
switch (index)
|
||||
{
|
||||
case 156: return 4099;
|
||||
case 98: return 4163;
|
||||
case 374: return 4419;
|
||||
case 188: return 4227;
|
||||
case 100: return 6147;
|
||||
case 107: return 4547;
|
||||
case 96: return 5059;
|
||||
case 60: return 6275;
|
||||
case 66: return 5251;
|
||||
case 161: return 4120;
|
||||
case 160: return 4376;
|
||||
case 159: return 4568;
|
||||
case 16: return 4233;
|
||||
case 178: return 5654;
|
||||
case 227: return 4483;
|
||||
case 111: return 5398;
|
||||
case 256: return 5526;
|
||||
case 702: return 263446;
|
||||
case 146: return 4186;
|
||||
case 155: return 4890;
|
||||
case 141: return 4570;
|
||||
case 158: return 4762;
|
||||
case 38: return 5891;
|
||||
case 63: return 4291;
|
||||
case 270: return 4355;
|
||||
case 327: return 4675;
|
||||
case 704: return 4611;
|
||||
case 242: return 4739;
|
||||
case 223: return 4803;
|
||||
case 174: return 4931;
|
||||
case 137: return 5123;
|
||||
case 186: return 5187;
|
||||
case 250: return 5315;
|
||||
case 104: return 4299;
|
||||
case 113: return 5379;
|
||||
case 206: return 4867;
|
||||
case 184: return 5443;
|
||||
case 125: return 5507;
|
||||
case 170: return 5571;
|
||||
case 25: return 5763;
|
||||
case 118: return 5827;
|
||||
case 76: return 6019;
|
||||
case 116: return 6083;
|
||||
case 108: return 6211;
|
||||
case 35: return 6339;
|
||||
case 180: return 6403;
|
||||
case 121: return 6595;
|
||||
case 243: return 6659;
|
||||
case 150: return 6723;
|
||||
case 175: return 6851;
|
||||
case 600: return 4180;
|
||||
case 348: return 4244;
|
||||
case 179: return 4116;
|
||||
case 77: return 4884;
|
||||
case 387: return 262164;
|
||||
case 214: return 4308;
|
||||
case 289: return 4756;
|
||||
case 264: return 4692;
|
||||
case 93: return 4500;
|
||||
case 240: return 4564;
|
||||
case 127: return 4820;
|
||||
case 29: return 4436;
|
||||
case 20: return 4948;
|
||||
case 18: return 4628;
|
||||
case 293: return 4372;
|
||||
case 22: return 4571;
|
||||
case 3: return 4699;
|
||||
case 51: return 4635;
|
||||
case 89: return 4123;
|
||||
case 307: return 5705;
|
||||
case 15: return 5321;
|
||||
case 6: return 4809;
|
||||
case 58: return 6089;
|
||||
case 26: return 5513;
|
||||
case 187: return 5577;
|
||||
case 1: return 5769;
|
||||
case 12: return 5897;
|
||||
case 244: return 5961;
|
||||
case 8: return 6153;
|
||||
case 318: return 6217;
|
||||
case 2: return 6025;
|
||||
case 30: return 5833;
|
||||
case 7: return 6281;
|
||||
case 65: return 6409;
|
||||
case 221: return 6473;
|
||||
case 54: return 4937;
|
||||
case 69: return 5385;
|
||||
case 4: return 6537;
|
||||
case 200: return 5257;
|
||||
case 195: return 5129;
|
||||
case 120: return 5193;
|
||||
case 56: return 5904;
|
||||
case 5: return 6864;
|
||||
case 169: return 4171;
|
||||
case 61: return 5707;
|
||||
case 575: return 5968;
|
||||
case 563: return 5456;
|
||||
case 13: return 6992;
|
||||
case 10: return 4811;
|
||||
case 109: return 4236;
|
||||
case 67: return 4556;
|
||||
case 276: return 4442;
|
||||
case 103: return 4506;
|
||||
case 183: return 4440;
|
||||
case 632: return 4162;
|
||||
case 135: return 4098;
|
||||
case 205: return 5004;
|
||||
case 87: return 4684;
|
||||
case 164: return 4940;
|
||||
case 201: return 4300;
|
||||
case 68: return 4620;
|
||||
case 101: return 5068;
|
||||
case 0: return 70;
|
||||
case 737: return 4102;
|
||||
case 703: return 5955;
|
||||
case 705: return 6531;
|
||||
case 706: return 5635;
|
||||
case 707: return 5699;
|
||||
case 708: return 4995;
|
||||
case 715: return 4298;
|
||||
case 717: return 4362;
|
||||
case 716: return 4490;
|
||||
case 718: return 4234;
|
||||
case 719: return 4106;
|
||||
case 722: return 4240;
|
||||
case 723: return 6480;
|
||||
case 725: return 4312;
|
||||
case 726: return 4248;
|
||||
case 727: return 4184;
|
||||
case 728: return 4504;
|
||||
case 732: return 4698;
|
||||
case 733: return 4378;
|
||||
case 734: return 4634;
|
||||
case 166: return 4250;
|
||||
case 288: return 4314;
|
||||
case 274: return 4122;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void Query::InitParams(bool localitySearch, SearchQueryParams & params)
|
||||
void Processor::InitParams(bool localitySearch, QueryParams & params)
|
||||
{
|
||||
params.Clear();
|
||||
|
||||
|
@ -1131,7 +1125,7 @@ void Query::InitParams(bool localitySearch, SearchQueryParams & params)
|
|||
Classificator const & c = classif();
|
||||
auto addSyms = [&](size_t i, uint32_t t)
|
||||
{
|
||||
SearchQueryParams::TSynonymsVector & v = params.GetTokens(i);
|
||||
QueryParams::TSynonymsVector & v = params.GetTokens(i);
|
||||
|
||||
uint32_t const index = c.GetIndexForType(t);
|
||||
v.push_back(FeatureTypeToString(index));
|
||||
|
@ -1165,7 +1159,7 @@ void Query::InitParams(bool localitySearch, SearchQueryParams & params)
|
|||
params.m_langs.insert(GetLanguage(i));
|
||||
}
|
||||
|
||||
void Query::SuggestStrings(Results & res)
|
||||
void Processor::SuggestStrings(Results & res)
|
||||
{
|
||||
if (m_prefix.empty() || !m_suggestsEnabled)
|
||||
return;
|
||||
|
@ -1179,15 +1173,15 @@ void Query::SuggestStrings(Results & res)
|
|||
MatchForSuggestionsImpl(m_prefix, arrLocales[i], prolog, res);
|
||||
}
|
||||
|
||||
void Query::MatchForSuggestionsImpl(strings::UniString const & token, int8_t locale,
|
||||
string const & prolog, Results & res)
|
||||
void Processor::MatchForSuggestionsImpl(strings::UniString const & token, int8_t locale,
|
||||
string const & prolog, Results & res)
|
||||
{
|
||||
for (auto const & suggest : m_suggests)
|
||||
{
|
||||
strings::UniString const & s = suggest.m_name;
|
||||
if ((suggest.m_prefixLength <= token.size()) &&
|
||||
(token != s) && // do not push suggestion if it already equals to token
|
||||
(suggest.m_locale == locale) && // push suggestions only for needed language
|
||||
(token != s) && // do not push suggestion if it already equals to token
|
||||
(suggest.m_locale == locale) && // push suggestions only for needed language
|
||||
StartsWith(s.begin(), s.end(), token.begin(), token.end()))
|
||||
{
|
||||
string const utf8Str = strings::ToUtf8(s);
|
||||
|
@ -1198,7 +1192,7 @@ void Query::MatchForSuggestionsImpl(strings::UniString const & token, int8_t loc
|
|||
}
|
||||
}
|
||||
|
||||
m2::RectD const & Query::GetViewport(ViewportID vID /*= DEFAULT_V*/) const
|
||||
m2::RectD const & Processor::GetViewport(ViewportID vID /*= DEFAULT_V*/) const
|
||||
{
|
||||
if (vID == LOCALITY_V)
|
||||
{
|
||||
|
@ -1210,18 +1204,14 @@ m2::RectD const & Query::GetViewport(ViewportID vID /*= DEFAULT_V*/) const
|
|||
return m_viewport[CURRENT_V];
|
||||
}
|
||||
|
||||
string DebugPrint(Query::ViewportID viewportId)
|
||||
string DebugPrint(Processor::ViewportID viewportId)
|
||||
{
|
||||
switch (viewportId)
|
||||
{
|
||||
case Query::DEFAULT_V:
|
||||
return "Default";
|
||||
case Query::CURRENT_V:
|
||||
return "Current";
|
||||
case Query::LOCALITY_V:
|
||||
return "Locality";
|
||||
case Query::COUNT_V:
|
||||
return "Count";
|
||||
case Processor::DEFAULT_V: return "Default";
|
||||
case Processor::CURRENT_V: return "Current";
|
||||
case Processor::LOCALITY_V: return "Locality";
|
||||
case Processor::COUNT_V: return "Count";
|
||||
}
|
||||
ASSERT(false, ("Unknown viewportId"));
|
||||
return "Unknown";
|
|
@ -48,19 +48,18 @@ namespace search
|
|||
{
|
||||
struct Locality;
|
||||
struct Region;
|
||||
struct SearchQueryParams;
|
||||
struct QueryParams;
|
||||
|
||||
namespace impl
|
||||
{
|
||||
class FeatureLoader;
|
||||
class BestNameFinder;
|
||||
class PreResult2Maker;
|
||||
class DoFindLocality;
|
||||
class HouseCompFactory;
|
||||
class FeatureLoader;
|
||||
class BestNameFinder;
|
||||
class PreResult2Maker;
|
||||
class DoFindLocality;
|
||||
class HouseCompFactory;
|
||||
}
|
||||
|
||||
// TODO (@y): rename this class to QueryProcessor.
|
||||
class Query : public my::Cancellable
|
||||
class Processor : public my::Cancellable
|
||||
{
|
||||
public:
|
||||
// Maximum result candidates count for each viewport/criteria.
|
||||
|
@ -69,8 +68,8 @@ public:
|
|||
static double const kMinViewportRadiusM;
|
||||
static double const kMaxViewportRadiusM;
|
||||
|
||||
Query(Index & index, CategoriesHolder const & categories, vector<Suggest> const & suggests,
|
||||
storage::CountryInfoGetter const & infoGetter);
|
||||
Processor(Index & index, CategoriesHolder const & categories, vector<Suggest> const & suggests,
|
||||
storage::CountryInfoGetter const & infoGetter);
|
||||
|
||||
inline void SupportOldFormat(bool b) { m_supportOldFormat = b; }
|
||||
|
||||
|
@ -113,13 +112,15 @@ public:
|
|||
|
||||
virtual void ClearCaches();
|
||||
|
||||
struct CancelException {};
|
||||
struct CancelException
|
||||
{
|
||||
};
|
||||
|
||||
/// @name This stuff is public for implementation classes in search_query.cpp
|
||||
/// @name This stuff is public for implementation classes in processor.cpp
|
||||
/// Do not use it in client code.
|
||||
//@{
|
||||
|
||||
void InitParams(bool localitySearch, SearchQueryParams & params);
|
||||
void InitParams(bool localitySearch, QueryParams & params);
|
||||
|
||||
protected:
|
||||
enum ViewportID
|
||||
|
@ -127,7 +128,7 @@ protected:
|
|||
DEFAULT_V = -1,
|
||||
CURRENT_V = 0,
|
||||
LOCALITY_V = 1,
|
||||
COUNT_V = 2 // Should always be the last
|
||||
COUNT_V = 2 // Should always be the last
|
||||
};
|
||||
|
||||
friend string DebugPrint(ViewportID viewportId);
|
||||
|
@ -138,11 +139,11 @@ protected:
|
|||
friend class impl::DoFindLocality;
|
||||
friend class impl::HouseCompFactory;
|
||||
|
||||
int GetCategoryLocales(int8_t (&arr) [3]) const;
|
||||
int GetCategoryLocales(int8_t(&arr)[3]) const;
|
||||
template <class ToDo>
|
||||
void ForEachCategoryTypes(v2::QuerySlice const & slice, ToDo toDo) const;
|
||||
template <class ToDo> void ProcessEmojiIfNeeded(
|
||||
strings::UniString const & token, size_t ind, ToDo & toDo) const;
|
||||
template <class ToDo>
|
||||
void ProcessEmojiIfNeeded(strings::UniString const & token, size_t ind, ToDo & toDo) const;
|
||||
|
||||
using TMWMVector = vector<shared_ptr<MwmInfo>>;
|
||||
using TOffsetsVector = map<MwmSet::MwmId, vector<uint32_t>>;
|
||||
|
@ -164,17 +165,20 @@ protected:
|
|||
//@{
|
||||
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, bool allMWMs,
|
||||
size_t resCount, bool oldHouseSearch);
|
||||
void FlushViewportResults(v2::Geocoder::Params const & params, Results & res,
|
||||
bool oldHouseSearch);
|
||||
//@}
|
||||
|
||||
void RemoveStringPrefix(string const & str, string & res) const;
|
||||
void GetSuggestion(string const & name, string & suggest) const;
|
||||
template <class T> void ProcessSuggestions(vector<T> & vec, Results & res) const;
|
||||
template <class T>
|
||||
void ProcessSuggestions(vector<T> & vec, Results & res) const;
|
||||
|
||||
void SuggestStrings(Results & res);
|
||||
void MatchForSuggestionsImpl(strings::UniString const & token, int8_t locale, string const & prolog, Results & res);
|
||||
void MatchForSuggestionsImpl(strings::UniString const & token, int8_t locale,
|
||||
string const & prolog, Results & res);
|
||||
|
||||
void GetBestMatchName(FeatureType const & f, string & name) const;
|
||||
|
||||
|
@ -226,7 +230,8 @@ protected:
|
|||
TCompare() : m_fn(0) {}
|
||||
explicit TCompare(TFunction const & fn) : m_fn(fn) {}
|
||||
|
||||
template <class T> bool operator() (T const & v1, T const & v2) const
|
||||
template <class T>
|
||||
bool operator()(T const & v1, T const & v2) const
|
||||
{
|
||||
return m_fn(v1, v2);
|
||||
}
|
27
search/processor_factory.hpp
Normal file
27
search/processor_factory.hpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include "search/suggest.hpp"
|
||||
#include "search/v2/processor_v2.hpp"
|
||||
|
||||
#include "std/unique_ptr.hpp"
|
||||
|
||||
namespace storage
|
||||
{
|
||||
class CountryInfoGetter;
|
||||
}
|
||||
|
||||
namespace search
|
||||
{
|
||||
class SearchProcessorFactory
|
||||
{
|
||||
public:
|
||||
virtual ~SearchProcessorFactory() = default;
|
||||
|
||||
virtual unique_ptr<Processor> BuildProcessor(Index & index, CategoriesHolder const & categories,
|
||||
vector<Suggest> const & suggests,
|
||||
storage::CountryInfoGetter const & infoGetter)
|
||||
{
|
||||
return make_unique<v2::ProcessorV2>(index, categories, suggests, infoGetter);
|
||||
}
|
||||
};
|
||||
} // namespace search
|
|
@ -1,4 +1,4 @@
|
|||
#include "search/search_query_params.hpp"
|
||||
#include "search/query_params.hpp"
|
||||
|
||||
#include "indexer/feature_impl.hpp"
|
||||
#include "indexer/scales.hpp"
|
||||
|
@ -14,9 +14,9 @@ namespace
|
|||
class DoAddStreetSynonyms
|
||||
{
|
||||
public:
|
||||
DoAddStreetSynonyms(SearchQueryParams & params) : m_params(params) {}
|
||||
DoAddStreetSynonyms(QueryParams & params) : m_params(params) {}
|
||||
|
||||
void operator()(SearchQueryParams::TString const & s, size_t i)
|
||||
void operator()(QueryParams::TString const & s, size_t i)
|
||||
{
|
||||
if (s.size() > 2)
|
||||
return;
|
||||
|
@ -42,7 +42,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
SearchQueryParams::TSynonymsVector & GetSyms(size_t i) const
|
||||
QueryParams::TSynonymsVector & GetSyms(size_t i) const
|
||||
{
|
||||
size_t const count = m_params.m_tokens.size();
|
||||
if (i < count)
|
||||
|
@ -53,13 +53,13 @@ private:
|
|||
|
||||
void AddSym(size_t i, string const & sym) { GetSyms(i).push_back(strings::MakeUniString(sym)); }
|
||||
|
||||
SearchQueryParams & m_params;
|
||||
QueryParams & m_params;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
SearchQueryParams::SearchQueryParams() : m_scale(scales::GetUpperScale()) {}
|
||||
QueryParams::QueryParams() : m_scale(scales::GetUpperScale()) {}
|
||||
|
||||
void SearchQueryParams::Clear()
|
||||
void QueryParams::Clear()
|
||||
{
|
||||
m_tokens.clear();
|
||||
m_prefixTokens.clear();
|
||||
|
@ -68,7 +68,7 @@ void SearchQueryParams::Clear()
|
|||
m_scale = scales::GetUpperScale();
|
||||
}
|
||||
|
||||
void SearchQueryParams::EraseTokens(vector<size_t> & eraseInds)
|
||||
void QueryParams::EraseTokens(vector<size_t> & eraseInds)
|
||||
{
|
||||
eraseInds.erase(unique(eraseInds.begin(), eraseInds.end()), eraseInds.end());
|
||||
ASSERT(is_sorted(eraseInds.begin(), eraseInds.end()), ());
|
||||
|
@ -99,12 +99,12 @@ void SearchQueryParams::EraseTokens(vector<size_t> & eraseInds)
|
|||
}
|
||||
}
|
||||
|
||||
void SearchQueryParams::ProcessAddressTokens()
|
||||
void QueryParams::ProcessAddressTokens()
|
||||
{
|
||||
// Erases all number tokens.
|
||||
// Assumes that USA street name numbers are end with "st, nd, rd, th" suffixes.
|
||||
vector<size_t> toErase;
|
||||
ForEachToken([&toErase](SearchQueryParams::TString const & s, size_t i)
|
||||
ForEachToken([&toErase](QueryParams::TString const & s, size_t i)
|
||||
{
|
||||
if (feature::IsNumber(s))
|
||||
toErase.push_back(i);
|
||||
|
@ -115,19 +115,19 @@ void SearchQueryParams::ProcessAddressTokens()
|
|||
ForEachToken(DoAddStreetSynonyms(*this));
|
||||
}
|
||||
|
||||
SearchQueryParams::TSynonymsVector const & SearchQueryParams::GetTokens(size_t i) const
|
||||
QueryParams::TSynonymsVector const & QueryParams::GetTokens(size_t i) const
|
||||
{
|
||||
ASSERT_LESS_OR_EQUAL(i, m_tokens.size(), ());
|
||||
return i < m_tokens.size() ? m_tokens[i] : m_prefixTokens;
|
||||
}
|
||||
|
||||
SearchQueryParams::TSynonymsVector & SearchQueryParams::GetTokens(size_t i)
|
||||
QueryParams::TSynonymsVector & QueryParams::GetTokens(size_t i)
|
||||
{
|
||||
ASSERT_LESS_OR_EQUAL(i, m_tokens.size(), ());
|
||||
return i < m_tokens.size() ? m_tokens[i] : m_prefixTokens;
|
||||
}
|
||||
|
||||
bool SearchQueryParams::IsNumberTokens(size_t start, size_t end) const
|
||||
bool QueryParams::IsNumberTokens(size_t start, size_t end) const
|
||||
{
|
||||
ASSERT_LESS(start, end, ());
|
||||
for (; start != end; ++start)
|
||||
|
@ -149,7 +149,7 @@ bool SearchQueryParams::IsNumberTokens(size_t start, size_t end) const
|
|||
}
|
||||
|
||||
template <class ToDo>
|
||||
void SearchQueryParams::ForEachToken(ToDo && toDo)
|
||||
void QueryParams::ForEachToken(ToDo && toDo)
|
||||
{
|
||||
size_t const count = m_tokens.size();
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
|
@ -166,10 +166,10 @@ void SearchQueryParams::ForEachToken(ToDo && toDo)
|
|||
}
|
||||
}
|
||||
|
||||
string DebugPrint(search::SearchQueryParams const & params)
|
||||
string DebugPrint(search::QueryParams const & params)
|
||||
{
|
||||
ostringstream os;
|
||||
os << "SearchQueryParams [ m_tokens=" << DebugPrint(params.m_tokens)
|
||||
os << "QueryParams [ m_tokens=" << DebugPrint(params.m_tokens)
|
||||
<< ", m_prefixTokens=" << DebugPrint(params.m_prefixTokens) << "]";
|
||||
return os.str();
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace search
|
||||
{
|
||||
struct SearchQueryParams
|
||||
struct QueryParams
|
||||
{
|
||||
using TString = strings::UniString;
|
||||
using TSynonymsVector = vector<TString>;
|
||||
|
@ -21,7 +21,7 @@ struct SearchQueryParams
|
|||
TLangsSet m_langs;
|
||||
int m_scale;
|
||||
|
||||
SearchQueryParams();
|
||||
QueryParams();
|
||||
|
||||
void Clear();
|
||||
|
||||
|
@ -45,5 +45,5 @@ private:
|
|||
void ForEachToken(ToDo && toDo);
|
||||
};
|
||||
|
||||
string DebugPrint(search::SearchQueryParams const & params);
|
||||
string DebugPrint(search::QueryParams const & params);
|
||||
} // namespace search
|
|
@ -127,7 +127,7 @@ bool IsFirstMatchesSecond(vector<T> const & first, vector<T> const & second, TCo
|
|||
return false;
|
||||
}
|
||||
|
||||
bool MatchFeatureByName(FeatureType const & ft, SearchQueryParams const & params)
|
||||
bool MatchFeatureByName(FeatureType const & ft, QueryParams const & params)
|
||||
{
|
||||
using namespace strings;
|
||||
|
||||
|
@ -202,7 +202,7 @@ void WithSearchTrieRoot(MwmValue & value, TFn && fn)
|
|||
template <typename TValue>
|
||||
unique_ptr<coding::CompressedBitVector> RetrieveAddressFeaturesImpl(
|
||||
MwmSet::MwmId const & id, MwmValue & value, my::Cancellable const & cancellable,
|
||||
SearchQueryParams const & params)
|
||||
QueryParams const & params)
|
||||
{
|
||||
EditedFeaturesHolder holder(id);
|
||||
vector<uint64_t> features;
|
||||
|
@ -309,9 +309,10 @@ struct Selector
|
|||
};
|
||||
} // namespace
|
||||
|
||||
unique_ptr<coding::CompressedBitVector> RetrieveAddressFeatures(
|
||||
MwmSet::MwmId const & id, MwmValue & value, my::Cancellable const & cancellable,
|
||||
SearchQueryParams const & params)
|
||||
unique_ptr<coding::CompressedBitVector> RetrieveAddressFeatures(MwmSet::MwmId const & id,
|
||||
MwmValue & value,
|
||||
my::Cancellable const & cancellable,
|
||||
QueryParams const & params)
|
||||
{
|
||||
Selector<RetrieveAddressFeaturesAdaptor> selector;
|
||||
return selector(id, value, cancellable, params);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "search/search_query_params.hpp"
|
||||
#include "search/query_params.hpp"
|
||||
|
||||
#include "indexer/mwm_set.hpp"
|
||||
|
||||
|
@ -28,7 +28,7 @@ class TokenSlice;
|
|||
unique_ptr<coding::CompressedBitVector> RetrieveAddressFeatures(MwmSet::MwmId const & id,
|
||||
MwmValue & value,
|
||||
my::Cancellable const & cancellable,
|
||||
SearchQueryParams const & params);
|
||||
QueryParams const & params);
|
||||
|
||||
// Retrieves from the search index corresponding to |value| all
|
||||
// postcodes matching to |slice|.
|
||||
|
|
|
@ -26,7 +26,10 @@ HEADERS += \
|
|||
mode.hpp \
|
||||
params.hpp \
|
||||
pre_ranker.hpp \
|
||||
processor.hpp \
|
||||
processor_factory.hpp \
|
||||
projection_on_street.hpp \
|
||||
query_params.hpp \
|
||||
query_saver.hpp \
|
||||
region.hpp \
|
||||
result.hpp \
|
||||
|
@ -35,9 +38,6 @@ HEADERS += \
|
|||
search_common.hpp \
|
||||
search_engine.hpp \
|
||||
search_index_values.hpp \
|
||||
search_query.hpp \
|
||||
search_query_factory.hpp \
|
||||
search_query_params.hpp \
|
||||
search_string_intersection.hpp \
|
||||
search_trie.hpp \
|
||||
suggest.hpp \
|
||||
|
@ -57,11 +57,11 @@ HEADERS += \
|
|||
v2/nested_rects_cache.hpp \
|
||||
v2/postcodes_matcher.hpp \
|
||||
v2/pre_ranking_info.hpp \
|
||||
v2/processor_v2.hpp \
|
||||
v2/rank_table_cache.hpp \
|
||||
v2/ranking_info.hpp \
|
||||
v2/ranking_utils.hpp \
|
||||
v2/search_model.hpp \
|
||||
v2/search_query_v2.hpp \
|
||||
v2/stats_cache.hpp \
|
||||
v2/street_vicinity_loader.hpp \
|
||||
v2/token_slice.hpp \
|
||||
|
@ -80,15 +80,15 @@ SOURCES += \
|
|||
mode.cpp \
|
||||
params.cpp \
|
||||
pre_ranker.cpp \
|
||||
processor.cpp \
|
||||
projection_on_street.cpp \
|
||||
query_params.cpp \
|
||||
query_saver.cpp \
|
||||
region.cpp \
|
||||
result.cpp \
|
||||
retrieval.cpp \
|
||||
reverse_geocoder.cpp \
|
||||
search_engine.cpp \
|
||||
search_query.cpp \
|
||||
search_query_params.cpp \
|
||||
types_skipper.cpp \
|
||||
v2/cbv_ptr.cpp \
|
||||
v2/features_filter.cpp \
|
||||
|
@ -105,10 +105,10 @@ SOURCES += \
|
|||
v2/nested_rects_cache.cpp \
|
||||
v2/postcodes_matcher.cpp \
|
||||
v2/pre_ranking_info.cpp \
|
||||
v2/processor_v2.cpp \
|
||||
v2/rank_table_cache.cpp \
|
||||
v2/ranking_info.cpp \
|
||||
v2/ranking_utils.cpp \
|
||||
v2/search_model.cpp \
|
||||
v2/search_query_v2.cpp \
|
||||
v2/street_vicinity_loader.cpp \
|
||||
v2/token_slice.cpp \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "search_engine.hpp"
|
||||
|
||||
#include "geometry_utils.hpp"
|
||||
#include "search_query.hpp"
|
||||
#include "processor.hpp"
|
||||
|
||||
#include "storage/country_info_getter.hpp"
|
||||
|
||||
|
@ -89,10 +89,10 @@ void SendStatistics(SearchParams const & params, m2::RectD const & viewport, Res
|
|||
}
|
||||
} // namespace
|
||||
|
||||
// QueryHandle -------------------------------------------------------------------------------------
|
||||
QueryHandle::QueryHandle() : m_processor(nullptr), m_cancelled(false) {}
|
||||
// ProcessorHandle----------------------------------------------------------------------------------
|
||||
ProcessorHandle::ProcessorHandle() : m_processor(nullptr), m_cancelled(false) {}
|
||||
|
||||
void QueryHandle::Cancel()
|
||||
void ProcessorHandle::Cancel()
|
||||
{
|
||||
lock_guard<mutex> lock(m_mu);
|
||||
m_cancelled = true;
|
||||
|
@ -100,7 +100,7 @@ void QueryHandle::Cancel()
|
|||
m_processor->Cancel();
|
||||
}
|
||||
|
||||
void QueryHandle::Attach(Query & processor)
|
||||
void ProcessorHandle::Attach(Processor & processor)
|
||||
{
|
||||
lock_guard<mutex> lock(m_mu);
|
||||
m_processor = &processor;
|
||||
|
@ -108,7 +108,7 @@ void QueryHandle::Attach(Query & processor)
|
|||
m_processor->Cancel();
|
||||
}
|
||||
|
||||
void QueryHandle::Detach()
|
||||
void ProcessorHandle::Detach()
|
||||
{
|
||||
lock_guard<mutex> lock(m_mu);
|
||||
m_processor = nullptr;
|
||||
|
@ -125,7 +125,7 @@ Engine::Params::Params(string const & locale, size_t numThreads)
|
|||
// Engine ------------------------------------------------------------------------------------------
|
||||
Engine::Engine(Index & index, CategoriesHolder const & categories,
|
||||
storage::CountryInfoGetter const & infoGetter,
|
||||
unique_ptr<SearchQueryFactory> factory, Params const & params)
|
||||
unique_ptr<SearchProcessorFactory> factory, Params const & params)
|
||||
: m_categories(categories), m_shutdown(false)
|
||||
{
|
||||
InitSuggestions doInit;
|
||||
|
@ -135,7 +135,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->BuildSearchQuery(index, m_categories, m_suggests, infoGetter);
|
||||
auto processor = factory->BuildProcessor(index, m_categories, m_suggests, infoGetter);
|
||||
processor->SetPreferredLocale(params.m_locale);
|
||||
m_contexts[i].m_processor = move(processor);
|
||||
}
|
||||
|
@ -157,10 +157,10 @@ Engine::~Engine()
|
|||
thread.join();
|
||||
}
|
||||
|
||||
weak_ptr<QueryHandle> Engine::Search(SearchParams const & params, m2::RectD const & viewport)
|
||||
weak_ptr<ProcessorHandle> Engine::Search(SearchParams const & params, m2::RectD const & viewport)
|
||||
{
|
||||
shared_ptr<QueryHandle> handle(new QueryHandle());
|
||||
PostMessage(Message::TYPE_TASK, [this, params, viewport, handle](Query & query)
|
||||
shared_ptr<ProcessorHandle> handle(new ProcessorHandle());
|
||||
PostMessage(Message::TYPE_TASK, [this, params, viewport, handle](Processor & query)
|
||||
{
|
||||
DoSearch(params, viewport, handle, query);
|
||||
});
|
||||
|
@ -169,7 +169,7 @@ weak_ptr<QueryHandle> Engine::Search(SearchParams const & params, m2::RectD cons
|
|||
|
||||
void Engine::SetSupportOldFormat(bool support)
|
||||
{
|
||||
PostMessage(Message::TYPE_BROADCAST, [this, support](Query & processor)
|
||||
PostMessage(Message::TYPE_BROADCAST, [this, support](Processor & processor)
|
||||
{
|
||||
processor.SupportOldFormat(support);
|
||||
});
|
||||
|
@ -177,7 +177,7 @@ void Engine::SetSupportOldFormat(bool support)
|
|||
|
||||
void Engine::SetLocale(string const & locale)
|
||||
{
|
||||
PostMessage(Message::TYPE_BROADCAST, [this, locale](Query & processor)
|
||||
PostMessage(Message::TYPE_BROADCAST, [this, locale](Processor & processor)
|
||||
{
|
||||
processor.SetPreferredLocale(locale);
|
||||
});
|
||||
|
@ -185,14 +185,14 @@ void Engine::SetLocale(string const & locale)
|
|||
|
||||
void Engine::ClearCaches()
|
||||
{
|
||||
PostMessage(Message::TYPE_BROADCAST, [this](Query & processor)
|
||||
PostMessage(Message::TYPE_BROADCAST, [this](Processor & processor)
|
||||
{
|
||||
processor.ClearCaches();
|
||||
});
|
||||
}
|
||||
|
||||
void Engine::SetRankPivot(SearchParams const & params, m2::RectD const & viewport,
|
||||
bool viewportSearch, Query & processor)
|
||||
bool viewportSearch, Processor & processor)
|
||||
{
|
||||
if (!viewportSearch && params.IsValidPosition())
|
||||
{
|
||||
|
@ -279,7 +279,7 @@ void Engine::PostMessage(TArgs && ... args)
|
|||
}
|
||||
|
||||
void Engine::DoSearch(SearchParams const & params, m2::RectD const & viewport,
|
||||
shared_ptr<QueryHandle> handle, Query & processor)
|
||||
shared_ptr<ProcessorHandle> handle, Processor & processor)
|
||||
{
|
||||
bool const viewportSearch = params.GetMode() == Mode::Viewport;
|
||||
|
||||
|
@ -332,7 +332,7 @@ void Engine::DoSearch(SearchParams const & params, m2::RectD const & viewport,
|
|||
if (!processor.IsCancelled())
|
||||
EmitResults(params, res);
|
||||
}
|
||||
catch (Query::CancelException const &)
|
||||
catch (Processor::CancelException const &)
|
||||
{
|
||||
LOG(LDEBUG, ("Search has been cancelled."));
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "params.hpp"
|
||||
#include "processor_factory.hpp"
|
||||
#include "result.hpp"
|
||||
#include "search_query_factory.hpp"
|
||||
#include "suggest.hpp"
|
||||
|
||||
#include "indexer/categories_holder.hpp"
|
||||
|
@ -35,19 +35,19 @@ class CountryInfoGetter;
|
|||
namespace search
|
||||
{
|
||||
class EngineData;
|
||||
class Query;
|
||||
class Processor;
|
||||
|
||||
// This class is used as a reference to a search query in the
|
||||
// This class is used as a reference to a search processor in the
|
||||
// SearchEngine's queue. It's only possible to cancel a search
|
||||
// request via this reference.
|
||||
//
|
||||
// NOTE: this class is thread-safe.
|
||||
class QueryHandle
|
||||
class ProcessorHandle
|
||||
{
|
||||
public:
|
||||
QueryHandle();
|
||||
ProcessorHandle();
|
||||
|
||||
// Cancels query this handle points to.
|
||||
// Cancels processor this handle points to.
|
||||
void Cancel();
|
||||
|
||||
private:
|
||||
|
@ -55,20 +55,20 @@ private:
|
|||
|
||||
// Attaches the handle to a |processor|. If there was or will be a
|
||||
// cancel signal, this signal will be propagated to |processor|.
|
||||
// This method is called only once, when search engine starts to
|
||||
// process query this handle corresponds to.
|
||||
void Attach(Query & processor);
|
||||
// This method is called only once, when search engine starts
|
||||
// the processor this handle corresponds to.
|
||||
void Attach(Processor & processor);
|
||||
|
||||
// Detaches handle from a processor. This method is called only
|
||||
// once, when search engine completes process of a query this handle
|
||||
// corresponds to.
|
||||
// once, when search engine completes processing of the query
|
||||
// that this handle corresponds to.
|
||||
void Detach();
|
||||
|
||||
Query * m_processor;
|
||||
Processor * m_processor;
|
||||
bool m_cancelled;
|
||||
mutex m_mu;
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(QueryHandle);
|
||||
DISALLOW_COPY_AND_MOVE(ProcessorHandle);
|
||||
};
|
||||
|
||||
// This class is a wrapper around thread which processes search
|
||||
|
@ -93,12 +93,12 @@ public:
|
|||
|
||||
// Doesn't take ownership of index. Takes ownership of categoriesR.
|
||||
Engine(Index & index, CategoriesHolder const & categories,
|
||||
storage::CountryInfoGetter const & infoGetter, unique_ptr<SearchQueryFactory> factory,
|
||||
storage::CountryInfoGetter const & infoGetter, unique_ptr<SearchProcessorFactory> factory,
|
||||
Params const & params);
|
||||
~Engine();
|
||||
|
||||
// Posts search request to the queue and returns its handle.
|
||||
weak_ptr<QueryHandle> Search(SearchParams const & params, m2::RectD const & viewport);
|
||||
weak_ptr<ProcessorHandle> Search(SearchParams const & params, m2::RectD const & viewport);
|
||||
|
||||
// Posts request to support old format to the queue.
|
||||
void SetSupportOldFormat(bool support);
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
private:
|
||||
struct Message
|
||||
{
|
||||
using TFn = function<void(Query & processor)>;
|
||||
using TFn = function<void(Processor & processor)>;
|
||||
|
||||
enum Type
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ private:
|
|||
|
||||
Message(Type type, TFn && fn) : m_type(type), m_fn(move(fn)) {}
|
||||
|
||||
void operator()(Query & processor) { m_fn(processor); }
|
||||
void operator()(Processor & processor) { m_fn(processor); }
|
||||
|
||||
Type m_type;
|
||||
TFn m_fn;
|
||||
|
@ -140,12 +140,12 @@ private:
|
|||
|
||||
// This field is thread-specific and *CAN NOT* be accessed by
|
||||
// other threads.
|
||||
unique_ptr<Query> m_processor;
|
||||
unique_ptr<Processor> m_processor;
|
||||
};
|
||||
|
||||
// *ALL* following methods are executed on the m_threads threads.
|
||||
void SetRankPivot(SearchParams const & params, m2::RectD const & viewport, bool viewportSearch,
|
||||
Query & processor);
|
||||
Processor & processor);
|
||||
|
||||
void EmitResults(SearchParams const & params, Results const & res);
|
||||
|
||||
|
@ -159,7 +159,7 @@ private:
|
|||
void PostMessage(TArgs &&... args);
|
||||
|
||||
void DoSearch(SearchParams const & params, m2::RectD const & viewport,
|
||||
shared_ptr<QueryHandle> handle, Query & processor);
|
||||
shared_ptr<ProcessorHandle> handle, Processor & processor);
|
||||
|
||||
CategoriesHolder const & m_categories;
|
||||
vector<Suggest> m_suggests;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "search/search_integration_tests/helpers.hpp"
|
||||
|
||||
#include "search/search_query_factory.hpp"
|
||||
#include "search/processor_factory.hpp"
|
||||
#include "search/search_tests_support/test_search_request.hpp"
|
||||
|
||||
#include "indexer/scales.hpp"
|
||||
|
@ -12,8 +12,8 @@ namespace search
|
|||
SearchTest::SearchTest()
|
||||
: m_platform(GetPlatform())
|
||||
, m_scopedLog(LDEBUG)
|
||||
, m_engine(make_unique<storage::CountryInfoGetterForTesting>(), make_unique<SearchQueryFactory>(),
|
||||
Engine::Params())
|
||||
, m_engine(make_unique<storage::CountryInfoGetterForTesting>(),
|
||||
make_unique<SearchProcessorFactory>(), Engine::Params())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace search
|
|||
{
|
||||
namespace
|
||||
{
|
||||
class SearchQueryV2Test : public SearchTest
|
||||
class ProcessorV2Test : public SearchTest
|
||||
{
|
||||
public:
|
||||
unique_ptr<TestSearchRequest> MakeRequest(string const & query)
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
UNIT_CLASS_TEST(SearchQueryV2Test, Smoke)
|
||||
UNIT_CLASS_TEST(ProcessorV2Test, Smoke)
|
||||
{
|
||||
string const countryName = "Wonderland";
|
||||
TestCountry wonderlandCountry(m2::PointD(10, 10), countryName, "en");
|
||||
|
@ -193,7 +193,7 @@ UNIT_CLASS_TEST(SearchQueryV2Test, Smoke)
|
|||
}
|
||||
}
|
||||
|
||||
UNIT_CLASS_TEST(SearchQueryV2Test, SearchInWorld)
|
||||
UNIT_CLASS_TEST(ProcessorV2Test, SearchInWorld)
|
||||
{
|
||||
string const countryName = "Wonderland";
|
||||
TestCountry wonderland(m2::PointD(0, 0), countryName, "en");
|
||||
|
@ -221,7 +221,7 @@ UNIT_CLASS_TEST(SearchQueryV2Test, SearchInWorld)
|
|||
}
|
||||
}
|
||||
|
||||
UNIT_CLASS_TEST(SearchQueryV2Test, SearchByName)
|
||||
UNIT_CLASS_TEST(ProcessorV2Test, SearchByName)
|
||||
{
|
||||
string const countryName = "Wonderland";
|
||||
TestCity london(m2::PointD(1, 1), "London", "en", 100 /* rank */);
|
||||
|
@ -259,7 +259,7 @@ UNIT_CLASS_TEST(SearchQueryV2Test, SearchByName)
|
|||
}
|
||||
}
|
||||
|
||||
UNIT_CLASS_TEST(SearchQueryV2Test, DisableSuggests)
|
||||
UNIT_CLASS_TEST(ProcessorV2Test, 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(SearchQueryV2Test, DisableSuggests)
|
|||
}
|
||||
}
|
||||
|
||||
UNIT_CLASS_TEST(SearchQueryV2Test, TestRankingInfo)
|
||||
UNIT_CLASS_TEST(ProcessorV2Test, TestRankingInfo)
|
||||
{
|
||||
string const countryName = "Wonderland";
|
||||
|
||||
|
@ -367,7 +367,7 @@ UNIT_CLASS_TEST(SearchQueryV2Test, TestRankingInfo)
|
|||
}
|
||||
}
|
||||
|
||||
UNIT_CLASS_TEST(SearchQueryV2Test, TestPostcodes)
|
||||
UNIT_CLASS_TEST(ProcessorV2Test, TestPostcodes)
|
||||
{
|
||||
string const countryName = "Russia";
|
||||
|
||||
|
@ -410,7 +410,7 @@ UNIT_CLASS_TEST(SearchQueryV2Test, TestPostcodes)
|
|||
TEST(handle.IsAlive(), ());
|
||||
my::Cancellable cancellable;
|
||||
|
||||
SearchQueryParams params;
|
||||
QueryParams params;
|
||||
params.m_tokens.emplace_back();
|
||||
params.m_tokens.back().push_back(strings::MakeUniString("141702"));
|
||||
auto * value = handle.GetValue<MwmValue>();
|
||||
|
@ -462,7 +462,7 @@ UNIT_CLASS_TEST(SearchQueryV2Test, TestPostcodes)
|
|||
}
|
||||
}
|
||||
|
||||
UNIT_CLASS_TEST(SearchQueryV2Test, TestCategories)
|
||||
UNIT_CLASS_TEST(ProcessorV2Test, TestCategories)
|
||||
{
|
||||
string const countryName = "Wonderland";
|
||||
|
||||
|
|
|
@ -217,7 +217,8 @@ int main(int argc, char * argv[])
|
|||
}
|
||||
|
||||
classificator::Load();
|
||||
TestSearchEngine engine(move(infoGetter), make_unique<SearchQueryFactory>(), Engine::Params{});
|
||||
TestSearchEngine engine(move(infoGetter), make_unique<SearchProcessorFactory>(),
|
||||
Engine::Params{});
|
||||
|
||||
vector<platform::LocalCountryFile> mwms;
|
||||
platform::FindAllLocalMapsAndCleanup(numeric_limits<int64_t>::max() /* the latest version */,
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
#include "geometry/mercator.hpp"
|
||||
#include "geometry/point2d.hpp"
|
||||
|
||||
#include "search/processor_factory.hpp"
|
||||
#include "search/result.hpp"
|
||||
#include "search/search_quality/helpers.hpp"
|
||||
#include "search/search_query_factory.hpp"
|
||||
#include "search/search_tests_support/test_search_engine.hpp"
|
||||
#include "search/search_tests_support/test_search_request.hpp"
|
||||
#include "search/v2/ranking_info.hpp"
|
||||
|
@ -380,7 +380,8 @@ 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<SearchQueryFactory>(), Engine::Params{});
|
||||
TestSearchEngine engine(move(infoGetter), make_unique<SearchProcessorFactory>(),
|
||||
Engine::Params{});
|
||||
|
||||
vector<platform::LocalCountryFile> mwms;
|
||||
if (!FLAGS_mwm_list_path.empty())
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "search/suggest.hpp"
|
||||
#include "search/v2/search_query_v2.hpp"
|
||||
|
||||
#include "std/unique_ptr.hpp"
|
||||
|
||||
namespace storage
|
||||
{
|
||||
class CountryInfoGetter;
|
||||
}
|
||||
|
||||
namespace search
|
||||
{
|
||||
class SearchQueryFactory
|
||||
{
|
||||
public:
|
||||
virtual ~SearchQueryFactory() = default;
|
||||
|
||||
virtual unique_ptr<Query> BuildSearchQuery(Index & index, CategoriesHolder const & categories,
|
||||
vector<Suggest> const & suggests,
|
||||
storage::CountryInfoGetter const & infoGetter)
|
||||
{
|
||||
return make_unique<v2::SearchQueryV2>(index, categories, suggests, infoGetter);
|
||||
}
|
||||
};
|
||||
} // namespace search
|
|
@ -21,7 +21,7 @@ using namespace strings;
|
|||
|
||||
namespace
|
||||
{
|
||||
void InitParams(string const & query, bool lastTokenIsPrefix, SearchQueryParams & params)
|
||||
void InitParams(string const & query, bool lastTokenIsPrefix, QueryParams & params)
|
||||
{
|
||||
params.m_tokens.clear();
|
||||
params.m_prefixTokens.clear();
|
||||
|
@ -40,7 +40,7 @@ void InitParams(string const & query, bool lastTokenIsPrefix, SearchQueryParams
|
|||
}
|
||||
}
|
||||
|
||||
void AddLocality(string const & name, uint32_t featureId, SearchQueryParams & params,
|
||||
void AddLocality(string const & name, uint32_t featureId, QueryParams & params,
|
||||
vector<Geocoder::Locality> & localities)
|
||||
{
|
||||
set<UniString> tokens;
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
uint8_t GetRank(uint32_t featureId) const override { return 0; }
|
||||
|
||||
protected:
|
||||
SearchQueryParams m_params;
|
||||
QueryParams m_params;
|
||||
vector<Geocoder::Locality> m_localities;
|
||||
unordered_map<uint32_t, vector<string>> m_names;
|
||||
LocalityScorer m_scorer;
|
||||
|
@ -208,7 +208,7 @@ UNIT_CLASS_TEST(LocalityScorerTest, PrefixMatch)
|
|||
ID_MOSCOW
|
||||
};
|
||||
|
||||
// SearchQueryParams params;
|
||||
// QueryParams params;
|
||||
InitParams("New York San Anto", true /* lastTokenIsPrefix */);
|
||||
|
||||
// vector<Geocoder::Locality> localities;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "../../testing/testing.hpp"
|
||||
|
||||
#include "search/search_query_params.hpp"
|
||||
#include "search/query_params.hpp"
|
||||
#include "search/v2/postcodes_matcher.hpp"
|
||||
#include "search/v2/token_slice.hpp"
|
||||
|
||||
|
@ -29,7 +29,7 @@ bool LooksLikePostcode(string const & s, bool checkPrefix)
|
|||
|
||||
size_t const numTokens = tokens.size();
|
||||
|
||||
SearchQueryParams params;
|
||||
QueryParams params;
|
||||
if (checkPrefix && lastTokenIsPrefix)
|
||||
{
|
||||
params.m_prefixTokens.push_back(tokens.back());
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "testing/testing.hpp"
|
||||
|
||||
#include "search/search_query_params.hpp"
|
||||
#include "search/query_params.hpp"
|
||||
#include "search/v2/ranking_utils.hpp"
|
||||
#include "search/v2/token_slice.hpp"
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace
|
|||
NameScore GetScore(string const & name, string const & query, size_t startToken, size_t endToken)
|
||||
{
|
||||
search::Delimiters delims;
|
||||
SearchQueryParams params;
|
||||
QueryParams params;
|
||||
auto addToken = [¶ms](UniString const & token)
|
||||
{
|
||||
params.m_tokens.push_back({token});
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace search
|
|||
namespace tests_support
|
||||
{
|
||||
TestSearchEngine::TestSearchEngine(unique_ptr<storage::CountryInfoGetter> infoGetter,
|
||||
unique_ptr<::search::SearchQueryFactory> factory,
|
||||
unique_ptr<::search::SearchProcessorFactory> factory,
|
||||
Engine::Params const & params)
|
||||
: m_platform(GetPlatform())
|
||||
, m_infoGetter(move(infoGetter))
|
||||
|
@ -17,7 +17,7 @@ TestSearchEngine::TestSearchEngine(unique_ptr<storage::CountryInfoGetter> infoGe
|
|||
{
|
||||
}
|
||||
|
||||
TestSearchEngine::TestSearchEngine(unique_ptr<::search::SearchQueryFactory> factory,
|
||||
TestSearchEngine::TestSearchEngine(unique_ptr<::search::SearchProcessorFactory> factory,
|
||||
Engine::Params const & params)
|
||||
: m_platform(GetPlatform())
|
||||
, m_infoGetter(storage::CountryInfoReader::CreateCountryInfoReader(m_platform))
|
||||
|
@ -27,8 +27,8 @@ TestSearchEngine::TestSearchEngine(unique_ptr<::search::SearchQueryFactory> fact
|
|||
|
||||
TestSearchEngine::~TestSearchEngine() {}
|
||||
|
||||
weak_ptr<::search::QueryHandle> TestSearchEngine::Search(::search::SearchParams const & params,
|
||||
m2::RectD const & viewport)
|
||||
weak_ptr<::search::ProcessorHandle> TestSearchEngine::Search(::search::SearchParams const & params,
|
||||
m2::RectD const & viewport)
|
||||
{
|
||||
return m_engine.Search(params, viewport);
|
||||
}
|
||||
|
|
|
@ -27,14 +27,16 @@ class TestSearchEngine : public Index
|
|||
{
|
||||
public:
|
||||
TestSearchEngine(unique_ptr<storage::CountryInfoGetter> infoGetter,
|
||||
unique_ptr<search::SearchQueryFactory> factory, Engine::Params const & params);
|
||||
TestSearchEngine(unique_ptr<::search::SearchQueryFactory> factory, Engine::Params const & params);
|
||||
unique_ptr<search::SearchProcessorFactory> factory,
|
||||
Engine::Params const & params);
|
||||
TestSearchEngine(unique_ptr<::search::SearchProcessorFactory> factory,
|
||||
Engine::Params const & params);
|
||||
~TestSearchEngine() override;
|
||||
|
||||
inline void SetLocale(string const & locale) { m_engine.SetLocale(locale); }
|
||||
|
||||
weak_ptr<search::QueryHandle> Search(search::SearchParams const & params,
|
||||
m2::RectD const & viewport);
|
||||
weak_ptr<search::ProcessorHandle> Search(search::SearchParams const & params,
|
||||
m2::RectD const & viewport);
|
||||
|
||||
storage::CountryInfoGetter & GetCountryInfoGetter() { return *m_infoGetter; }
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "search/v2/geocoder.hpp"
|
||||
|
||||
#include "search/dummy_rank_table.hpp"
|
||||
#include "search/processor.hpp"
|
||||
#include "search/retrieval.hpp"
|
||||
#include "search/search_query.hpp"
|
||||
#include "search/v2/cbv_ptr.hpp"
|
||||
#include "search/v2/features_filter.hpp"
|
||||
#include "search/v2/features_layer_matcher.hpp"
|
||||
|
@ -210,7 +210,7 @@ private:
|
|||
DISALLOW_COPY_AND_MOVE(StreetCategories);
|
||||
};
|
||||
|
||||
void JoinQueryTokens(SearchQueryParams const & params, size_t curToken, size_t endToken,
|
||||
void JoinQueryTokens(QueryParams const & params, size_t curToken, size_t endToken,
|
||||
strings::UniString const & sep, strings::UniString & res)
|
||||
{
|
||||
ASSERT_LESS_OR_EQUAL(curToken, endToken, ());
|
||||
|
@ -397,7 +397,7 @@ Geocoder::Geocoder(Index & index, storage::CountryInfoGetter const & infoGetter)
|
|||
, m_numTokens(0)
|
||||
, m_model(SearchModel::Instance())
|
||||
, m_pivotRectsCache(kPivotRectsCacheSize, static_cast<my::Cancellable const &>(*this),
|
||||
Query::kMaxViewportRadiusM)
|
||||
Processor::kMaxViewportRadiusM)
|
||||
, m_localityRectsCache(kLocalityRectsCacheSize, static_cast<my::Cancellable const &>(*this))
|
||||
, m_pivotFeatures(index)
|
||||
, m_streets(nullptr)
|
||||
|
@ -633,7 +633,7 @@ void Geocoder::PrepareRetrievalParams(size_t curToken, size_t endToken)
|
|||
|
||||
// TODO (@y): possibly it's not cheap to copy vectors of strings.
|
||||
// Profile it, and in case of serious performance loss, refactor
|
||||
// SearchQueryParams to support subsets of tokens.
|
||||
// QueryParams to support subsets of tokens.
|
||||
for (size_t i = curToken; i < endToken; ++i)
|
||||
{
|
||||
if (i < m_params.m_tokens.size())
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "search/cancel_exception.hpp"
|
||||
#include "search/mode.hpp"
|
||||
#include "search/search_query_params.hpp"
|
||||
#include "search/query_params.hpp"
|
||||
#include "search/v2/features_layer.hpp"
|
||||
#include "search/v2/features_layer_path_finder.hpp"
|
||||
#include "search/v2/geometry_cache.hpp"
|
||||
|
@ -75,7 +75,7 @@ class TokenSlice;
|
|||
class Geocoder : public my::Cancellable
|
||||
{
|
||||
public:
|
||||
struct Params : public SearchQueryParams
|
||||
struct Params : public QueryParams
|
||||
{
|
||||
Params();
|
||||
|
||||
|
@ -185,7 +185,7 @@ private:
|
|||
template <typename TLocality>
|
||||
using TLocalitiesCache = map<pair<size_t, size_t>, vector<TLocality>>;
|
||||
|
||||
SearchQueryParams::TSynonymsVector const & GetTokens(size_t i) const;
|
||||
QueryParams::TSynonymsVector const & GetTokens(size_t i) const;
|
||||
|
||||
// Fills |m_retrievalParams| with [curToken, endToken) subsequence
|
||||
// of search query tokens.
|
||||
|
@ -372,7 +372,7 @@ private:
|
|||
FeaturesLayerPathFinder m_finder;
|
||||
|
||||
// Search query params prepared for retrieval.
|
||||
SearchQueryParams m_retrievalParams;
|
||||
QueryParams m_retrievalParams;
|
||||
|
||||
// Pointer to the most nested region filled during geocoding.
|
||||
Region const * m_lastMatchedRegion;
|
||||
|
|
|
@ -33,7 +33,7 @@ LocalityScorer::ExLocality::ExLocality(Geocoder::Locality const & locality)
|
|||
}
|
||||
|
||||
// LocalityScorer ----------------------------------------------------------------------------------
|
||||
LocalityScorer::LocalityScorer(SearchQueryParams const & params, Delegate const & delegate)
|
||||
LocalityScorer::LocalityScorer(QueryParams const & params, Delegate const & delegate)
|
||||
: m_params(params), m_delegate(delegate)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace search
|
||||
{
|
||||
struct SearchQueryParams;
|
||||
struct QueryParams;
|
||||
|
||||
namespace v2
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ public:
|
|||
virtual uint8_t GetRank(uint32_t featureId) const = 0;
|
||||
};
|
||||
|
||||
LocalityScorer(SearchQueryParams const & params, Delegate const & delegate);
|
||||
LocalityScorer(QueryParams const & params, Delegate const & delegate);
|
||||
|
||||
// Leaves at most |limit| elements of |localities|, ordered by some
|
||||
// combination of ranks and number of matched tokens.
|
||||
|
@ -50,7 +50,7 @@ private:
|
|||
void LeaveTopByRank(size_t limit, vector<ExLocality> & ls) const;
|
||||
void SortByName(vector<ExLocality> & ls) const;
|
||||
|
||||
SearchQueryParams const & m_params;
|
||||
QueryParams const & m_params;
|
||||
Delegate const & m_delegate;
|
||||
};
|
||||
} // namespace v2
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "search/v2/search_query_v2.hpp"
|
||||
#include "search/v2/processor_v2.hpp"
|
||||
|
||||
#include "search/dummy_rank_table.hpp"
|
||||
|
||||
|
@ -13,27 +13,27 @@ namespace search
|
|||
{
|
||||
namespace v2
|
||||
{
|
||||
SearchQueryV2::SearchQueryV2(Index & index, CategoriesHolder const & categories,
|
||||
vector<Suggest> const & suggests,
|
||||
storage::CountryInfoGetter const & infoGetter)
|
||||
: Query(index, categories, suggests, infoGetter), m_geocoder(index, infoGetter)
|
||||
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 SearchQueryV2::Reset()
|
||||
void ProcessorV2::Reset()
|
||||
{
|
||||
Query::Reset();
|
||||
Processor::Reset();
|
||||
m_geocoder.Reset();
|
||||
}
|
||||
|
||||
void SearchQueryV2::Cancel()
|
||||
void ProcessorV2::Cancel()
|
||||
{
|
||||
Query::Cancel();
|
||||
Processor::Cancel();
|
||||
m_geocoder.Cancel();
|
||||
}
|
||||
|
||||
void SearchQueryV2::Search(Results & results, size_t limit)
|
||||
void ProcessorV2::Search(Results & results, size_t limit)
|
||||
{
|
||||
if (m_tokens.empty())
|
||||
SuggestStrings(results);
|
||||
|
@ -51,7 +51,7 @@ void SearchQueryV2::Search(Results & results, size_t limit)
|
|||
FlushResults(params, results, false /* allMWMs */, limit, false /* oldHouseSearch */);
|
||||
}
|
||||
|
||||
void SearchQueryV2::SearchViewportPoints(Results & results)
|
||||
void ProcessorV2::SearchViewportPoints(Results & results)
|
||||
{
|
||||
Geocoder::Params params;
|
||||
InitParams(false /* localitySearch */, params);
|
||||
|
@ -64,9 +64,9 @@ void SearchQueryV2::SearchViewportPoints(Results & results)
|
|||
FlushViewportResults(params, results, false /* oldHouseSearch */);
|
||||
}
|
||||
|
||||
void SearchQueryV2::ClearCaches()
|
||||
void ProcessorV2::ClearCaches()
|
||||
{
|
||||
Query::ClearCaches();
|
||||
Processor::ClearCaches();
|
||||
m_geocoder.ClearCaches();
|
||||
}
|
||||
} // namespace v2
|
|
@ -1,17 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include "search/search_query.hpp"
|
||||
#include "search/processor.hpp"
|
||||
#include "search/v2/geocoder.hpp"
|
||||
|
||||
namespace search
|
||||
{
|
||||
namespace v2
|
||||
{
|
||||
class SearchQueryV2 : public Query
|
||||
class ProcessorV2 : public Processor
|
||||
{
|
||||
public:
|
||||
SearchQueryV2(Index & index, CategoriesHolder const & categories,
|
||||
vector<Suggest> const & suggests, storage::CountryInfoGetter const & infoGetter);
|
||||
ProcessorV2(Index & index, CategoriesHolder const & categories, vector<Suggest> const & suggests,
|
||||
storage::CountryInfoGetter const & infoGetter);
|
||||
|
||||
// my::Cancellable overrides:
|
||||
void Reset() override;
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "search/search_query_params.hpp"
|
||||
#include "search/query_params.hpp"
|
||||
#include "search/v2/geocoder.hpp"
|
||||
#include "search/v2/search_model.hpp"
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
|||
|
||||
namespace search
|
||||
{
|
||||
struct SearchQueryParams;
|
||||
struct QueryParams;
|
||||
|
||||
namespace v2
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@ string SliceToString(string const & name, TSlice const & slice)
|
|||
}
|
||||
} // namespace
|
||||
|
||||
TokenSlice::TokenSlice(SearchQueryParams const & params, size_t startToken, size_t endToken)
|
||||
TokenSlice::TokenSlice(QueryParams const & params, size_t startToken, size_t endToken)
|
||||
: m_params(params), m_offset(startToken), m_size(endToken - startToken)
|
||||
{
|
||||
ASSERT_LESS_OR_EQUAL(startToken, endToken, ());
|
||||
|
@ -44,7 +44,7 @@ bool TokenSlice::IsLast(size_t i) const
|
|||
return m_offset + i == m_params.m_tokens.size();
|
||||
}
|
||||
|
||||
TokenSliceNoCategories::TokenSliceNoCategories(SearchQueryParams const & params, size_t startToken,
|
||||
TokenSliceNoCategories::TokenSliceNoCategories(QueryParams const & params, size_t startToken,
|
||||
size_t endToken)
|
||||
: m_params(params)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "search/search_query_params.hpp"
|
||||
#include "search/query_params.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
|
@ -15,9 +15,9 @@ namespace v2
|
|||
class TokenSlice
|
||||
{
|
||||
public:
|
||||
TokenSlice(SearchQueryParams const & params, size_t startToken, size_t endToken);
|
||||
TokenSlice(QueryParams const & params, size_t startToken, size_t endToken);
|
||||
|
||||
inline SearchQueryParams::TSynonymsVector const & Get(size_t i) const
|
||||
inline QueryParams::TSynonymsVector const & Get(size_t i) const
|
||||
{
|
||||
ASSERT_LESS(i, Size(), ());
|
||||
return m_params.GetTokens(m_offset + i);
|
||||
|
@ -36,7 +36,7 @@ public:
|
|||
bool IsLast(size_t i) const;
|
||||
|
||||
private:
|
||||
SearchQueryParams const & m_params;
|
||||
QueryParams const & m_params;
|
||||
size_t const m_offset;
|
||||
size_t const m_size;
|
||||
};
|
||||
|
@ -44,9 +44,9 @@ private:
|
|||
class TokenSliceNoCategories
|
||||
{
|
||||
public:
|
||||
TokenSliceNoCategories(SearchQueryParams const & params, size_t startToken, size_t endToken);
|
||||
TokenSliceNoCategories(QueryParams const & params, size_t startToken, size_t endToken);
|
||||
|
||||
inline SearchQueryParams::TSynonymsVector const & Get(size_t i) const
|
||||
inline QueryParams::TSynonymsVector const & Get(size_t i) const
|
||||
{
|
||||
ASSERT_LESS(i, Size(), ());
|
||||
return m_params.GetTokens(m_indexes[i]);
|
||||
|
@ -63,14 +63,14 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
SearchQueryParams const & m_params;
|
||||
QueryParams const & m_params;
|
||||
vector<size_t> m_indexes;
|
||||
};
|
||||
|
||||
class QuerySlice
|
||||
{
|
||||
public:
|
||||
using TString = SearchQueryParams::TString;
|
||||
using TString = QueryParams::TString;
|
||||
|
||||
virtual ~QuerySlice() = default;
|
||||
|
||||
|
@ -87,7 +87,7 @@ public:
|
|||
QuerySliceOnTokens(TokenSlice const & slice) : m_slice(slice) {}
|
||||
|
||||
// QuerySlice overrides:
|
||||
SearchQueryParams::TString const & Get(size_t i) const override { return m_slice.Get(i).front(); }
|
||||
QueryParams::TString const & Get(size_t i) const override { return m_slice.Get(i).front(); }
|
||||
size_t Size() const override { return m_slice.Size(); }
|
||||
bool IsPrefix(size_t i) const override { return m_slice.IsPrefix(i); }
|
||||
|
||||
|
@ -105,7 +105,7 @@ public:
|
|||
}
|
||||
|
||||
// QuerySlice overrides:
|
||||
SearchQueryParams::TString const & Get(size_t i) const override
|
||||
QueryParams::TString const & Get(size_t i) const override
|
||||
{
|
||||
ASSERT_LESS(i, Size(), ());
|
||||
return i == m_tokens.size() ? m_prefix : m_tokens[i];
|
||||
|
|
Loading…
Add table
Reference in a new issue