diff options
author | Yuri Gorshenin <y@maps.me> | 2015-07-08 15:00:30 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:54:45 +0300 |
commit | fda4e3603d8bd3ce40816344afc8f0f88f3e2afd (patch) | |
tree | a23b273110780feba0ff39684582a01cd8f206fe /search | |
parent | a64351d1e62ce58b5a4a8d768a8541c8771f294f (diff) |
[index, mwm-set] MwmLock -> MwmHandle
Diffstat (limited to 'search')
-rw-r--r-- | search/integration_tests/smoke_test.cpp | 4 | ||||
-rw-r--r-- | search/locality_finder.cpp | 4 | ||||
-rw-r--r-- | search/search_query.cpp | 34 | ||||
-rw-r--r-- | search/search_query.hpp | 7 | ||||
-rw-r--r-- | search/search_tests/house_detector_tests.cpp | 20 | ||||
-rw-r--r-- | search/search_tests/locality_finder_test.cpp | 11 |
6 files changed, 39 insertions, 41 deletions
diff --git a/search/integration_tests/smoke_test.cpp b/search/integration_tests/smoke_test.cpp index 3a8dcd5121..7c7690fa1f 100644 --- a/search/integration_tests/smoke_test.cpp +++ b/search/integration_tests/smoke_test.cpp @@ -39,8 +39,8 @@ UNIT_TEST(GenerateTestMwm_Smoke) TestSearchEngine engine("en" /* locale */); auto ret = engine.RegisterMap(file); - TEST(ret.second, ("Can't register generated map.")); - TEST(ret.first.IsLocked(), ("Can't get lock on a generated map.")); + TEST_EQUAL(MwmSet::RegResult::Success, ret.second, ("Can't register generated map.")); + TEST(ret.first.IsAlive(), ("Can't get lock on a generated map.")); TestFeaturesCount(engine, m2::RectD(m2::PointD(0, 0), m2::PointD(1, 1)), 4); TestFeaturesCount(engine, m2::RectD(m2::PointD(-0.5, -0.5), m2::PointD(0.5, 1.5)), 2); diff --git a/search/locality_finder.cpp b/search/locality_finder.cpp index 56f71d3b3d..563ebf890c 100644 --- a/search/locality_finder.cpp +++ b/search/locality_finder.cpp @@ -127,8 +127,8 @@ void LocalityFinder::RecreateCache(Cache & cache, m2::RectD rect) const { typedef feature::DataHeader HeaderT; MwmSet::MwmId mwmId(info); - Index::MwmLock const mwmLock(const_cast<Index &>(*m_pIndex), mwmId); - MwmValue * const pMwm = mwmLock.GetValue<MwmValue>(); + Index::MwmHandle const mwmHandle(const_cast<Index &>(*m_pIndex), mwmId); + MwmValue * const pMwm = mwmHandle.GetValue<MwmValue>(); if (pMwm && pMwm->GetHeader().GetType() == HeaderT::world) { HeaderT const & header = pMwm->GetHeader(); diff --git a/search/search_query.cpp b/search/search_query.cpp index 14e6a2fc62..48faf7968e 100644 --- a/search/search_query.cpp +++ b/search/search_query.cpp @@ -264,8 +264,8 @@ void Query::UpdateViewportOffsets(MWMVectorT const & mwmsInfo, m2::RectD const & if (rect.IsIntersect(info->m_limitRect)) { MwmSet::MwmId mwmId(info); - Index::MwmLock const mwmLock(const_cast<Index &>(*m_pIndex), mwmId); - if (MwmValue * const pMwm = mwmLock.GetValue<MwmValue>()) + Index::MwmHandle const mwmHandle(const_cast<Index &>(*m_pIndex), mwmId); + if (MwmValue * const pMwm = mwmHandle.GetValue<MwmValue>()) { FHeaderT const & header = pMwm->GetHeader(); if (header.GetType() == FHeaderT::country) @@ -1608,8 +1608,8 @@ void Query::SearchAddress(Results & res) for (shared_ptr<MwmInfo> & info : mwmsInfo) { MwmSet::MwmId mwmId(info); - Index::MwmLock const mwmLock(const_cast<Index &>(*m_pIndex), mwmId); - MwmValue * const pMwm = mwmLock.GetValue<MwmValue>(); + Index::MwmHandle const mwmHandle(const_cast<Index &>(*m_pIndex), mwmId); + MwmValue * const pMwm = mwmHandle.GetValue<MwmValue>(); if (pMwm && pMwm->m_cont.IsExist(SEARCH_INDEX_FILE_TAG) && pMwm->GetHeader().GetType() == FHeaderT::world) @@ -1663,14 +1663,14 @@ void Query::SearchAddress(Results & res) for (shared_ptr<MwmInfo> & info : mwmsInfo) { MwmSet::MwmId id(info); - Index::MwmLock const mwmLock(const_cast<Index &>(*m_pIndex), id); - if (mwmLock.IsLocked()) + Index::MwmHandle const handle(const_cast<Index &>(*m_pIndex), id); + if (handle.IsAlive()) { platform::CountryFile const & countryFile = - mwmLock.GetValue<MwmValue>()->GetCountryFile(); + handle.GetValue<MwmValue>()->GetCountryFile(); string const countryFileName = countryFile.GetNameWithoutExt(); if (m_pInfoGetter->IsBelongToRegion(countryFileName, region.m_ids)) - SearchInMWM(mwmLock, params); + SearchInMWM(handle, params); } } } @@ -2030,8 +2030,8 @@ void Query::SearchFeatures(Params const & params, MWMVectorT const & mwmsInfo, V // Search only mwms that intersect with viewport (world always does). if (m_viewport[vID].IsIntersect(info->m_limitRect)) { - Index::MwmLock const mwmLock(const_cast<Index &>(*m_pIndex), MwmSet::MwmId(info)); - SearchInMWM(mwmLock, params, vID); + Index::MwmHandle const mwmHandle(const_cast<Index &>(*m_pIndex), MwmSet::MwmId(info)); + SearchInMWM(mwmHandle, params, vID); } } } @@ -2069,10 +2069,10 @@ void FillCategories(Query::Params const & params, TrieIterator const * pTrieRoot } -void Query::SearchInMWM(Index::MwmLock const & mwmLock, Params const & params, +void Query::SearchInMWM(Index::MwmHandle const & mwmHandle, Params const & params, ViewportID vID /*= DEFAULT_V*/) { - if (MwmValue const * const pMwm = mwmLock.GetValue<MwmValue>()) + if (MwmValue const * const pMwm = mwmHandle.GetValue<MwmValue>()) { if (pMwm->m_cont.IsExist(SEARCH_INDEX_FILE_TAG)) { @@ -2091,7 +2091,7 @@ void Query::SearchInMWM(Index::MwmLock const & mwmLock, Params const & params, trie::ValueReader(cp), trie::EdgeValueReader())); - MwmSet::MwmId const mwmId = mwmLock.GetId(); + MwmSet::MwmId const mwmId = mwmHandle.GetId(); FeaturesFilter filter((vID == DEFAULT_V || isWorld) ? 0 : &m_offsetsInViewport[vID][mwmId], *this); // Get categories for each token separately - find needed edge with categories. @@ -2199,11 +2199,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>()->GetCountryFile().GetNameWithoutExt() == fileName) + Index::MwmHandle const handle(const_cast<Index &>(*m_pIndex), MwmSet::MwmId(info)); + if (handle.IsAlive() && + handle.GetValue<MwmValue>()->GetCountryFile().GetNameWithoutExt() == fileName) { - SearchInMWM(mwmLock, params); + SearchInMWM(handle, params); } } diff --git a/search/search_query.hpp b/search/search_query.hpp index 91acc1a4c6..866c8b5b50 100644 --- a/search/search_query.hpp +++ b/search/search_query.hpp @@ -4,7 +4,7 @@ #include "indexer/ftypes_matcher.hpp" #include "indexer/search_trie.hpp" -#include "indexer/index.hpp" // for Index::MwmLock +#include "indexer/index.hpp" // for Index::MwmHandle #include "geometry/rect2d.hpp" @@ -203,8 +203,9 @@ private: //@{ /// Do search in all maps from mwmInfo. void SearchFeatures(Params const & params, MWMVectorT const & mwmsInfo, ViewportID vID); - /// Do search in particular map (mwmLock). - void SearchInMWM(Index::MwmLock const & mwmLock, Params const & params, ViewportID vID = DEFAULT_V); + /// Do search in particular map (mwmHandle). + void SearchInMWM(Index::MwmHandle const & mwmHandle, Params const & params, + ViewportID vID = DEFAULT_V); //@} void SuggestStrings(Results & res); diff --git a/search/search_tests/house_detector_tests.cpp b/search/search_tests/house_detector_tests.cpp index eae291fb9a..c728ae5151 100644 --- a/search/search_tests/house_detector_tests.cpp +++ b/search/search_tests/house_detector_tests.cpp @@ -184,10 +184,9 @@ UNIT_TEST(HS_StreetsMerge) classificator::Load(); Index index; - pair<MwmSet::MwmLock, bool> const p = - index.Register(LocalCountryFile::MakeForTesting("minsk-pass")); - TEST(p.first.IsLocked(), ()); - TEST(p.second, ()); + auto const p = index.Register(LocalCountryFile::MakeForTesting("minsk-pass")); + TEST(p.first.IsAlive(), ()); + TEST_EQUAL(MwmSet::RegResult::Success, p.second, ()); { search::HouseDetector houser(&index); @@ -274,10 +273,9 @@ UNIT_TEST(HS_FindHouseSmoke) classificator::Load(); Index index; - pair<MwmSet::MwmLock, bool> const p = - index.Register(LocalCountryFile::MakeForTesting("minsk-pass")); - TEST(p.first.IsLocked(), ()); - TEST(p.second, ()); + auto const p = index.Register(LocalCountryFile::MakeForTesting("minsk-pass")); + TEST(p.first.IsAlive(), ()); + TEST_EQUAL(MwmSet::RegResult::Success, p.second, ()); { vector<string> streetName(1, "Московская улица"); @@ -375,13 +373,13 @@ UNIT_TEST(HS_MWMSearch) } Index index; - pair<MwmSet::MwmLock, bool> const p = index.Register(LocalCountryFile::MakeForTesting(country)); - if (!p.second) + auto p = index.Register(LocalCountryFile::MakeForTesting(country)); + if (p.second != MwmSet::RegResult::Success) { LOG(LWARNING, ("MWM file not found")); return; } - TEST(p.first.IsLocked(), ()); + TEST(p.first.IsAlive(), ()); CollectStreetIDs streetIDs; index.ForEachInScale(streetIDs, scales::GetUpperScale()); diff --git a/search/search_tests/locality_finder_test.cpp b/search/search_tests/locality_finder_test.cpp index 62efda0f5e..b04dcaf686 100644 --- a/search/search_tests/locality_finder_test.cpp +++ b/search/search_tests/locality_finder_test.cpp @@ -38,12 +38,11 @@ void doTests2(search::LocalityFinder & finder, vector<m2::PointD> const & input, UNIT_TEST(LocalityFinder) { Index index; - pair<MwmSet::MwmLock, bool> const p = - index.Register(platform::LocalCountryFile::MakeForTesting("World")); - TEST(p.second, ()); - MwmSet::MwmLock const & lock = p.first; - TEST(lock.IsLocked(), ()); - shared_ptr<MwmInfo> info = lock.GetId().GetInfo(); + auto const p = index.Register(platform::LocalCountryFile::MakeForTesting("World")); + TEST_EQUAL(MwmSet::RegResult::Success, p.second, ()); + MwmSet::MwmHandle const & handle = p.first; + TEST(handle.IsAlive(), ()); + shared_ptr<MwmInfo> info = handle.GetId().GetInfo(); m2::RectD const & rect = info->m_limitRect; search::LocalityFinder finder(&index); |