diff options
author | Yuri Gorshenin <y@maps.me> | 2015-06-16 18:15:09 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:53:25 +0300 |
commit | 598e71858b63ef4e587efd932db41474f8f516a0 (patch) | |
tree | 19e39c1dd331579432c9b58e5e1e82c750842ac3 /search | |
parent | 9148053b3aa67aac443ade98e2ed2ae899419095 (diff) |
Storage redesign.
Diffstat (limited to 'search')
-rw-r--r-- | search/search_query.cpp | 23 | ||||
-rw-r--r-- | search/search_tests/house_detector_tests.cpp | 14 | ||||
-rw-r--r-- | search/search_tests/locality_finder_test.cpp | 7 |
3 files changed, 27 insertions, 17 deletions
diff --git a/search/search_query.cpp b/search/search_query.cpp index 0a5eab18d3..12741b473b 100644 --- a/search/search_query.cpp +++ b/search/search_query.cpp @@ -600,7 +600,7 @@ namespace impl if (m_pFV->IsWorld()) country.clear(); else - country = m_pFV->GetFileName(); + country = m_pFV->GetCountryFileName(); } public: @@ -1659,11 +1659,14 @@ void Query::SearchAddress(Results & res) { MwmSet::MwmId id(info); Index::MwmLock const mwmLock(const_cast<Index &>(*m_pIndex), id); - string fileName; if (mwmLock.IsLocked()) - fileName = mwmLock.GetValue<MwmValue>()->GetFileName(); - if (m_pInfoGetter->IsBelongToRegion(fileName, region.m_ids)) - SearchInMWM(mwmLock, params); + { + platform::CountryFile const & countryFile = + mwmLock.GetValue<MwmValue>()->GetCountryFile(); + string const countryFileName = countryFile.GetNameWithoutExt(); + if (m_pInfoGetter->IsBelongToRegion(countryFileName, region.m_ids)) + SearchInMWM(mwmLock, params); + } } } } @@ -2108,9 +2111,8 @@ void Query::SearchInMWM(Index::MwmLock const & mwmLock, Params const & params, TrieRootPrefix(*pLangRoot, edge), filter, categoriesHolder, emitter); - LOG(LDEBUG, ("Country", pMwm->GetFileName(), - "Lang", StringUtf8Multilang::GetLangByCode(lang), - "Matched", emitter.GetCount())); + LOG(LDEBUG, ("Country", pMwm->GetCountryFile().GetNameWithoutExt(), "Lang", + StringUtf8Multilang::GetLangByCode(lang), "Matched", emitter.GetCount())); emitter.Reset(); } @@ -2193,8 +2195,11 @@ void Query::SearchAdditional(Results & res, size_t resCount) for (shared_ptr<MwmInfo> const & info : mwmsInfo) { Index::MwmLock const mwmLock(const_cast<Index &>(*m_pIndex), MwmSet::MwmId(info)); - if (mwmLock.IsLocked() && mwmLock.GetValue<MwmValue>()->GetFileName() == fileName) + if (mwmLock.IsLocked() && + mwmLock.GetValue<MwmValue>()->GetCountryFile().GetNameWithoutExt() == fileName) + { SearchInMWM(mwmLock, params); + } } FlushResults(res, true, resCount); diff --git a/search/search_tests/house_detector_tests.cpp b/search/search_tests/house_detector_tests.cpp index 1f03cb824d..eae291fb9a 100644 --- a/search/search_tests/house_detector_tests.cpp +++ b/search/search_tests/house_detector_tests.cpp @@ -17,6 +17,7 @@ #include "std/iostream.hpp" #include "std/fstream.hpp" +using platform::LocalCountryFile; class StreetIDsByName { @@ -183,7 +184,8 @@ UNIT_TEST(HS_StreetsMerge) classificator::Load(); Index index; - pair<MwmSet::MwmLock, bool> const p = index.Register("minsk-pass.mwm"); + pair<MwmSet::MwmLock, bool> const p = + index.Register(LocalCountryFile::MakeForTesting("minsk-pass")); TEST(p.first.IsLocked(), ()); TEST(p.second, ()); @@ -272,7 +274,8 @@ UNIT_TEST(HS_FindHouseSmoke) classificator::Load(); Index index; - pair<MwmSet::MwmLock, bool> const p = index.Register("minsk-pass.mwm"); + pair<MwmSet::MwmLock, bool> const p = + index.Register(LocalCountryFile::MakeForTesting("minsk-pass")); TEST(p.first.IsLocked(), ()); TEST(p.second, ()); @@ -345,10 +348,7 @@ struct Address string m_house; double m_lat, m_lon; - bool operator<(Address const & rhs) const - { - return (m_streetKey < rhs.m_streetKey); - } + bool operator<(Address const & rhs) const { return (m_streetKey < rhs.m_streetKey); } }; void swap(Address & a1, Address & a2) @@ -375,7 +375,7 @@ UNIT_TEST(HS_MWMSearch) } Index index; - pair<MwmSet::MwmLock, bool> const p = index.Register(country + ".mwm"); + pair<MwmSet::MwmLock, bool> const p = index.Register(LocalCountryFile::MakeForTesting(country)); if (!p.second) { LOG(LWARNING, ("MWM file not found")); diff --git a/search/search_tests/locality_finder_test.cpp b/search/search_tests/locality_finder_test.cpp index 30182f7267..62efda0f5e 100644 --- a/search/search_tests/locality_finder_test.cpp +++ b/search/search_tests/locality_finder_test.cpp @@ -5,6 +5,10 @@ #include "search/locality_finder.hpp" +#include "platform/country_file.hpp" +#include "platform/local_country_file.hpp" +#include "platform/platform.hpp" + namespace { @@ -34,7 +38,8 @@ void doTests2(search::LocalityFinder & finder, vector<m2::PointD> const & input, UNIT_TEST(LocalityFinder) { Index index; - pair<MwmSet::MwmLock, bool> const p = index.Register("World.mwm"); + pair<MwmSet::MwmLock, bool> const p = + index.Register(platform::LocalCountryFile::MakeForTesting("World")); TEST(p.second, ()); MwmSet::MwmLock const & lock = p.first; TEST(lock.IsLocked(), ()); |