diff --git a/search/v2/cbv_ptr.cpp b/search/cbv_ptr.cpp similarity index 82% rename from search/v2/cbv_ptr.cpp rename to search/cbv_ptr.cpp index 405db9c5b3..7bdf63e64a 100644 --- a/search/v2/cbv_ptr.cpp +++ b/search/cbv_ptr.cpp @@ -1,14 +1,8 @@ -#include "search/v2/cbv_ptr.hpp" - +#include "search/cbv_ptr.hpp" namespace search { -namespace v2 -{ -CBVPtr::CBVPtr(coding::CompressedBitVector const * p, bool isOwner) -{ - Set(p, isOwner); -} +CBVPtr::CBVPtr(coding::CompressedBitVector const * p, bool isOwner) { Set(p, isOwner); } void CBVPtr::Release() { @@ -20,7 +14,7 @@ void CBVPtr::Release() m_isFull = false; } -void CBVPtr::Set(coding::CompressedBitVector const * p, bool isOwner/* = false*/) +void CBVPtr::Set(coding::CompressedBitVector const * p, bool isOwner /* = false*/) { Release(); @@ -68,10 +62,6 @@ void CBVPtr::Intersect(coding::CompressedBitVector const * p) } } -bool CBVPtr::IsEmpty() const -{ - return !m_isFull && coding::CompressedBitVector::IsEmpty(m_ptr); -} +bool CBVPtr::IsEmpty() const { return !m_isFull && coding::CompressedBitVector::IsEmpty(m_ptr); } -} // namespace v2 } // namespace search diff --git a/search/v2/cbv_ptr.hpp b/search/cbv_ptr.hpp similarity index 97% rename from search/v2/cbv_ptr.hpp rename to search/cbv_ptr.hpp index 55e7da2734..3c9cd68fd8 100644 --- a/search/v2/cbv_ptr.hpp +++ b/search/cbv_ptr.hpp @@ -8,11 +8,8 @@ #include "std/function.hpp" #include "std/utility.hpp" - namespace search { -namespace v2 -{ /// CompressedBitVector pointer class that incapsulates /// binary operators logic and takes ownership if needed. class CBVPtr @@ -57,5 +54,5 @@ public: coding::CompressedBitVectorEnumerator::ForEach(*m_ptr, forward(fn)); } }; -} // namespace v2 + } // namespace search diff --git a/search/feature_offset_match.hpp b/search/feature_offset_match.hpp index 075c51a37c..9ce4023339 100644 --- a/search/feature_offset_match.hpp +++ b/search/feature_offset_match.hpp @@ -3,7 +3,7 @@ #include "search/query_params.hpp" #include "search/search_common.hpp" #include "search/search_index_values.hpp" -#include "search/v2/token_slice.hpp" +#include "search/token_slice.hpp" #include "indexer/trie.hpp" @@ -445,7 +445,7 @@ void MatchFeaturesInTrie(QueryParams const & params, } template -void MatchPostcodesInTrie(v2::TokenSlice const & slice, +void MatchPostcodesInTrie(TokenSlice const & slice, trie::Iterator> const & trieRoot, TFilter const & filter, ToDo && toDo) { diff --git a/search/v2/features_filter.cpp b/search/features_filter.cpp similarity index 95% rename from search/v2/features_filter.cpp rename to search/features_filter.cpp index ffe474494e..0f9912ad07 100644 --- a/search/v2/features_filter.cpp +++ b/search/features_filter.cpp @@ -1,4 +1,4 @@ -#include "search/v2/features_filter.hpp" +#include "search/features_filter.hpp" #include "coding/compressed_bit_vector.hpp" @@ -6,8 +6,6 @@ namespace search { -namespace v2 -{ // FeaturesFilter ---------------------------------------------------------------------------------- FeaturesFilter::FeaturesFilter(coding::CompressedBitVector const & filter, uint32_t threshold) : m_filter(filter), m_threshold(threshold) @@ -45,5 +43,5 @@ unique_ptr ViewportFilter::Filter( return result; return cbv.LeaveFirstSetNBits(m_threshold); } -} // namespace v2 + } // namespace search diff --git a/search/v2/features_filter.hpp b/search/features_filter.hpp similarity index 97% rename from search/v2/features_filter.hpp rename to search/features_filter.hpp index f84ca3a7bf..fb5f425c3c 100644 --- a/search/v2/features_filter.hpp +++ b/search/features_filter.hpp @@ -9,8 +9,6 @@ class CompressedBitVector; namespace search { -namespace v2 -{ // A lightweight filter of features. // // NOTE: this class and its subclasses *ARE* thread-safe. @@ -57,5 +55,5 @@ public: unique_ptr Filter( coding::CompressedBitVector const & cbv) const override; }; -} // namespace v2 + } // namespace search diff --git a/search/v2/features_layer.cpp b/search/features_layer.cpp similarity index 92% rename from search/v2/features_layer.cpp rename to search/features_layer.cpp index 80ceabe2cc..e3c077db77 100644 --- a/search/v2/features_layer.cpp +++ b/search/features_layer.cpp @@ -1,4 +1,4 @@ -#include "search/v2/features_layer.hpp" +#include "search/features_layer.hpp" #include "base/internal/message.hpp" @@ -6,8 +6,6 @@ namespace search { -namespace v2 -{ FeaturesLayer::FeaturesLayer() { Clear(); } void FeaturesLayer::Clear() @@ -31,5 +29,5 @@ string DebugPrint(FeaturesLayer const & layer) << ", m_lastTokenIsPrefix: " << layer.m_lastTokenIsPrefix << " ]"; return os.str(); } -} // namespace v2 + } // namespace search diff --git a/search/v2/features_layer.hpp b/search/features_layer.hpp similarity index 93% rename from search/v2/features_layer.hpp rename to search/features_layer.hpp index 78a48ae927..b3ec6bb467 100644 --- a/search/v2/features_layer.hpp +++ b/search/features_layer.hpp @@ -1,6 +1,6 @@ #pragma once -#include "search/v2/search_model.hpp" +#include "search/search_model.hpp" #include "base/string_utils.hpp" @@ -8,8 +8,6 @@ namespace search { -namespace v2 -{ // This structure represents a part of search query interpretation - // when to a substring of tokens [m_startToken, m_endToken) is matched // with a set of m_features of the same m_type. @@ -41,5 +39,5 @@ struct FeaturesLayer }; string DebugPrint(FeaturesLayer const & layer); -} // namespace v2 + } // namespace search diff --git a/search/v2/features_layer_matcher.cpp b/search/features_layer_matcher.cpp similarity index 80% rename from search/v2/features_layer_matcher.cpp rename to search/features_layer_matcher.cpp index e3134e838f..1f98b22ffb 100644 --- a/search/v2/features_layer_matcher.cpp +++ b/search/features_layer_matcher.cpp @@ -1,7 +1,7 @@ -#include "search/v2/features_layer_matcher.hpp" +#include "search/features_layer_matcher.hpp" +#include "search/house_to_street_table.hpp" #include "search/reverse_geocoder.hpp" -#include "search/v2/house_to_street_table.hpp" #include "indexer/scales.hpp" @@ -9,9 +9,6 @@ namespace search { -namespace v2 -{ - /// Max distance from house to street where we do search matching /// even if there is no exact street written for this house. int constexpr kMaxApproxStreetDistanceM = 100; @@ -60,21 +57,20 @@ uint32_t FeaturesLayerMatcher::GetMatchingStreet(uint32_t houseId, FeatureType & return GetMatchingStreetImpl(houseId, houseFeature); } -FeaturesLayerMatcher::TStreets const & -FeaturesLayerMatcher::GetNearbyStreets(uint32_t featureId) +FeaturesLayerMatcher::TStreets const & FeaturesLayerMatcher::GetNearbyStreets(uint32_t featureId) { FeatureType feature; return GetNearbyStreetsImpl(featureId, feature); } -FeaturesLayerMatcher::TStreets const & -FeaturesLayerMatcher::GetNearbyStreets(uint32_t featureId, FeatureType & feature) +FeaturesLayerMatcher::TStreets const & FeaturesLayerMatcher::GetNearbyStreets(uint32_t featureId, + FeatureType & feature) { return GetNearbyStreetsImpl(featureId, feature); } -FeaturesLayerMatcher::TStreets const & -FeaturesLayerMatcher::GetNearbyStreetsImpl(uint32_t featureId, FeatureType & feature) +FeaturesLayerMatcher::TStreets const & FeaturesLayerMatcher::GetNearbyStreetsImpl( + uint32_t featureId, FeatureType & feature) { auto entry = m_nearbyStreetsCache.Get(featureId); if (!entry.second) @@ -101,7 +97,8 @@ uint32_t FeaturesLayerMatcher::GetMatchingStreetImpl(uint32_t houseId, FeatureTy { // Check if this feature is modified - the logic will be different. string streetName; - bool const edited = osm::Editor::Instance().GetEditedFeatureStreet(houseFeature.GetID(), streetName); + bool const edited = + osm::Editor::Instance().GetEditedFeatureStreet(houseFeature.GetID(), streetName); // Check the cached result value. auto entry = m_matchingStreetsCache.Get(houseId); @@ -120,9 +117,9 @@ uint32_t FeaturesLayerMatcher::GetMatchingStreetImpl(uint32_t houseId, FeatureTy if (edited) { auto const ret = find_if(streets.begin(), streets.end(), [&streetName](TStreet const & st) - { - return st.m_name == streetName; - }); + { + return st.m_name == streetName; + }); if (ret != streets.end()) result = ret->m_id.m_index; } @@ -134,8 +131,7 @@ uint32_t FeaturesLayerMatcher::GetMatchingStreetImpl(uint32_t houseId, FeatureTy } // If there is no saved street for feature, assume that it's a nearest street if it's too close. - if (result == kInvalidId && - !streets.empty() && + if (result == kInvalidId && !streets.empty() && streets[0].m_distanceMeters < kMaxApproxStreetDistanceM) { result = streets[0].m_id.m_index; @@ -144,5 +140,4 @@ uint32_t FeaturesLayerMatcher::GetMatchingStreetImpl(uint32_t houseId, FeatureTy return result; } -} // namespace v2 } // namespace search diff --git a/search/v2/features_layer_matcher.hpp b/search/features_layer_matcher.hpp similarity index 92% rename from search/v2/features_layer_matcher.hpp rename to search/features_layer_matcher.hpp index 39e505a7ce..8b18e1484c 100644 --- a/search/v2/features_layer_matcher.hpp +++ b/search/features_layer_matcher.hpp @@ -1,12 +1,12 @@ #pragma once #include "search/cancel_exception.hpp" +#include "search/features_layer.hpp" +#include "search/house_numbers_matcher.hpp" +#include "search/mwm_context.hpp" #include "search/reverse_geocoder.hpp" -#include "search/v2/features_layer.hpp" -#include "search/v2/house_numbers_matcher.hpp" -#include "search/v2/mwm_context.hpp" -#include "search/v2/search_model.hpp" -#include "search/v2/street_vicinity_loader.hpp" +#include "search/search_model.hpp" +#include "search/street_vicinity_loader.hpp" #include "indexer/feature.hpp" #include "indexer/feature_algo.hpp" @@ -37,8 +37,6 @@ class Index; namespace search { -namespace v2 -{ // This class performs pairwise intersection between two layers of // features, where the first (child) layer is geographically smaller // than the second (parent) one. It emits all pairs @@ -87,7 +85,7 @@ public: break; case SearchModel::SEARCH_TYPE_STREET: ASSERT(child.m_type == SearchModel::SEARCH_TYPE_POI || - child.m_type == SearchModel::SEARCH_TYPE_BUILDING, + child.m_type == SearchModel::SEARCH_TYPE_BUILDING, ("Invalid child layer type:", child.m_type)); if (child.m_type == SearchModel::SEARCH_TYPE_POI) MatchPOIsWithStreets(child, parent, forward(fn)); @@ -164,18 +162,19 @@ private: for (size_t i = 0; i < pois.size(); ++i) { m_context->ForEachFeature( - MercatorBounds::RectByCenterXYAndSizeInMeters(poiCenters[i], kBuildingRadiusMeters), - [&](FeatureType & ft) + MercatorBounds::RectByCenterXYAndSizeInMeters(poiCenters[i], kBuildingRadiusMeters), + [&](FeatureType & ft) + { + if (m_postcodes && !m_postcodes->GetBit(ft.GetID().m_index)) + return; + if (HouseNumbersMatch(strings::MakeUniString(ft.GetHouseNumber()), queryParses)) { - if (m_postcodes && !m_postcodes->GetBit(ft.GetID().m_index)) - return; - if (HouseNumbersMatch(strings::MakeUniString(ft.GetHouseNumber()), queryParses)) - { - double const distanceM = MercatorBounds::DistanceOnEarth(feature::GetCenter(ft), poiCenters[i]); - if (distanceM < kBuildingRadiusMeters) - fn(pois[i], ft.GetID().m_index); - } - }); + double const distanceM = + MercatorBounds::DistanceOnEarth(feature::GetCenter(ft), poiCenters[i]); + if (distanceM < kBuildingRadiusMeters) + fn(pois[i], ft.GetID().m_index); + } + }); } } @@ -210,8 +209,7 @@ private: for (uint32_t streetId : streets) { BailIfCancelled(m_cancellable); - m_loader.ForEachInVicinity(streetId, pois, kStreetRadiusMeters, - bind(fn, _1, streetId)); + m_loader.ForEachInVicinity(streetId, pois, kStreetRadiusMeters, bind(fn, _1, streetId)); } } @@ -345,7 +343,8 @@ private: /// TODO(vng): GetFeature below can return false if feature was deleted by user in the Editor. /// This code should be fixed to take that into an account. /// Until we don't show "Delete" button to our users, this code will work correctly. - /// Correct fix would be injection into ForEachInIntervalAndScale, so deleted features will never + /// Correct fix would be injection into ForEachInIntervalAndScale, so deleted features will + /// never /// be emitted and used in other code. UNUSED_VALUE(m_context->GetFeature(id, ft)); } @@ -368,5 +367,5 @@ private: StreetVicinityLoader m_loader; my::Cancellable const & m_cancellable; }; -} // namespace v2 + } // namespace search diff --git a/search/v2/features_layer_path_finder.cpp b/search/features_layer_path_finder.cpp similarity index 96% rename from search/v2/features_layer_path_finder.cpp rename to search/features_layer_path_finder.cpp index 0f5ca4e91b..91db4ef27f 100644 --- a/search/v2/features_layer_path_finder.cpp +++ b/search/features_layer_path_finder.cpp @@ -1,8 +1,8 @@ -#include "search/v2/features_layer_path_finder.hpp" +#include "search/features_layer_path_finder.hpp" #include "search/cancel_exception.hpp" -#include "search/v2/features_layer_matcher.hpp" -#include "search/v2/house_numbers_matcher.hpp" +#include "search/features_layer_matcher.hpp" +#include "search/house_numbers_matcher.hpp" #include "indexer/features_vector.hpp" @@ -10,8 +10,6 @@ namespace search { -namespace v2 -{ namespace { using TParentGraph = unordered_map; @@ -194,5 +192,5 @@ void FeaturesLayerPathFinder::FindReachableVerticesBottomUp( results.push_back(result); } } -} // namespace v2 + } // namespace search diff --git a/search/v2/features_layer_path_finder.hpp b/search/features_layer_path_finder.hpp similarity index 89% rename from search/v2/features_layer_path_finder.hpp rename to search/features_layer_path_finder.hpp index 04684c5ca8..ce58dc1e73 100644 --- a/search/v2/features_layer_path_finder.hpp +++ b/search/features_layer_path_finder.hpp @@ -1,7 +1,7 @@ #pragma once -#include "search/v2/features_layer.hpp" -#include "search/v2/intersection_result.hpp" +#include "search/features_layer.hpp" +#include "search/intersection_result.hpp" #include "std/vector.hpp" @@ -20,8 +20,6 @@ class Cancellable; namespace search { -namespace v2 -{ class FeaturesLayerMatcher; // This class is able to find all paths through a layered graph, with @@ -45,9 +43,9 @@ public: if (layers.empty()) return; - // TODO (@y): remove following code as soon as - // FindReachableVertices() will work fast for most cases - // (significantly less than 1 second). +// TODO (@y): remove following code as soon as +// FindReachableVertices() will work fast for most cases +// (significantly less than 1 second). #if defined(DEBUG) for (auto const * layer : layers) LOG(LINFO, (DebugPrint(*layer))); @@ -83,5 +81,5 @@ private: my::Cancellable const & m_cancellable; }; -} // namespace v2 + } // namespace search diff --git a/search/v2/geocoder.cpp b/search/geocoder.cpp similarity index 92% rename from search/v2/geocoder.cpp rename to search/geocoder.cpp index a08cac2575..0c50de6cc4 100644 --- a/search/v2/geocoder.cpp +++ b/search/geocoder.cpp @@ -1,13 +1,13 @@ -#include "search/v2/geocoder.hpp" +#include "search/geocoder.hpp" +#include "search/cbv_ptr.hpp" #include "search/dummy_rank_table.hpp" +#include "search/features_filter.hpp" +#include "search/features_layer_matcher.hpp" +#include "search/locality_scorer.hpp" #include "search/processor.hpp" #include "search/retrieval.hpp" -#include "search/v2/cbv_ptr.hpp" -#include "search/v2/features_filter.hpp" -#include "search/v2/features_layer_matcher.hpp" -#include "search/v2/locality_scorer.hpp" -#include "search/v2/token_slice.hpp" +#include "search/token_slice.hpp" #include "indexer/classificator.hpp" #include "indexer/feature_decl.hpp" @@ -53,8 +53,6 @@ namespace search { -namespace v2 -{ namespace { size_t constexpr kMaxNumCities = 5; @@ -99,7 +97,7 @@ struct ScopedMarkTokens class LazyRankTable : public RankTable { - public: +public: LazyRankTable(MwmValue const & value) : m_value(value) {} uint8_t Get(uint64_t i) const override @@ -126,15 +124,15 @@ class LazyRankTable : public RankTable m_table->Serialize(writer, preserveHostEndiannes); } - private: - void EnsureTableLoaded() const - { - if (m_table) - return; - m_table = search::RankTable::Load(m_value.m_cont); - if (!m_table) - m_table = make_unique(); - } +private: + void EnsureTableLoaded() const + { + if (m_table) + return; + m_table = search::RankTable::Load(m_value.m_cont); + if (!m_table) + m_table = make_unique(); + } MwmValue const & m_value; mutable unique_ptr m_table; @@ -272,16 +270,13 @@ MwmSet::MwmHandle FindWorld(Index & index, vector> const & i return handle; } -strings::UniString AsciiToUniString(char const * s) -{ - return strings::UniString(s, s + strlen(s)); -} +strings::UniString AsciiToUniString(char const * s) { return strings::UniString(s, s + strlen(s)); } bool IsStopWord(strings::UniString const & s) { /// @todo Get all common used stop words and factor out this array into /// search_string_utils.cpp module for example. - static char const * arr[] = { "a", "de", "da", "la" }; + static char const * arr[] = {"a", "de", "da", "la"}; static set const kStopWords( make_transform_iterator(arr, &AsciiToUniString), @@ -290,10 +285,7 @@ bool IsStopWord(strings::UniString const & s) return kStopWords.count(s) > 0; } -double Area(m2::RectD const & rect) -{ - return rect.IsValid() ? rect.SizeX() * rect.SizeY() : 0; -} +double Area(m2::RectD const & rect) { return rect.IsValid() ? rect.SizeX() * rect.SizeY() : 0; } // Computes an average similaty between |rect| and |pivot|. By // similarity between two rects we mean a fraction of the area of @@ -477,8 +469,8 @@ void Geocoder::SetParams(Params const & params) void Geocoder::GoEverywhere(PreRanker & preRanker) { - // TODO (@y): remove following code as soon as Geocoder::Go() will - // work fast for most cases (significantly less than 1 second). +// TODO (@y): remove following code as soon as Geocoder::Go() will +// work fast for most cases (significantly less than 1 second). #if defined(DEBUG) my::Timer timer; MY_SCOPE_GUARD(printDuration, [&timer]() @@ -509,9 +501,9 @@ void Geocoder::GoInViewport(PreRanker & preRanker) m_index.GetMwmsInfo(infos); my::EraseIf(infos, [this](shared_ptr const & info) - { - return !m_params.m_pivot.IsIntersect(info->m_limitRect); - }); + { + return !m_params.m_pivot.IsIntersect(info->m_limitRect); + }); GoImpl(preRanker, infos, true /* inViewport */); } @@ -560,7 +552,7 @@ void Geocoder::GoImpl(PreRanker & preRanker, vector> & infos // MatchAroundPivot() should always be matched in mwms // intersecting with position and viewport. - auto const & cancellable = static_cast(*this); + auto const & cancellable = static_cast(*this); auto processCountry = [&](size_t index, unique_ptr context) { ASSERT(context, ()); @@ -580,7 +572,8 @@ void Geocoder::GoImpl(PreRanker & preRanker, vector> & infos if (it == m_matchersCache.end()) { it = m_matchersCache.insert(make_pair(m_context->GetId(), make_unique( - m_index, cancellable))).first; + m_index, cancellable))) + .first; } m_matcher = it->second.get(); m_matcher->SetContext(m_context.get()); @@ -672,9 +665,9 @@ void Geocoder::PrepareAddressFeatures() for (size_t i = 0; i < m_numTokens; ++i) { PrepareRetrievalParams(i, i + 1); - m_addressFeatures[i] = RetrieveAddressFeatures( - m_context->GetId(), m_context->m_value, static_cast(*this), - m_retrievalParams); + m_addressFeatures[i] = + RetrieveAddressFeatures(m_context->GetId(), m_context->m_value, + static_cast(*this), m_retrievalParams); ASSERT(m_addressFeatures[i], ()); } } @@ -805,8 +798,7 @@ void Geocoder::FillLocalitiesTable() addRegionMaps(numCountries, kMaxNumCountries, REGION_TYPE_COUNTRY); break; } - default: - break; + default: break; } } } @@ -871,19 +863,17 @@ void Geocoder::MatchRegions(RegionType type) { switch (type) { - case REGION_TYPE_STATE: - // Tries to skip state matching and go to cities matching. - // Then, performs states matching. - MatchCities(); - break; - case REGION_TYPE_COUNTRY: - // Tries to skip country matching and go to states matching. - // Then, performs countries matching. - MatchRegions(REGION_TYPE_STATE); - break; - case REGION_TYPE_COUNT: - ASSERT(false, ("Invalid region type.")); - return; + case REGION_TYPE_STATE: + // Tries to skip state matching and go to cities matching. + // Then, performs states matching. + MatchCities(); + break; + case REGION_TYPE_COUNTRY: + // Tries to skip country matching and go to states matching. + // Then, performs countries matching. + MatchRegions(REGION_TYPE_STATE); + break; + case REGION_TYPE_COUNT: ASSERT(false, ("Invalid region type.")); return; } auto const & regions = m_regions[type]; @@ -931,18 +921,15 @@ void Geocoder::MatchRegions(RegionType type) } m_lastMatchedRegion = ®ion; - MY_SCOPE_GUARD(cleanup, [this]() { m_lastMatchedRegion = nullptr; }); + MY_SCOPE_GUARD(cleanup, [this]() + { + m_lastMatchedRegion = nullptr; + }); switch (type) { - case REGION_TYPE_STATE: - MatchCities(); - break; - case REGION_TYPE_COUNTRY: - MatchRegions(REGION_TYPE_STATE); - break; - case REGION_TYPE_COUNT: - ASSERT(false, ("Invalid region type.")); - break; + case REGION_TYPE_STATE: MatchCities(); break; + case REGION_TYPE_COUNTRY: MatchRegions(REGION_TYPE_STATE); break; + case REGION_TYPE_COUNT: ASSERT(false, ("Invalid region type.")); break; } } } @@ -1006,7 +993,10 @@ void Geocoder::MatchAroundPivot() void Geocoder::LimitedSearch(FeaturesFilter const & filter) { m_filter = &filter; - MY_SCOPE_GUARD(resetFilter, [&]() { m_filter = nullptr; }); + MY_SCOPE_GUARD(resetFilter, [&]() + { + m_filter = nullptr; + }); if (!m_streets) m_streets = LoadStreets(*m_context); @@ -1046,7 +1036,10 @@ void Geocoder::WithPostcodes(TFn && fn) auto postcodes = RetrievePostcodeFeatures(*m_context, TokenSlice(m_params, startToken, endToken)); - MY_SCOPE_GUARD(cleanup, [&]() { m_postcodes.Clear(); }); + MY_SCOPE_GUARD(cleanup, [&]() + { + m_postcodes.Clear(); + }); if (!coding::CompressedBitVector::IsEmpty(postcodes)) { @@ -1263,20 +1256,20 @@ void Geocoder::MatchPOIsAndBuildings(size_t curToken) for (size_t i = 0; i < kNumClusters; ++i) ends[i] = clusters[i].size(); filtered.ForEach([&](uint32_t featureId) - { - bool found = false; - for (size_t i = 0; i < kNumClusters && !found; ++i) - { - size_t & cur = curs[i]; - size_t const end = ends[i]; - while (cur != end && clusters[i][cur] < featureId) - ++cur; - if (cur != end && clusters[i][cur] == featureId) - found = true; - } - if (!found) - clusterize(featureId); - }); + { + bool found = false; + for (size_t i = 0; i < kNumClusters && !found; ++i) + { + size_t & cur = curs[i]; + size_t const end = ends[i]; + while (cur != end && clusters[i][cur] < featureId) + ++cur; + if (cur != end && clusters[i][cur] == featureId) + found = true; + } + if (!found) + clusterize(featureId); + }); for (size_t i = 0; i < kNumClusters; ++i) inplace_merge(clusters[i].begin(), clusters[i].begin() + ends[i], clusters[i].end()); } @@ -1366,15 +1359,15 @@ void Geocoder::FindPaths() auto const & innermostLayer = *sortedLayers.front(); m_matcher->SetPostcodes(m_postcodes.m_features.get()); - m_finder.ForEachReachableVertex(*m_matcher, sortedLayers, - [this, &innermostLayer](IntersectionResult const & result) - { - ASSERT(result.IsValid(), ()); - // TODO(@y, @m, @vng): use rest fields of IntersectionResult for - // better scoring. - EmitResult(m_context->GetId(), result.InnermostResult(), innermostLayer.m_type, - innermostLayer.m_startToken, innermostLayer.m_endToken); - }); + m_finder.ForEachReachableVertex( + *m_matcher, sortedLayers, [this, &innermostLayer](IntersectionResult const & result) + { + ASSERT(result.IsValid(), ()); + // TODO(@y, @m, @vng): use rest fields of IntersectionResult for + // better scoring. + EmitResult(m_context->GetId(), result.InnermostResult(), innermostLayer.m_type, + innermostLayer.m_startToken, innermostLayer.m_endToken); + }); } void Geocoder::EmitResult(MwmSet::MwmId const & mwmId, uint32_t ftId, SearchModel::SearchType type, @@ -1425,7 +1418,8 @@ void Geocoder::FillMissingFieldsInResults() mwmId = id.m_mwmId; mwmHandle = m_index.GetMwmHandleById(mwmId); if (mwmHandle.IsAlive()) - rankTable = RankTable::Load(mwmHandle.GetValue()->m_cont); + rankTable = + RankTable::Load(mwmHandle.GetValue()->m_cont); else rankTable = make_unique(); } @@ -1498,9 +1492,9 @@ unique_ptr Geocoder::LoadCategories( for_each(categories.begin(), categories.end(), [&](strings::UniString const & category) { m_retrievalParams.m_tokens[0][0] = category; - auto cbv = RetrieveAddressFeatures( - context.GetId(), context.m_value, static_cast(*this), - m_retrievalParams); + auto cbv = RetrieveAddressFeatures(context.GetId(), context.m_value, + static_cast(*this), + m_retrievalParams); if (!coding::CompressedBitVector::IsEmpty(cbv)) cbvs.push_back(move(cbv)); }); @@ -1540,8 +1534,8 @@ unique_ptr Geocoder::LoadVillages(MwmContext & cont unique_ptr Geocoder::RetrievePostcodeFeatures( MwmContext const & context, TokenSlice const & slice) { - return ::search::v2::RetrievePostcodeFeatures(context.GetId(), context.m_value, - static_cast(*this), slice); + return ::search::RetrievePostcodeFeatures(context.GetId(), context.m_value, + static_cast(*this), slice); } coding::CompressedBitVector const * Geocoder::RetrieveGeometryFeatures(MwmContext const & context, @@ -1603,5 +1597,5 @@ string DebugPrint(Geocoder::Locality const & locality) << ", startToken=" << locality.m_startToken << ", endToken=" << locality.m_endToken << "]"; return os.str(); } -} // namespace v2 + } // namespace search diff --git a/search/v2/geocoder.hpp b/search/geocoder.hpp similarity index 96% rename from search/v2/geocoder.hpp rename to search/geocoder.hpp index bdc8ef0d52..13810f27f4 100644 --- a/search/v2/geocoder.hpp +++ b/search/geocoder.hpp @@ -1,16 +1,16 @@ #pragma once #include "search/cancel_exception.hpp" +#include "search/features_layer.hpp" +#include "search/features_layer_path_finder.hpp" +#include "search/geometry_cache.hpp" #include "search/mode.hpp" +#include "search/mwm_context.hpp" +#include "search/nested_rects_cache.hpp" +#include "search/pre_ranking_info.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" -#include "search/v2/mwm_context.hpp" -#include "search/v2/nested_rects_cache.hpp" -#include "search/v2/pre_ranking_info.hpp" -#include "search/v2/ranking_utils.hpp" -#include "search/v2/search_model.hpp" +#include "search/ranking_utils.hpp" +#include "search/search_model.hpp" #include "indexer/index.hpp" #include "indexer/mwm_set.hpp" @@ -50,8 +50,6 @@ namespace search { class PreRanker; -namespace v2 -{ class FeaturesFilter; class FeaturesLayerMatcher; class SearchModel; @@ -62,7 +60,7 @@ class TokenSlice; // (including synonyms for these tokens), and Geocoder tries to build // all possible partitions (or layers) of the search query, where each // layer is a set of features corresponding to some search class -// (e.g. POI, BUILDING, STREET, etc., see search/v2/search_model.hpp). +// (e.g. POI, BUILDING, STREET, etc., see search_model.hpp). // Then, Geocoder builds a layered graph, with edges between features // on adjacent layers (e.g. between BUILDING ans STREET, STREET and // CITY, etc.). Usually an edge between two features means that a @@ -233,7 +231,7 @@ private: // incorporated into |filter|. void LimitedSearch(FeaturesFilter const & filter); - template + template void WithPostcodes(TFn && fn); // Tries to match some adjacent tokens in the query as streets and @@ -388,5 +386,5 @@ private: }; string DebugPrint(Geocoder::Locality const & locality); -} // namespace v2 + } // namespace search diff --git a/search/v2/geometry_cache.cpp b/search/geometry_cache.cpp similarity index 78% rename from search/v2/geometry_cache.cpp rename to search/geometry_cache.cpp index 2884e76aa1..275c2ff875 100644 --- a/search/v2/geometry_cache.cpp +++ b/search/geometry_cache.cpp @@ -1,15 +1,13 @@ -#include "search/v2/geometry_cache.hpp" +#include "search/geometry_cache.hpp" #include "search/geometry_utils.hpp" +#include "search/mwm_context.hpp" #include "search/retrieval.hpp" -#include "search/v2/mwm_context.hpp" #include "geometry/mercator.hpp" namespace search { -namespace v2 -{ namespace { double constexpr kCellEps = MercatorBounds::GetCellID2PointAbsEpsilon(); @@ -26,7 +24,7 @@ void GeometryCache::InitEntry(MwmContext const & context, m2::RectD const & rect Entry & entry) { entry.m_rect = rect; - entry.m_cbv = v2::RetrieveGeometryFeatures(context, m_cancellable, rect, scale); + entry.m_cbv = RetrieveGeometryFeatures(context, m_cancellable, rect, scale); entry.m_scale = scale; } @@ -40,11 +38,12 @@ PivotRectsCache::PivotRectsCache(size_t maxNumEntries, my::Cancellable const & c coding::CompressedBitVector const * PivotRectsCache::Get(MwmContext const & context, m2::RectD const & rect, int scale) { - auto p = FindOrCreateEntry(context.GetId(), [&rect, &scale](Entry const & entry) - { - return scale == entry.m_scale && - (entry.m_rect.IsRectInside(rect) || IsEqualMercator(rect, entry.m_rect, kCellEps)); - }); + auto p = FindOrCreateEntry( + context.GetId(), [&rect, &scale](Entry const & entry) + { + return scale == entry.m_scale && + (entry.m_rect.IsRectInside(rect) || IsEqualMercator(rect, entry.m_rect, kCellEps)); + }); auto & entry = p.first; if (p.second) { @@ -67,13 +66,14 @@ coding::CompressedBitVector const * LocalityRectsCache::Get(MwmContext const & c m2::RectD const & rect, int scale) { auto p = FindOrCreateEntry(context.GetId(), [&rect, &scale](Entry const & entry) - { - return scale == entry.m_scale && IsEqualMercator(rect, entry.m_rect, kCellEps); - }); + { + return scale == entry.m_scale && + IsEqualMercator(rect, entry.m_rect, kCellEps); + }); auto & entry = p.first; if (p.second) InitEntry(context, rect, scale, entry); return entry.m_cbv.get(); } -} // namespace v2 + } // namespace search diff --git a/search/v2/geometry_cache.hpp b/search/geometry_cache.hpp similarity index 98% rename from search/v2/geometry_cache.hpp rename to search/geometry_cache.hpp index 62805918a5..d5d305301b 100644 --- a/search/v2/geometry_cache.hpp +++ b/search/geometry_cache.hpp @@ -22,8 +22,6 @@ class Cancellable; namespace search { -namespace v2 -{ class MwmContext; // This class represents a simple cache of features in rects for all mwms. @@ -105,5 +103,5 @@ public: coding::CompressedBitVector const * Get(MwmContext const & context, m2::RectD const & rect, int scale) override; }; -} // namespace v2 + } // namespace search diff --git a/search/v2/house_numbers_matcher.cpp b/search/house_numbers_matcher.cpp similarity index 99% rename from search/v2/house_numbers_matcher.cpp rename to search/house_numbers_matcher.cpp index 3acd0d6341..504b75d859 100644 --- a/search/v2/house_numbers_matcher.cpp +++ b/search/house_numbers_matcher.cpp @@ -1,4 +1,4 @@ -#include "search/v2/house_numbers_matcher.hpp" +#include "search/house_numbers_matcher.hpp" #include "std/algorithm.hpp" #include "std/iterator.hpp" @@ -11,8 +11,6 @@ using namespace strings; namespace search { -namespace v2 -{ namespace { size_t constexpr kInvalidNum = numeric_limits::max(); @@ -318,5 +316,5 @@ string DebugPrint(Parse const & parse) os << "Parse [" << DebugPrint(parse.m_parts) << "]"; return os.str(); } -} // namespace v2 + } // namespace search diff --git a/search/v2/house_numbers_matcher.hpp b/search/house_numbers_matcher.hpp similarity index 98% rename from search/v2/house_numbers_matcher.hpp rename to search/house_numbers_matcher.hpp index 53bf7d6bb7..72299a1777 100644 --- a/search/v2/house_numbers_matcher.hpp +++ b/search/house_numbers_matcher.hpp @@ -7,8 +7,6 @@ namespace search { -namespace v2 -{ // This class splits a string representing a house number to groups of // symbols from the same class (separators, digits or other symbols, // hope, letters). @@ -62,5 +60,5 @@ string DebugPrint(HouseNumberTokenizer::CharClass charClass); string DebugPrint(HouseNumberTokenizer::Token const & token); string DebugPrint(Parse const & parse); -} // namespace v2 + } // namespace search diff --git a/search/v2/house_to_street_table.cpp b/search/house_to_street_table.cpp similarity index 94% rename from search/v2/house_to_street_table.cpp rename to search/house_to_street_table.cpp index 8c15dc59f3..6321b0c636 100644 --- a/search/v2/house_to_street_table.cpp +++ b/search/house_to_street_table.cpp @@ -1,4 +1,4 @@ -#include "search/v2/house_to_street_table.hpp" +#include "search/house_to_street_table.hpp" #include "indexer/index.hpp" @@ -13,8 +13,6 @@ namespace search { -namespace v2 -{ namespace { class Fixed3BitsTable : public HouseToStreetTable @@ -67,5 +65,5 @@ unique_ptr HouseToStreetTable::Load(MwmValue & value) result.reset(new DummyTable()); return result; } -} // namespace v2 + } // namespace search diff --git a/search/v2/house_to_street_table.hpp b/search/house_to_street_table.hpp similarity index 95% rename from search/v2/house_to_street_table.hpp rename to search/house_to_street_table.hpp index 4d991c70f1..f395e635ba 100644 --- a/search/v2/house_to_street_table.hpp +++ b/search/house_to_street_table.hpp @@ -7,8 +7,6 @@ class MwmValue; namespace search { -namespace v2 -{ class HouseToStreetTable { public: @@ -24,5 +22,5 @@ public: // street. virtual bool Get(uint32_t houseId, uint32_t & streetIndex) const = 0; }; -} // namespace v2 + } // namespace search diff --git a/search/intermediate_result.cpp b/search/intermediate_result.cpp index 3fd67841fb..5bf687a96a 100644 --- a/search/intermediate_result.cpp +++ b/search/intermediate_result.cpp @@ -60,8 +60,7 @@ void ProcessMetadata(FeatureType const & ft, Result::Metadata & meta) namespace impl { -PreResult1::PreResult1(FeatureID const & fID, v2::PreRankingInfo const & info) - : m_id(fID), m_info(info) +PreResult1::PreResult1(FeatureID const & fID, PreRankingInfo const & info) : m_id(fID), m_info(info) { ASSERT(m_id.IsValid(), ()); } diff --git a/search/intermediate_result.hpp b/search/intermediate_result.hpp index 840b4db8ac..259abfbb67 100644 --- a/search/intermediate_result.hpp +++ b/search/intermediate_result.hpp @@ -1,9 +1,9 @@ #pragma once +#include "search/pre_ranking_info.hpp" +#include "search/ranking_info.hpp" +#include "search/ranking_utils.hpp" #include "search/result.hpp" -#include "search/v2/pre_ranking_info.hpp" -#include "search/v2/ranking_info.hpp" -#include "search/v2/ranking_utils.hpp" #include "indexer/feature_data.hpp" @@ -27,7 +27,7 @@ namespace impl class PreResult1 { public: - PreResult1(FeatureID const & fID, v2::PreRankingInfo const & info); + PreResult1(FeatureID const & fID, PreRankingInfo const & info); static bool LessRank(PreResult1 const & r1, PreResult1 const & r2); static bool LessDistance(PreResult1 const & r1, PreResult1 const & r2); @@ -35,14 +35,14 @@ public: inline FeatureID GetId() const { return m_id; } inline double GetDistance() const { return m_info.m_distanceToPivot; } inline uint8_t GetRank() const { return m_info.m_rank; } - inline v2::PreRankingInfo & GetInfo() { return m_info; } - inline v2::PreRankingInfo const & GetInfo() const { return m_info; } + inline PreRankingInfo & GetInfo() { return m_info; } + inline PreRankingInfo const & GetInfo() const { return m_info; } private: friend class PreResult2; FeatureID m_id; - v2::PreRankingInfo m_info; + PreRankingInfo m_info; }; /// Second result class. Objects are creating during reading of features. @@ -66,7 +66,7 @@ public: /// For RESULT_LATLON. PreResult2(double lat, double lon); - inline search::v2::RankingInfo const & GetRankingInfo() const { return m_info; } + inline search::RankingInfo const & GetRankingInfo() const { return m_info; } template inline void SetRankingInfo(TInfo && info) @@ -143,7 +143,7 @@ private: double m_distance; ResultType m_resultType; - v2::RankingInfo m_info; + RankingInfo m_info; feature::EGeomType m_geomType; Result::Metadata m_metadata; diff --git a/search/v2/intersection_result.cpp b/search/intersection_result.cpp similarity index 95% rename from search/v2/intersection_result.cpp rename to search/intersection_result.cpp index 0733ac2e26..72dd5bdff6 100644 --- a/search/v2/intersection_result.cpp +++ b/search/intersection_result.cpp @@ -1,12 +1,10 @@ -#include "search/v2/intersection_result.hpp" +#include "search/intersection_result.hpp" #include "std/limits.hpp" #include "std/sstream.hpp" namespace search { -namespace v2 -{ // static uint32_t const IntersectionResult::kInvalidId = numeric_limits::max(); @@ -62,5 +60,5 @@ string DebugPrint(IntersectionResult const & result) os << "]"; return os.str(); } -} // namespace v2 + } // namespace search diff --git a/search/v2/intersection_result.hpp b/search/intersection_result.hpp similarity index 91% rename from search/v2/intersection_result.hpp rename to search/intersection_result.hpp index 53f755c622..9285cbe5cd 100644 --- a/search/v2/intersection_result.hpp +++ b/search/intersection_result.hpp @@ -1,14 +1,12 @@ #pragma once -#include "search/v2/search_model.hpp" +#include "search/search_model.hpp" #include "std/cstdint.hpp" #include "std/string.hpp" namespace search { -namespace v2 -{ // This class holds higher-level features for an intersection result, // i.e. BUILDING and STREET for POI or STREET for BUILDING. struct IntersectionResult @@ -35,5 +33,5 @@ struct IntersectionResult }; string DebugPrint(IntersectionResult const & result); -} // namespace v2 + } // namespace search diff --git a/search/locality_finder.cpp b/search/locality_finder.cpp index 11c479a63c..4df74233d2 100644 --- a/search/locality_finder.cpp +++ b/search/locality_finder.cpp @@ -1,5 +1,6 @@ #include "search/locality_finder.hpp" -#include "search/v2/mwm_context.hpp" + +#include "search/mwm_context.hpp" #include "indexer/ftypes_matcher.hpp" @@ -126,7 +127,7 @@ void LocalityFinder::UpdateCache(Cache & cache, m2::PointD const & pt) const if (handle.IsAlive() && value->GetHeader().GetType() == feature::DataHeader::world) { cache.m_rect = rect; - v2::MwmContext(move(handle)).ForEachFeature(rect, DoLoader(*this, cache)); + MwmContext(move(handle)).ForEachFeature(rect, DoLoader(*this, cache)); break; } } diff --git a/search/v2/locality_scorer.cpp b/search/locality_scorer.cpp similarity index 66% rename from search/v2/locality_scorer.cpp rename to search/locality_scorer.cpp index e72ed54dfa..48eff3e136 100644 --- a/search/v2/locality_scorer.cpp +++ b/search/locality_scorer.cpp @@ -1,13 +1,11 @@ -#include "search/v2/locality_scorer.hpp" +#include "search/locality_scorer.hpp" -#include "search/v2/token_slice.hpp" +#include "search/token_slice.hpp" #include "std/algorithm.hpp" namespace search { -namespace v2 -{ // static size_t const LocalityScorer::kDefaultReadLimit = 100; @@ -101,39 +99,39 @@ void LocalityScorer::SortByName(vector & ls) const auto score = NAME_SCORE_ZERO; for (auto const & name : names) { - score = max(score, GetNameScore(name, v2::TokenSlice(m_params, l.m_locality.m_startToken, - l.m_locality.m_endToken))); + score = max(score, GetNameScore(name, TokenSlice(m_params, l.m_locality.m_startToken, + l.m_locality.m_endToken))); } l.m_nameScore = score; } sort(ls.begin(), ls.end(), [](ExLocality const & lhs, ExLocality const & rhs) - { - if (IsAlmostFullMatch(lhs.m_nameScore) && IsAlmostFullMatch(rhs.m_nameScore)) - { - // When both localities match well, e.g. full or full prefix - // match, the one with larger number of tokens is selected. In - // case of tie, the one with better score is selected. - if (lhs.m_numTokens != rhs.m_numTokens) - return lhs.m_numTokens > rhs.m_numTokens; - if (lhs.m_nameScore != rhs.m_nameScore) - return lhs.m_nameScore > rhs.m_nameScore; - } - else - { - // When name scores differ, the one with better name score is - // selected. In case of tie, the one with larger number of - // matched tokens is selected. - if (lhs.m_nameScore != rhs.m_nameScore) - return lhs.m_nameScore > rhs.m_nameScore; - if (lhs.m_numTokens != rhs.m_numTokens) - return lhs.m_numTokens > rhs.m_numTokens; - } + { + if (IsAlmostFullMatch(lhs.m_nameScore) && IsAlmostFullMatch(rhs.m_nameScore)) + { + // When both localities match well, e.g. full or full prefix + // match, the one with larger number of tokens is selected. In + // case of tie, the one with better score is selected. + if (lhs.m_numTokens != rhs.m_numTokens) + return lhs.m_numTokens > rhs.m_numTokens; + if (lhs.m_nameScore != rhs.m_nameScore) + return lhs.m_nameScore > rhs.m_nameScore; + } + else + { + // When name scores differ, the one with better name score is + // selected. In case of tie, the one with larger number of + // matched tokens is selected. + if (lhs.m_nameScore != rhs.m_nameScore) + return lhs.m_nameScore > rhs.m_nameScore; + if (lhs.m_numTokens != rhs.m_numTokens) + return lhs.m_numTokens > rhs.m_numTokens; + } - // Okay, in case of tie we select the one with better rank. This - // is a quite arbitrary decision and definitely may be improved. - return lhs.m_rank > rhs.m_rank; - }); + // Okay, in case of tie we select the one with better rank. This + // is a quite arbitrary decision and definitely may be improved. + return lhs.m_rank > rhs.m_rank; + }); } -} // namespace v2 + } // namespace search diff --git a/search/v2/locality_scorer.hpp b/search/locality_scorer.hpp similarity index 92% rename from search/v2/locality_scorer.hpp rename to search/locality_scorer.hpp index d65a82edac..102350d0ee 100644 --- a/search/v2/locality_scorer.hpp +++ b/search/locality_scorer.hpp @@ -1,7 +1,7 @@ #pragma once -#include "search/v2/geocoder.hpp" -#include "search/v2/ranking_utils.hpp" +#include "search/geocoder.hpp" +#include "search/ranking_utils.hpp" #include "std/string.hpp" #include "std/vector.hpp" @@ -10,8 +10,6 @@ namespace search { struct QueryParams; -namespace v2 -{ class LocalityScorer { public: @@ -53,5 +51,5 @@ private: QueryParams const & m_params; Delegate const & m_delegate; }; -} // namespace v2 + } // namespace search diff --git a/search/v2/mwm_context.cpp b/search/mwm_context.cpp similarity index 90% rename from search/v2/mwm_context.cpp rename to search/mwm_context.cpp index 69a3fd140e..b89575d420 100644 --- a/search/v2/mwm_context.cpp +++ b/search/mwm_context.cpp @@ -1,11 +1,7 @@ -#include "search/v2/mwm_context.hpp" - +#include "search/mwm_context.hpp" namespace search { -namespace v2 -{ - void CoverRect(m2::RectD const & rect, int scale, covering::IntervalsT & result) { covering::CoveringGetter covering(rect, covering::ViewportWithLowLevels); @@ -25,8 +21,7 @@ bool MwmContext::GetFeature(uint32_t index, FeatureType & ft) const { switch (GetEditedStatus(index)) { - case osm::Editor::FeatureStatus::Deleted: - return false; + case osm::Editor::FeatureStatus::Deleted: return false; case osm::Editor::FeatureStatus::Modified: case osm::Editor::FeatureStatus::Created: VERIFY(osm::Editor::Instance().GetEditedFeature(GetId(), index, ft), ()); @@ -48,5 +43,4 @@ bool MwmContext::GetStreetIndex(uint32_t houseId, uint32_t & streetId) return m_houseToStreetTable->Get(houseId, streetId); } -} // namespace v2 } // namespace search diff --git a/search/v2/mwm_context.hpp b/search/mwm_context.hpp similarity index 67% rename from search/v2/mwm_context.hpp rename to search/mwm_context.hpp index 191d2eea69..200f5cd053 100644 --- a/search/v2/mwm_context.hpp +++ b/search/mwm_context.hpp @@ -1,6 +1,6 @@ #pragma once -#include "search/v2/house_to_street_table.hpp" +#include "search/house_to_street_table.hpp" #include "indexer/features_vector.hpp" #include "indexer/index.hpp" @@ -14,9 +14,6 @@ class MwmValue; namespace search { -namespace v2 -{ - void CoverRect(m2::RectD const & rect, int scale, covering::IntervalsT & result); /// @todo Move this class into "index" library and make it more generic. @@ -39,25 +36,26 @@ public: inline string const & GetName() const { return GetInfo()->GetCountryName(); } inline shared_ptr const & GetInfo() const { return GetId().GetInfo(); } - template void ForEachIndex(covering::IntervalsT const & intervals, - uint32_t scale, TFn && fn) const + template + void ForEachIndex(covering::IntervalsT const & intervals, uint32_t scale, TFn && fn) const { ForEachIndexImpl(intervals, scale, [&](uint32_t index) - { - // TODO: Optimize deleted checks by getting vector of deleted indexes from the Editor. - if (GetEditedStatus(index) != osm::Editor::FeatureStatus::Deleted) - fn(index); - }); + { + // TODO: Optimize deleted checks by getting vector of deleted indexes from + // the Editor. + if (GetEditedStatus(index) != osm::Editor::FeatureStatus::Deleted) + fn(index); + }); } - template void ForEachFeature(m2::RectD const & rect, TFn && fn) const + template + void ForEachFeature(m2::RectD const & rect, TFn && fn) const { uint32_t const scale = m_value.GetHeader().GetLastScale(); covering::IntervalsT intervals; CoverRect(rect, scale, intervals); - ForEachIndexImpl(intervals, scale, - [&](uint32_t index) + ForEachIndexImpl(intervals, scale, [&](uint32_t index) { FeatureType ft; if (GetFeature(index, ft)) @@ -76,21 +74,21 @@ private: return osm::Editor::Instance().GetFeatureStatus(GetId(), index); } - template void ForEachIndexImpl(covering::IntervalsT const & intervals, - uint32_t scale, TFn && fn) const + template + void ForEachIndexImpl(covering::IntervalsT const & intervals, uint32_t scale, TFn && fn) const { CheckUniqueIndexes checkUnique(m_value.GetHeader().GetFormat() >= version::Format::v5); for (auto const & i : intervals) m_index.ForEachInIntervalAndScale( - [&] (uint32_t index) - { - if (checkUnique(index)) - fn(index); - }, i.first, i.second, scale); + [&](uint32_t index) + { + if (checkUnique(index)) + fn(index); + }, + i.first, i.second, scale); } DISALLOW_COPY_AND_MOVE(MwmContext); }; -} // namespace v2 } // namespace search diff --git a/search/v2/nested_rects_cache.cpp b/search/nested_rects_cache.cpp similarity index 95% rename from search/v2/nested_rects_cache.cpp rename to search/nested_rects_cache.cpp index 8708e4b00a..07c5ae68ce 100644 --- a/search/v2/nested_rects_cache.cpp +++ b/search/nested_rects_cache.cpp @@ -1,6 +1,6 @@ -#include "search/v2/nested_rects_cache.hpp" +#include "search/nested_rects_cache.hpp" -#include "search/v2/ranking_info.hpp" +#include "search/ranking_info.hpp" #include "indexer/index.hpp" @@ -14,8 +14,6 @@ namespace search { -namespace v2 -{ namespace { double const kPositionToleranceMeters = 15.0; @@ -100,5 +98,5 @@ void NestedRectsCache::Update() m_valid = true; } -} // namespace v2 + } // namespace search diff --git a/search/v2/nested_rects_cache.hpp b/search/nested_rects_cache.hpp similarity index 95% rename from search/v2/nested_rects_cache.hpp rename to search/nested_rects_cache.hpp index a4f7387a04..919ed29a74 100644 --- a/search/v2/nested_rects_cache.hpp +++ b/search/nested_rects_cache.hpp @@ -8,8 +8,6 @@ class Index; namespace search { -namespace v2 -{ class NestedRectsCache { public: @@ -44,5 +42,5 @@ private: // Sorted lists of features. vector m_features[RECT_SCALE_COUNT]; }; -} // namespace v2 + } // namespace search diff --git a/search/pre_ranker.cpp b/search/pre_ranker.cpp index 2d99624053..54e6f628fc 100644 --- a/search/pre_ranker.cpp +++ b/search/pre_ranker.cpp @@ -1,6 +1,6 @@ #include "search/pre_ranker.hpp" -#include "search/v2/pre_ranking_info.hpp" +#include "search/pre_ranking_info.hpp" #include "base/stl_helpers.hpp" diff --git a/search/v2/pre_ranking_info.cpp b/search/pre_ranking_info.cpp similarity index 85% rename from search/v2/pre_ranking_info.cpp rename to search/pre_ranking_info.cpp index b45f92dc08..8de435ac55 100644 --- a/search/v2/pre_ranking_info.cpp +++ b/search/pre_ranking_info.cpp @@ -1,11 +1,9 @@ -#include "search/v2/pre_ranking_info.hpp" +#include "search/ranking_info.hpp" #include "std/sstream.hpp" namespace search { -namespace v2 -{ string DebugPrint(PreRankingInfo const & info) { ostringstream os; @@ -18,5 +16,5 @@ string DebugPrint(PreRankingInfo const & info) os << "]"; return os.str(); } -} // namespace v2 + } // namespace search diff --git a/search/v2/pre_ranking_info.hpp b/search/pre_ranking_info.hpp similarity index 90% rename from search/v2/pre_ranking_info.hpp rename to search/pre_ranking_info.hpp index 5459e4c285..3b0cd80c7b 100644 --- a/search/v2/pre_ranking_info.hpp +++ b/search/pre_ranking_info.hpp @@ -1,13 +1,11 @@ #pragma once -#include "search/v2/search_model.hpp" +#include "search/search_model.hpp" #include "std/cstdint.hpp" namespace search { -namespace v2 -{ struct PreRankingInfo { inline size_t GetNumTokens() const { return m_endToken - m_startToken; } @@ -29,5 +27,5 @@ struct PreRankingInfo }; string DebugPrint(PreRankingInfo const & info); -} // namespace v2 + } // namespace search diff --git a/search/processor.cpp b/search/processor.cpp index d3a4727094..60385621e2 100644 --- a/search/processor.cpp +++ b/search/processor.cpp @@ -5,14 +5,14 @@ #include "search/intermediate_result.hpp" #include "search/latlon_match.hpp" #include "search/locality.hpp" +#include "search/pre_ranking_info.hpp" #include "search/query_params.hpp" +#include "search/ranking_info.hpp" +#include "search/ranking_utils.hpp" #include "search/region.hpp" #include "search/search_common.hpp" #include "search/search_index_values.hpp" #include "search/search_string_intersection.hpp" -#include "search/v2/pre_ranking_info.hpp" -#include "search/v2/ranking_info.hpp" -#include "search/v2/ranking_utils.hpp" #include "storage/country_info_getter.hpp" #include "storage/index.hpp" @@ -181,18 +181,18 @@ m2::RectD GetRectAroundPosition(m2::PointD const & position) } template -void UpdateNameScore(string const & name, TSlice const & slice, v2::NameScore & bestScore) +void UpdateNameScore(string const & name, TSlice const & slice, NameScore & bestScore) { - auto const score = v2::GetNameScore(name, slice); + auto const score = GetNameScore(name, slice); if (score > bestScore) bestScore = score; } template void UpdateNameScore(vector const & tokens, TSlice const & slice, - v2::NameScore & bestScore) + NameScore & bestScore) { - auto const score = v2::GetNameScore(tokens, slice); + auto const score = GetNameScore(tokens, slice); if (score > bestScore) bestScore = score; } @@ -358,7 +358,7 @@ void Processor::SetQuery(string const & query) // get preffered types to show in results m_prefferedTypes.clear(); - ForEachCategoryTypes(v2::QuerySliceOnRawStrings(m_tokens, m_prefix), + ForEachCategoryTypes(QuerySliceOnRawStrings(m_tokens, m_prefix), [&](size_t, uint32_t t) { m_prefferedTypes.insert(t); @@ -497,10 +497,10 @@ void Processor::Search(Results & results, size_t limit) if (m_tokens.empty()) SuggestStrings(results); - v2::Geocoder::Params params; + Geocoder::Params params; + InitParams(params); params.m_mode = m_mode; - params.m_pivot = GetPivotRect(); params.m_accuratePivotCenter = GetPivotPoint(); m_geocoder.SetParams(params); @@ -512,7 +512,8 @@ void Processor::Search(Results & results, size_t limit) void Processor::SearchViewportPoints(Results & results) { - v2::Geocoder::Params params; + Geocoder::Params params; + InitParams(params); params.m_pivot = m_viewport[CURRENT_V]; params.m_accuratePivotCenter = params.m_pivot.Center(); @@ -551,7 +552,7 @@ namespace impl class PreResult2Maker { Processor & m_processor; - v2::Geocoder::Params const & m_params; + Geocoder::Params const & m_params; unique_ptr m_pFV; @@ -577,7 +578,7 @@ class PreResult2Maker } void InitRankingInfo(FeatureType const & ft, m2::PointD const & center, - impl::PreResult1 const & res, search::v2::RankingInfo & info) + impl::PreResult1 const & res, search::RankingInfo & info) { auto const & preInfo = res.GetInfo(); @@ -586,11 +587,10 @@ class PreResult2Maker info.m_distanceToPivot = MercatorBounds::DistanceOnEarth(center, pivot); info.m_rank = preInfo.m_rank; info.m_searchType = preInfo.m_searchType; - info.m_nameScore = v2::NAME_SCORE_ZERO; + info.m_nameScore = NAME_SCORE_ZERO; - v2::TokenSlice slice(m_params, preInfo.m_startToken, preInfo.m_endToken); - v2::TokenSliceNoCategories sliceNoCategories(m_params, preInfo.m_startToken, - preInfo.m_endToken); + TokenSlice slice(m_params, preInfo.m_startToken, preInfo.m_endToken); + TokenSliceNoCategories sliceNoCategories(m_params, preInfo.m_startToken, preInfo.m_endToken); for (auto const & lang : m_params.m_langs) { @@ -604,12 +604,12 @@ class PreResult2Maker UpdateNameScore(tokens, sliceNoCategories, info.m_nameScore); } - if (info.m_searchType == v2::SearchModel::SEARCH_TYPE_BUILDING) + if (info.m_searchType == SearchModel::SEARCH_TYPE_BUILDING) UpdateNameScore(ft.GetHouseNumber(), sliceNoCategories, info.m_nameScore); feature::TypesHolder holder(ft); vector> matched(slice.Size()); - m_processor.ForEachCategoryTypes(v2::QuerySlice(slice), [&](size_t i, uint32_t t) + m_processor.ForEachCategoryTypes(QuerySlice(slice), [&](size_t i, uint32_t t) { ++matched[i].second; if (holder.Has(t)) @@ -626,13 +626,13 @@ class PreResult2Maker }); } - uint8_t NormalizeRank(uint8_t rank, v2::SearchModel::SearchType type, m2::PointD const & center, + uint8_t NormalizeRank(uint8_t rank, SearchModel::SearchType type, m2::PointD const & center, string const & country) { switch (type) { - case v2::SearchModel::SEARCH_TYPE_VILLAGE: return rank /= 1.5; - case v2::SearchModel::SEARCH_TYPE_CITY: + case SearchModel::SEARCH_TYPE_VILLAGE: return rank /= 1.5; + case SearchModel::SEARCH_TYPE_CITY: { if (m_processor.GetViewport(Processor::CURRENT_V).IsPointInside(center)) return rank * 2; @@ -645,7 +645,7 @@ class PreResult2Maker if (info.IsNotEmpty() && info.m_name == m_processor.GetPivotRegion()) return rank *= 1.7; } - case v2::SearchModel::SEARCH_TYPE_COUNTRY: + case SearchModel::SEARCH_TYPE_COUNTRY: return rank /= 1.5; // For all other search types, rank should be zero for now. @@ -654,7 +654,7 @@ class PreResult2Maker } public: - explicit PreResult2Maker(Processor & q, v2::Geocoder::Params const & params) + explicit PreResult2Maker(Processor & q, Geocoder::Params const & params) : m_processor(q), m_params(params) { } @@ -671,7 +671,7 @@ public: auto res2 = make_unique(ft, &res1, center, m_processor.GetPosition() /* pivot */, name, country); - search::v2::RankingInfo info; + search::RankingInfo info; InitRankingInfo(ft, center, res1, info); info.m_rank = NormalizeRank(info.m_rank, info.m_searchType, center, country); res2->SetRankingInfo(move(info)); @@ -682,7 +682,7 @@ public: } // namespace impl template -void Processor::MakePreResult2(v2::Geocoder::Params const & params, vector & cont, +void Processor::MakePreResult2(Geocoder::Params const & params, vector & cont, vector & streets) { m_preRanker.Filter(m_viewportSearch); @@ -707,7 +707,7 @@ void Processor::MakePreResult2(v2::Geocoder::Params const & params, vector & }); } -void Processor::FlushResults(v2::Geocoder::Params const & params, Results & res, size_t resCount) +void Processor::FlushResults(Geocoder::Params const & params, Results & res, size_t resCount) { vector indV; vector streets; @@ -736,7 +736,7 @@ void Processor::FlushResults(v2::Geocoder::Params const & params, Results & res, } } -void Processor::FlushViewportResults(v2::Geocoder::Params const & params, Results & res) +void Processor::FlushViewportResults(Geocoder::Params const & params, Results & res) { vector indV; vector streets; @@ -1155,7 +1155,7 @@ void Processor::InitParams(QueryParams & params) } } }; - ForEachCategoryTypes(v2::QuerySliceOnRawStrings(m_tokens, m_prefix), addSyms); + ForEachCategoryTypes(QuerySliceOnRawStrings(m_tokens, m_prefix), addSyms); for (auto & tokens : params.m_tokens) { diff --git a/search/processor.hpp b/search/processor.hpp index 514b2e1994..c91a574e4d 100644 --- a/search/processor.hpp +++ b/search/processor.hpp @@ -1,13 +1,13 @@ #pragma once +#include "search/geocoder.hpp" #include "search/keyword_lang_matcher.hpp" #include "search/mode.hpp" #include "search/pre_ranker.hpp" +#include "search/rank_table_cache.hpp" #include "search/reverse_geocoder.hpp" #include "search/search_trie.hpp" #include "search/suggest.hpp" -#include "search/v2/geocoder.hpp" -#include "search/v2/rank_table_cache.hpp" -#include "search/v2/token_slice.hpp" +#include "search/token_slice.hpp" #include "indexer/ftypes_matcher.hpp" #include "indexer/index.hpp" @@ -52,10 +52,7 @@ struct Region; struct QueryParams; class ReverseGeocoder; -namespace v2 -{ class Geocoder; -} // namespace search::v2 namespace impl { @@ -159,11 +156,11 @@ protected: void ClearCache(size_t ind); template - void MakePreResult2(v2::Geocoder::Params const & params, vector & cont, + void MakePreResult2(Geocoder::Params const & params, vector & cont, vector & streets); - void FlushResults(v2::Geocoder::Params const & params, Results & res, size_t resCount); - void FlushViewportResults(v2::Geocoder::Params const & params, Results & res); + void FlushResults(Geocoder::Params const & params, Results & res, size_t resCount); + void FlushViewportResults(Geocoder::Params const & params, Results & res); void RemoveStringPrefix(string const & str, string & res) const; void GetSuggestion(string const & name, string & suggest) const; @@ -219,7 +216,7 @@ protected: bool m_keepHouseNumberInQuery; PreRanker m_preRanker; - v2::Geocoder m_geocoder; + Geocoder m_geocoder; ReverseGeocoder const m_reverseGeocoder; }; } // namespace search diff --git a/search/v2/rank_table_cache.cpp b/search/rank_table_cache.cpp similarity index 72% rename from search/v2/rank_table_cache.cpp rename to search/rank_table_cache.cpp index cfaf1ee62e..83b94f9b94 100644 --- a/search/v2/rank_table_cache.cpp +++ b/search/rank_table_cache.cpp @@ -1,4 +1,4 @@ -#include "search/v2/rank_table_cache.hpp" +#include "search/rank_table_cache.hpp" #include "search/dummy_rank_table.hpp" @@ -6,9 +6,6 @@ namespace search { -namespace v2 -{ - RankTable const & RankTableCache::Get(Index & index, TId const & mwmId) { auto const it = m_ranks.find(TKey(mwmId)); @@ -23,15 +20,8 @@ RankTable const & RankTableCache::Get(Index & index, TId const & mwmId) return *(m_ranks.emplace(move(handle), move(table)).first->second.get()); } -void RankTableCache::Remove(TId const & id) -{ - m_ranks.erase(TKey(id)); -} +void RankTableCache::Remove(TId const & id) { m_ranks.erase(TKey(id)); } -void RankTableCache::Clear() -{ - m_ranks.clear(); -} +void RankTableCache::Clear() { m_ranks.clear(); } -} // namespace v2 } // namespace search diff --git a/search/v2/rank_table_cache.hpp b/search/rank_table_cache.hpp similarity index 66% rename from search/v2/rank_table_cache.hpp rename to search/rank_table_cache.hpp index d4cac4041a..2332a3a3c1 100644 --- a/search/v2/rank_table_cache.hpp +++ b/search/rank_table_cache.hpp @@ -11,8 +11,6 @@ namespace search { class RankTable; -namespace v2 -{ class RankTableCache { using TId = MwmSet::MwmId; @@ -22,14 +20,8 @@ class RankTableCache TKey() = default; TKey(TKey &&) = default; - explicit TKey(TId const & id) - { - this->m_mwmId = id; - } - explicit TKey(MwmSet::MwmHandle && handle) - : MwmSet::MwmHandle(move(handle)) - { - } + explicit TKey(TId const & id) { this->m_mwmId = id; } + explicit TKey(MwmSet::MwmHandle && handle) : MwmSet::MwmHandle(move(handle)) {} }; public: @@ -43,15 +35,12 @@ public: private: struct Compare { - bool operator() (TKey const & r1, TKey const & r2) const - { - return (r1.GetId() < r2.GetId()); - } + bool operator()(TKey const & r1, TKey const & r2) const { return (r1.GetId() < r2.GetId()); } }; map, Compare> m_ranks; DISALLOW_COPY_AND_MOVE(RankTableCache); }; -} // namespace v2 + } // namespace search diff --git a/search/v2/ranking_info.cpp b/search/ranking_info.cpp similarity index 86% rename from search/v2/ranking_info.cpp rename to search/ranking_info.cpp index 0de02d483e..163208b652 100644 --- a/search/v2/ranking_info.cpp +++ b/search/ranking_info.cpp @@ -1,4 +1,4 @@ -#include "search/v2/ranking_info.hpp" +#include "search/ranking_info.hpp" #include "std/cmath.hpp" #include "std/iomanip.hpp" @@ -7,8 +7,6 @@ namespace search { -namespace v2 -{ namespace { // See search/search_quality/scoring_model.py for details. In short, @@ -17,21 +15,13 @@ double const kDistanceToPivot = -0.7579760; double const kRank = 0.9185310; double const kFalseCats = -0.7996119; double const kNameScore[NameScore::NAME_SCORE_COUNT] = { - -1.0000000 /* Zero */, - 0.3585180 /* Substring Prefix */, - 0.3198080 /* Substring */, - 0.3216740 /* Full Match Prefix */, - 0.3216740 /* Full Match */ + -1.0000000 /* Zero */, 0.3585180 /* Substring Prefix */, 0.3198080 /* Substring */, + 0.3216740 /* Full Match Prefix */, 0.3216740 /* Full Match */ }; double const kSearchType[SearchModel::SEARCH_TYPE_COUNT] = { - -0.1419479 /* POI */, - -0.1419479 /* Building */, - -0.1462099 /* Street */, - -0.1509122 /* Unclassified */, - -0.2591458 /* Village */, - -0.0451342 /* City */, - 0.2515398 /* State */, - 0.4918102 /* Country */ + -0.1419479 /* POI */, -0.1419479 /* Building */, -0.1462099 /* Street */, + -0.1509122 /* Unclassified */, -0.2591458 /* Village */, -0.0451342 /* City */, + 0.2515398 /* State */, 0.4918102 /* Country */ }; double TransformDistance(double distance) @@ -99,5 +89,5 @@ double RankingInfo::GetLinearModelRank() const return kDistanceToPivot * distanceToPivot + kRank * rank + kNameScore[nameScore] + kSearchType[m_searchType] + m_falseCats * kFalseCats; } -} // namespace v2 + } // namespace search diff --git a/search/v2/ranking_info.hpp b/search/ranking_info.hpp similarity index 87% rename from search/v2/ranking_info.hpp rename to search/ranking_info.hpp index 8a1cf70896..d5ee955af4 100644 --- a/search/v2/ranking_info.hpp +++ b/search/ranking_info.hpp @@ -1,8 +1,8 @@ #pragma once -#include "search/v2/pre_ranking_info.hpp" -#include "search/v2/ranking_utils.hpp" -#include "search/v2/search_model.hpp" +#include "search/pre_ranking_info.hpp" +#include "search/ranking_utils.hpp" +#include "search/search_model.hpp" #include "std/iostream.hpp" @@ -10,8 +10,6 @@ class FeatureType; namespace search { -namespace v2 -{ struct RankingInfo { static double const kMaxDistMeters; @@ -47,5 +45,5 @@ struct RankingInfo }; string DebugPrint(RankingInfo const & info); -} // namespace v2 + } // namespace search diff --git a/search/v2/ranking_utils.cpp b/search/ranking_utils.cpp similarity index 92% rename from search/v2/ranking_utils.cpp rename to search/ranking_utils.cpp index f865f3336e..39dcf2fe7f 100644 --- a/search/v2/ranking_utils.cpp +++ b/search/ranking_utils.cpp @@ -1,4 +1,4 @@ -#include "search/v2/ranking_utils.hpp" +#include "search/ranking_utils.hpp" #include "std/algorithm.hpp" @@ -6,8 +6,6 @@ using namespace strings; namespace search { -namespace v2 -{ namespace impl { bool Match(vector const & tokens, UniString const & token) @@ -39,5 +37,5 @@ string DebugPrint(NameScore score) } return "Unknown"; } -} // namespace v2 + } // namespace search diff --git a/search/v2/ranking_utils.hpp b/search/ranking_utils.hpp similarity index 96% rename from search/v2/ranking_utils.hpp rename to search/ranking_utils.hpp index 1d0d1d2c65..75b94e4c50 100644 --- a/search/v2/ranking_utils.hpp +++ b/search/ranking_utils.hpp @@ -1,7 +1,7 @@ #pragma once #include "search/query_params.hpp" -#include "search/v2/search_model.hpp" +#include "search/search_model.hpp" #include "indexer/search_delimiters.hpp" #include "indexer/search_string_utils.hpp" @@ -18,8 +18,6 @@ namespace search { struct QueryParams; -namespace v2 -{ namespace impl { bool Match(vector const & tokens, strings::UniString const & token); @@ -88,5 +86,5 @@ NameScore GetNameScore(vector const & tokens, TSlice const & } string DebugPrint(NameScore score); -} // namespace v2 + } // namespace search diff --git a/search/result.hpp b/search/result.hpp index 896aa2c181..19d1576411 100644 --- a/search/result.hpp +++ b/search/result.hpp @@ -1,5 +1,5 @@ #pragma once -#include "search/v2/ranking_info.hpp" +#include "search/ranking_info.hpp" #include "indexer/feature_decl.hpp" @@ -94,7 +94,7 @@ public: int32_t GetPositionInResults() const { return m_positionInResults; } void SetPositionInResults(int32_t pos) { m_positionInResults = pos; } - inline v2::RankingInfo const & GetRankingInfo() const { return m_info; } + inline RankingInfo const & GetRankingInfo() const { return m_info; } template inline void SetRankingInfo(TInfo && info) @@ -115,7 +115,7 @@ private: string m_suggestionStr; buffer_vector, 4> m_hightlightRanges; - v2::RankingInfo m_info; + RankingInfo m_info; // The position that this result occupied in the vector returned // by a search query. -1 if undefined. diff --git a/search/retrieval.cpp b/search/retrieval.cpp index a2ecb76677..8a312d8f6b 100644 --- a/search/retrieval.cpp +++ b/search/retrieval.cpp @@ -1,13 +1,12 @@ #include "retrieval.hpp" -#include "cancel_exception.hpp" -#include "feature_offset_match.hpp" -#include "interval_set.hpp" -#include "search_index_values.hpp" -#include "search_trie.hpp" - -#include "v2/mwm_context.hpp" -#include "v2/token_slice.hpp" +#include "search/cancel_exception.hpp" +#include "search/feature_offset_match.hpp" +#include "search/interval_set.hpp" +#include "search/mwm_context.hpp" +#include "search/search_index_values.hpp" +#include "search/search_trie.hpp" +#include "search/token_slice.hpp" #include "indexer/feature.hpp" #include "indexer/feature_algo.hpp" @@ -30,8 +29,6 @@ using osm::Editor; namespace search { -namespace v2 -{ namespace { class FeaturesCollector @@ -160,7 +157,7 @@ bool MatchFeatureByName(FeatureType const & ft, QueryParams const & params) return matched; } -bool MatchFeatureByPostcode(FeatureType const & ft, v2::TokenSlice const & slice) +bool MatchFeatureByPostcode(FeatureType const & ft, TokenSlice const & slice) { string const postcode = ft.GetMetadata().Get(feature::Metadata::FMD_POSTCODE); vector tokens; @@ -252,7 +249,7 @@ unique_ptr RetrievePostcodeFeaturesImpl( // Retrieves from the geometry index corresponding to handle all // features from |coverage|. unique_ptr RetrieveGeometryFeaturesImpl( - v2::MwmContext const & context, my::Cancellable const & cancellable, + MwmContext const & context, my::Cancellable const & cancellable, covering::IntervalsT const & coverage, int scale) { vector features; @@ -331,9 +328,8 @@ unique_ptr RetrieveGeometryFeatures( m2::RectD const & rect, int scale) { covering::IntervalsT coverage; - v2::CoverRect(rect, scale, coverage); + CoverRect(rect, scale, coverage); return RetrieveGeometryFeaturesImpl(context, cancellable, coverage, scale); } -} // namespace v2 } // namespace search diff --git a/search/retrieval.hpp b/search/retrieval.hpp index a4e85c6095..032636bf7c 100644 --- a/search/retrieval.hpp +++ b/search/retrieval.hpp @@ -18,8 +18,6 @@ class CompressedBitVector; namespace search { -namespace v2 -{ class MwmContext; class TokenSlice; @@ -40,5 +38,5 @@ unique_ptr RetrievePostcodeFeatures( unique_ptr RetrieveGeometryFeatures( MwmContext const & context, my::Cancellable const & cancellable, m2::RectD const & rect, int scale); -} // namespace v2 + } // namespace search diff --git a/search/reverse_geocoder.cpp b/search/reverse_geocoder.cpp index d91089c491..c2796138dc 100644 --- a/search/reverse_geocoder.cpp +++ b/search/reverse_geocoder.cpp @@ -1,6 +1,6 @@ #include "reverse_geocoder.hpp" -#include "search/v2/mwm_context.hpp" +#include "search/mwm_context.hpp" #include "indexer/feature.hpp" #include "indexer/feature_algo.hpp" @@ -50,7 +50,7 @@ void ReverseGeocoder::GetNearbyStreets(MwmSet::MwmId const & id, m2::PointD cons MwmSet::MwmHandle mwmHandle = m_index.GetMwmHandleById(id); if (mwmHandle.IsAlive()) { - search::v2::MwmContext(move(mwmHandle)).ForEachFeature(rect, addStreet); + search::MwmContext(move(mwmHandle)).ForEachFeature(rect, addStreet); sort(streets.begin(), streets.end(), my::LessBy(&Street::m_distanceMeters)); } } @@ -199,7 +199,7 @@ bool ReverseGeocoder::HouseTable::Get(FeatureID const & fid, uint32_t & streetIn LOG(LWARNING, ("MWM", fid, "is dead")); return false; } - m_table = search::v2::HouseToStreetTable::Load(*m_handle.GetValue()); + m_table = search::HouseToStreetTable::Load(*m_handle.GetValue()); } return m_table->Get(fid.m_index, streetIndex); diff --git a/search/reverse_geocoder.hpp b/search/reverse_geocoder.hpp index 3aa3dd4328..097cbe752d 100644 --- a/search/reverse_geocoder.hpp +++ b/search/reverse_geocoder.hpp @@ -1,6 +1,6 @@ #pragma once -#include "search/v2/house_to_street_table.hpp" +#include "search/house_to_street_table.hpp" #include "indexer/feature_decl.hpp" @@ -99,7 +99,7 @@ private: class HouseTable { Index const & m_index; - unique_ptr m_table; + unique_ptr m_table; MwmSet::MwmHandle m_handle; public: explicit HouseTable(Index const & index) : m_index(index) {} diff --git a/search/search.pro b/search/search.pro index 504169295d..894529fb5b 100644 --- a/search/search.pro +++ b/search/search.pro @@ -12,25 +12,42 @@ HEADERS += \ algos.hpp \ approximate_string_match.hpp \ cancel_exception.hpp \ + cbv_ptr.hpp \ dummy_rank_table.hpp \ feature_offset_match.hpp \ + features_filter.hpp \ + features_layer.hpp \ + features_layer_matcher.hpp \ + features_layer_path_finder.hpp \ + geocoder.hpp \ + geometry_cache.hpp \ geometry_utils.hpp \ house_detector.hpp \ + house_numbers_matcher.hpp \ + house_to_street_table.hpp \ intermediate_result.hpp \ + intersection_result.hpp \ interval_set.hpp \ keyword_lang_matcher.hpp \ keyword_matcher.hpp \ latlon_match.hpp \ locality.hpp \ locality_finder.hpp \ + locality_scorer.hpp \ mode.hpp \ + mwm_context.hpp \ + nested_rects_cache.hpp \ params.hpp \ pre_ranker.hpp \ + pre_ranking_info.hpp \ processor.hpp \ processor_factory.hpp \ projection_on_street.hpp \ query_params.hpp \ query_saver.hpp \ + rank_table_cache.hpp \ + ranking_info.hpp \ + ranking_utils.hpp \ region.hpp \ result.hpp \ retrieval.hpp \ @@ -38,73 +55,56 @@ HEADERS += \ search_common.hpp \ search_engine.hpp \ search_index_values.hpp \ + search_model.hpp \ search_string_intersection.hpp \ search_trie.hpp \ + stats_cache.hpp \ + street_vicinity_loader.hpp \ suggest.hpp \ + token_slice.hpp \ types_skipper.hpp \ - v2/cbv_ptr.hpp \ - v2/features_filter.hpp \ - v2/features_layer.hpp \ - v2/features_layer_matcher.hpp \ - v2/features_layer_path_finder.hpp \ - v2/geocoder.hpp \ - v2/geometry_cache.hpp \ - v2/house_numbers_matcher.hpp \ - v2/house_to_street_table.hpp \ - v2/intersection_result.hpp \ - v2/locality_scorer.hpp \ - v2/mwm_context.hpp \ - v2/nested_rects_cache.hpp \ - v2/pre_ranking_info.hpp \ - v2/rank_table_cache.hpp \ - v2/ranking_info.hpp \ - v2/ranking_utils.hpp \ - v2/search_model.hpp \ - v2/stats_cache.hpp \ - v2/street_vicinity_loader.hpp \ - v2/token_slice.hpp \ SOURCES += \ approximate_string_match.cpp \ + cbv_ptr.cpp \ dummy_rank_table.cpp \ + features_filter.cpp \ + features_layer.cpp \ + features_layer_matcher.cpp \ + features_layer_path_finder.cpp \ + geocoder.cpp \ + geometry_cache.cpp \ geometry_utils.cpp \ house_detector.cpp \ + house_numbers_matcher.cpp \ + house_to_street_table.cpp \ intermediate_result.cpp \ + intersection_result.cpp \ keyword_lang_matcher.cpp \ keyword_matcher.cpp \ latlon_match.cpp \ locality.cpp \ locality_finder.cpp \ + locality_scorer.cpp \ mode.cpp \ + mwm_context.cpp \ + nested_rects_cache.cpp \ params.cpp \ pre_ranker.cpp \ + pre_ranking_info.cpp \ processor.cpp \ projection_on_street.cpp \ query_params.cpp \ query_saver.cpp \ + rank_table_cache.cpp \ + ranking_info.cpp \ + ranking_utils.cpp \ region.cpp \ result.cpp \ retrieval.cpp \ reverse_geocoder.cpp \ search_engine.cpp \ + search_model.cpp \ + street_vicinity_loader.cpp \ + token_slice.cpp \ types_skipper.cpp \ - v2/cbv_ptr.cpp \ - v2/features_filter.cpp \ - v2/features_layer.cpp \ - v2/features_layer_matcher.cpp \ - v2/features_layer_path_finder.cpp \ - v2/geocoder.cpp \ - v2/geometry_cache.cpp \ - v2/house_numbers_matcher.cpp \ - v2/house_to_street_table.cpp \ - v2/intersection_result.cpp \ - v2/locality_scorer.cpp \ - v2/mwm_context.cpp \ - v2/nested_rects_cache.cpp \ - v2/pre_ranking_info.cpp \ - v2/rank_table_cache.cpp \ - v2/ranking_info.cpp \ - v2/ranking_utils.cpp \ - v2/search_model.cpp \ - v2/street_vicinity_loader.cpp \ - v2/token_slice.cpp \ diff --git a/search/search_integration_tests/processor_test.cpp b/search/search_integration_tests/processor_test.cpp index 4d81c982d9..6676b73a89 100644 --- a/search/search_integration_tests/processor_test.cpp +++ b/search/search_integration_tests/processor_test.cpp @@ -4,7 +4,7 @@ #include "search/search_integration_tests/helpers.hpp" #include "search/search_tests_support/test_results_matching.hpp" #include "search/search_tests_support/test_search_request.hpp" -#include "search/v2/token_slice.hpp" +#include "search/token_slice.hpp" #include "generator/generator_tests_support/test_feature.hpp" #include "generator/generator_tests_support/test_mwm_builder.hpp" @@ -22,7 +22,6 @@ using namespace generator::tests_support; using namespace search::tests_support; -using namespace search::v2; using TRules = vector>; @@ -414,8 +413,8 @@ UNIT_CLASS_TEST(ProcessorTest, TestPostcodes) params.m_tokens.emplace_back(); params.m_tokens.back().push_back(strings::MakeUniString("141702")); auto * value = handle.GetValue(); - auto features = v2::RetrievePostcodeFeatures(countryId, *value, cancellable, - TokenSlice(params, 0, params.m_tokens.size())); + auto features = RetrievePostcodeFeatures(countryId, *value, cancellable, + TokenSlice(params, 0, params.m_tokens.size())); TEST_EQUAL(1, features->PopCount(), ()); uint64_t index = 0; diff --git a/search/v2/search_model.cpp b/search/search_model.cpp similarity index 82% rename from search/v2/search_model.cpp rename to search/search_model.cpp index 5117d6e3a7..4b45a728a2 100644 --- a/search/v2/search_model.cpp +++ b/search/search_model.cpp @@ -1,4 +1,4 @@ -#include "search/v2/search_model.hpp" +#include "search/search_model.hpp" #include "indexer/classificator.hpp" #include "indexer/feature.hpp" @@ -9,19 +9,15 @@ using namespace ftypes; namespace search { -namespace v2 -{ TwoLevelPOIChecker::TwoLevelPOIChecker() : ftypes::BaseChecker(2 /* level */) { Classificator const & c = classif(); - StringIL arr[] = { - {"highway", "bus_stop"}, - {"highway", "speed_camera"}, - {"waterway", "waterfall"}, - {"natural", "volcano"}, - {"natural", "cave_entrance"}, - {"natural", "beach"} - }; + StringIL arr[] = {{"highway", "bus_stop"}, + {"highway", "speed_camera"}, + {"waterway", "waterfall"}, + {"natural", "volcano"}, + {"natural", "cave_entrance"}, + {"natural", "beach"}}; for (size_t i = 0; i < ARRAY_SIZE(arr); ++i) m_types.push_back(c.GetTypeByPath(arr[i])); @@ -105,20 +101,13 @@ SearchModel::SearchType SearchModel::GetSearchType(FeatureType const & feature) Type type = localityChecker.GetType(feature); switch (type) { - case NONE: - ASSERT(false, ("Unknown locality.")); - return SEARCH_TYPE_UNCLASSIFIED; - case STATE: - return SEARCH_TYPE_STATE; - case COUNTRY: - return SEARCH_TYPE_COUNTRY; + case NONE: ASSERT(false, ("Unknown locality.")); return SEARCH_TYPE_UNCLASSIFIED; + case STATE: return SEARCH_TYPE_STATE; + case COUNTRY: return SEARCH_TYPE_COUNTRY; case CITY: - case TOWN: - return SEARCH_TYPE_CITY; - case VILLAGE: - return SEARCH_TYPE_VILLAGE; - case LOCALITY_COUNT: - return SEARCH_TYPE_UNCLASSIFIED; + case TOWN: return SEARCH_TYPE_CITY; + case VILLAGE: return SEARCH_TYPE_VILLAGE; + case LOCALITY_COUNT: return SEARCH_TYPE_UNCLASSIFIED; } } @@ -145,5 +134,5 @@ string DebugPrint(SearchModel::SearchType type) ASSERT(false, ("Unknown search type:", static_cast(type))); return string(); } -} // namespace v2 + } // namespace search diff --git a/search/v2/search_model.hpp b/search/search_model.hpp similarity index 97% rename from search/v2/search_model.hpp rename to search/search_model.hpp index 5b81678944..99e09d66c8 100644 --- a/search/v2/search_model.hpp +++ b/search/search_model.hpp @@ -11,9 +11,6 @@ class FeatureType; namespace search { -namespace v2 -{ - /// Describes 2-level POI-exception types that don't belong to any POI-common classes /// (amenity, shop, tourism, ...). Used in search algo and search categories index generation. class TwoLevelPOIChecker : public ftypes::BaseChecker @@ -61,5 +58,5 @@ private: }; string DebugPrint(SearchModel::SearchType type); -} // namespace v2 + } // namespace search diff --git a/search/search_quality/features_collector_tool/features_collector_tool.cpp b/search/search_quality/features_collector_tool/features_collector_tool.cpp index 59cabc2c3d..e7047da993 100644 --- a/search/search_quality/features_collector_tool/features_collector_tool.cpp +++ b/search/search_quality/features_collector_tool/features_collector_tool.cpp @@ -1,9 +1,9 @@ +#include "search/ranking_info.hpp" #include "search/result.hpp" #include "search/search_quality/helpers.hpp" #include "search/search_quality/sample.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" #include "indexer/classificator_loader.hpp" #include "indexer/feature_algo.hpp" @@ -232,7 +232,7 @@ int main(int argc, char * argv[]) Context context(engine); cout << "SampleId,"; - v2::RankingInfo::PrintCSVHeader(cout); + RankingInfo::PrintCSVHeader(cout); cout << ",Relevance" << endl; for (size_t i = 0; i < samples.size(); ++i) diff --git a/search/search_quality/search_quality_tool/search_quality_tool.cpp b/search/search_quality/search_quality_tool/search_quality_tool.cpp index a49384af61..031d0ccb5c 100644 --- a/search/search_quality/search_quality_tool/search_quality_tool.cpp +++ b/search/search_quality/search_quality_tool/search_quality_tool.cpp @@ -12,11 +12,11 @@ #include "geometry/point2d.hpp" #include "search/processor_factory.hpp" +#include "search/ranking_info.hpp" #include "search/result.hpp" #include "search/search_quality/helpers.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" #include "platform/country_file.hpp" #include "platform/local_country_file.hpp" @@ -455,7 +455,7 @@ int main(int argc, char * argv[]) if (dumpCSV) { - v2::RankingInfo::PrintCSVHeader(csv); + RankingInfo::PrintCSVHeader(csv); csv << endl; } diff --git a/search/search_tests/house_numbers_matcher_test.cpp b/search/search_tests/house_numbers_matcher_test.cpp index 6a4573f0bf..90485b0755 100644 --- a/search/search_tests/house_numbers_matcher_test.cpp +++ b/search/search_tests/house_numbers_matcher_test.cpp @@ -1,13 +1,13 @@ #include "testing/testing.hpp" -#include "search/v2/house_numbers_matcher.hpp" +#include "search/house_numbers_matcher.hpp" #include "std/vector.hpp" #include "base/string_utils.hpp" using namespace strings; -using namespace search::v2; +using namespace search; namespace { @@ -28,7 +28,7 @@ bool HouseNumbersMatch(string const & houseNumber, string const & query, bool qu { vector queryParses; ParseQuery(MakeUniString(query), queryIsPrefix, queryParses); - return search::v2::HouseNumbersMatch(MakeUniString(houseNumber), queryParses); + return search::HouseNumbersMatch(MakeUniString(houseNumber), queryParses); } bool CheckTokenizer(string const & utf8s, vector const & expected) diff --git a/search/search_tests/locality_scorer_test.cpp b/search/search_tests/locality_scorer_test.cpp index 5021e24af7..7223c73431 100644 --- a/search/search_tests/locality_scorer_test.cpp +++ b/search/search_tests/locality_scorer_test.cpp @@ -1,6 +1,6 @@ #include "testing/testing.hpp" -#include "search/v2/locality_scorer.hpp" +#include "search/locality_scorer.hpp" #include "indexer/search_delimiters.hpp" #include "indexer/search_string_utils.hpp" @@ -15,7 +15,6 @@ #include "std/unordered_map.hpp" #include "std/vector.hpp" -using namespace search::v2; using namespace search; using namespace strings; diff --git a/search/search_tests/ranking_tests.cpp b/search/search_tests/ranking_tests.cpp index bc92c2a4b9..7c1df97352 100644 --- a/search/search_tests/ranking_tests.cpp +++ b/search/search_tests/ranking_tests.cpp @@ -1,8 +1,8 @@ #include "testing/testing.hpp" #include "search/query_params.hpp" -#include "search/v2/ranking_utils.hpp" -#include "search/v2/token_slice.hpp" +#include "search/ranking_utils.hpp" +#include "search/token_slice.hpp" #include "indexer/search_delimiters.hpp" #include "indexer/search_string_utils.hpp" @@ -13,7 +13,6 @@ #include "std/string.hpp" using namespace search; -using namespace search::v2; using namespace strings; namespace diff --git a/search/v2/stats_cache.hpp b/search/stats_cache.hpp similarity index 75% rename from search/v2/stats_cache.hpp rename to search/stats_cache.hpp index 42cfee0e0e..946e12a7c7 100644 --- a/search/v2/stats_cache.hpp +++ b/search/stats_cache.hpp @@ -4,12 +4,8 @@ #include "std/unordered_map.hpp" #include "std/utility.hpp" - namespace search { -namespace v2 -{ - template class Cache { @@ -19,8 +15,8 @@ class Cache size_t m_accesses; size_t m_misses; - size_t m_emptyQueriesCount; /// empty queries count at a row - string m_name; /// cache name for print functions + size_t m_emptyQueriesCount; /// empty queries count at a row + string m_name; /// cache name for print functions public: explicit Cache(string const & name) @@ -51,8 +47,8 @@ public: { if (m_accesses != 0) { - LOG(LDEBUG, ("Cache", m_name, "Queries =", m_accesses, - "From cache =", m_accesses - m_misses, "Added =", m_misses)); + LOG(LDEBUG, ("Cache", m_name, "Queries =", m_accesses, "From cache =", m_accesses - m_misses, + "Added =", m_misses)); m_accesses = m_misses = 0; m_emptyQueriesCount = 0; } @@ -64,5 +60,4 @@ public: } }; -} // namespace v2 -} // namespace search +} // namespace search diff --git a/search/v2/street_vicinity_loader.cpp b/search/street_vicinity_loader.cpp similarity index 91% rename from search/v2/street_vicinity_loader.cpp rename to search/street_vicinity_loader.cpp index b5a4bddb63..28989355b3 100644 --- a/search/v2/street_vicinity_loader.cpp +++ b/search/street_vicinity_loader.cpp @@ -1,4 +1,4 @@ -#include "search/v2/street_vicinity_loader.hpp" +#include "search/street_vicinity_loader.hpp" #include "indexer/feature_covering.hpp" #include "indexer/feature_decl.hpp" @@ -13,8 +13,6 @@ namespace search { -namespace v2 -{ StreetVicinityLoader::StreetVicinityLoader(int scale, double offsetMeters) : m_context(nullptr), m_scale(scale), m_offsetMeters(offsetMeters), m_cache("Streets") { @@ -31,10 +29,7 @@ void StreetVicinityLoader::SetContext(MwmContext * context) m_scale = my::clamp(m_scale, scaleRange.first, scaleRange.second); } -void StreetVicinityLoader::OnQueryFinished() -{ - m_cache.ClearIfNeeded(); -} +void StreetVicinityLoader::OnQueryFinished() { m_cache.ClearIfNeeded(); } StreetVicinityLoader::Street const & StreetVicinityLoader::GetStreet(uint32_t featureId) { @@ -68,5 +63,5 @@ void StreetVicinityLoader::LoadStreet(uint32_t featureId, Street & street) street.m_calculator = make_unique(points); } -} // namespace v2 + } // namespace search diff --git a/search/v2/street_vicinity_loader.hpp b/search/street_vicinity_loader.hpp similarity index 92% rename from search/v2/street_vicinity_loader.hpp rename to search/street_vicinity_loader.hpp index b4f308795e..3f3598054d 100644 --- a/search/v2/street_vicinity_loader.hpp +++ b/search/street_vicinity_loader.hpp @@ -1,8 +1,8 @@ #pragma once +#include "search/mwm_context.hpp" #include "search/projection_on_street.hpp" -#include "search/v2/mwm_context.hpp" -#include "search/v2/stats_cache.hpp" +#include "search/stats_cache.hpp" #include "indexer/feature.hpp" #include "indexer/feature_algo.hpp" @@ -13,11 +13,8 @@ #include "std/unordered_map.hpp" - namespace search { -namespace v2 -{ class MwmContext; // This class is able to load features in a street's vicinity. @@ -49,8 +46,8 @@ public: // Calls |fn| on each index in |sortedIds| where sortedIds[index] // belongs to the street's vicinity. template - void ForEachInVicinity(uint32_t streetId, vector const & sortedIds, - double offsetMeters, TFn const & fn) + void ForEachInVicinity(uint32_t streetId, vector const & sortedIds, double offsetMeters, + TFn const & fn) { // Passed offset param should be less than the cached one, or the cache is invalid otherwise. ASSERT_LESS_OR_EQUAL(offsetMeters, m_offsetMeters, ()); @@ -94,5 +91,5 @@ private: DISALLOW_COPY_AND_MOVE(StreetVicinityLoader); }; -} // namespace v2 + } // namespace search diff --git a/search/v2/token_slice.cpp b/search/token_slice.cpp similarity index 90% rename from search/v2/token_slice.cpp rename to search/token_slice.cpp index 2c230eae05..6705b884fe 100644 --- a/search/v2/token_slice.cpp +++ b/search/token_slice.cpp @@ -1,11 +1,9 @@ -#include "search/v2/token_slice.hpp" +#include "search/token_slice.hpp" #include "std/sstream.hpp" namespace search { -namespace v2 -{ namespace { template @@ -58,14 +56,11 @@ TokenSliceNoCategories::TokenSliceNoCategories(QueryParams const & params, size_ } } -string DebugPrint(TokenSlice const & slice) -{ - return SliceToString("TokenSlice", slice); -} +string DebugPrint(TokenSlice const & slice) { return SliceToString("TokenSlice", slice); } string DebugPrint(TokenSliceNoCategories const & slice) { return SliceToString("TokenSliceNoCategories", slice); } -} // namespace v2 + } // namespace search diff --git a/search/v2/token_slice.hpp b/search/token_slice.hpp similarity index 98% rename from search/v2/token_slice.hpp rename to search/token_slice.hpp index 725ea98355..87da032ce9 100644 --- a/search/v2/token_slice.hpp +++ b/search/token_slice.hpp @@ -12,8 +12,6 @@ namespace search { -namespace v2 -{ class TokenSlice { public: @@ -100,7 +98,7 @@ public: size_t Size() const override { return m_tokens.size() + (m_prefix.empty() ? 0 : 1); } - private: +private: TCont const & m_tokens; TString const & m_prefix; }; @@ -108,5 +106,5 @@ public: string DebugPrint(TokenSlice const & slice); string DebugPrint(TokenSliceNoCategories const & slice); -} // namespace v2 + } // namespace search diff --git a/search/types_skipper.hpp b/search/types_skipper.hpp index 5dd51cf630..0938aba0c8 100644 --- a/search/types_skipper.hpp +++ b/search/types_skipper.hpp @@ -1,6 +1,6 @@ #pragma once -#include "v2/search_model.hpp" +#include "search_model.hpp" #include "base/buffer_vector.hpp" @@ -31,7 +31,7 @@ private: // m_skipIfEmptyName and m_dontSkipIfEmptyName are used in the case 2 described above. TCont m_skipIfEmptyName[2]; - v2::TwoLevelPOIChecker m_dontSkipIfEmptyName; + TwoLevelPOIChecker m_dontSkipIfEmptyName; uint32_t m_country, m_state; };