diff options
author | Yury Melnichek <melnichek@malinovka.local> | 2011-08-26 01:10:15 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:22:32 +0300 |
commit | 31f2a764cd99e2e184233b017218bb4064d28751 (patch) | |
tree | 2a54feb81c09cae28f16e79b75c6fc2731e7521a | |
parent | 940c975a933069485234682335bfcb18ecad8508 (diff) |
Fix bug when some feature were omitted from ForEachInRect. Remove Query class, since it's not used anywhere.
-rw-r--r-- | indexer/index.hpp | 88 | ||||
-rw-r--r-- | indexer/interval_index.hpp | 18 | ||||
-rw-r--r-- | indexer/interval_index_iface.hpp | 8 | ||||
-rw-r--r-- | indexer/old/interval_index_101.hpp | 32 | ||||
-rw-r--r-- | indexer/scale_index.hpp | 6 | ||||
-rw-r--r-- | map/feature_vec_model.hpp | 3 | ||||
-rw-r--r-- | search/query.hpp | 1 |
7 files changed, 31 insertions, 125 deletions
diff --git a/indexer/index.hpp b/indexer/index.hpp index ff91666b1d..172d8c47a0 100644 --- a/indexer/index.hpp +++ b/indexer/index.hpp @@ -32,87 +32,56 @@ template <class BaseT> class IndexForEachAdapter : public BaseT { -public: - typedef typename BaseT::Query Query; - private: template <typename F> void CallForIntervals(F const & f, covering::IntervalsT const & intervals, - m2::RectD const & rect, uint32_t scale, Query & query) const + m2::RectD const & rect, uint32_t scale) const { for (size_t i = 0; i < intervals.size(); ++i) { BaseT::ForEachInIntervalAndScale(f, intervals[i].first, intervals[i].second, - scale, rect, query); + scale, rect); } } +public: template <typename F> - void ForEachInRect(F const & f, m2::RectD const & rect, uint32_t scale, Query & query) const + void ForEachInRect(F const & f, m2::RectD const & rect, uint32_t scale) const { - CallForIntervals(f, covering::CoverViewportAndAppendLowerLevels(rect), rect, scale, query); + CallForIntervals(f, covering::CoverViewportAndAppendLowerLevels(rect), rect, scale); } template <typename F> - void ForEachInRect_TileDrawing(F const & f, m2::RectD const & rect, uint32_t scale, Query & query) const + void ForEachInRect_TileDrawing(F const & f, m2::RectD const & rect, uint32_t scale) const { using namespace covering; IntervalsT intervals; AppendLowerLevels(GetRectIdAsIs(rect), intervals); - CallForIntervals(f, intervals, rect, scale, query); + CallForIntervals(f, intervals, rect, scale); } public: - template <typename F> - void ForEachInRect(F const & f, m2::RectD const & rect, uint32_t scale) const - { - Query query; - ForEachInRect(f, rect, scale, query); - } - - template <typename F> - void ForEachInRect_TileDrawing(F const & f, m2::RectD const & rect, uint32_t scale) const - { - Query query; - ForEachInRect_TileDrawing(f, rect, scale, query); - } - - template <typename F> - void ForEachInViewport(F const & f, m2::RectD const & viewport, Query & query) const - { - ForEachInRect(f, viewport, scales::GetScaleLevel(viewport), query); - } template <typename F> void ForEachInViewport(F const & f, m2::RectD const & viewport) const { - Query query; - ForEachInViewport(f, viewport, query); + ForEachInRect(f, viewport, scales::GetScaleLevel(viewport)); } template <typename F> - void ForEachInScale(F const & f, uint32_t scale, Query & query) const + void ForEachInScale(F const & f, uint32_t scale) const { int64_t const rootId = RectId("").ToInt64(); BaseT::ForEachInIntervalAndScale(f, rootId, rootId + RectId("").SubTreeSize(), scale, - m2::RectD::GetInfiniteRect(), query); - } - - template <typename F> - void ForEachInScale(F const & f, uint32_t scale) const - { - Query query; - ForEachInScale(f, scale, query); + m2::RectD::GetInfiniteRect()); } }; template <class IndexT> class MultiIndexAdapter { public: - typedef typename IndexT::Query Query; - MultiIndexAdapter() { } @@ -134,7 +103,7 @@ public: template <typename F> void ForEachInIntervalAndScale(F const & f, int64_t beg, int64_t end, uint32_t scale, - m2::RectD const & occlusionRect, Query & query) const + m2::RectD const & occlusionRect) const { for (size_t iIndex = 0; true;) { @@ -163,7 +132,7 @@ public: { ProxyUnlockGuard proxyUnlockGuard(m_mutex, pProxy); UNUSED_VALUE(proxyUnlockGuard); - pIndex->ForEachInIntervalAndScale(f, beg, end, scale, query); + pIndex->ForEachInIntervalAndScale(f, beg, end, scale); } } } @@ -425,8 +394,6 @@ private: template <class FeatureVectorT, class BaseT> class OffsetToFeatureAdapter : public BaseT { public: - typedef typename BaseT::Query Query; - OffsetToFeatureAdapter(FilesContainerR const & cont, IndexFactory & factory) : BaseT(cont.GetReader(INDEX_FILE_TAG), factory), m_FeatureVector(cont, factory.GetHeader()) @@ -434,11 +401,10 @@ public: } template <typename F> - void ForEachInIntervalAndScale(F const & f, int64_t beg, int64_t end, uint32_t scale, - Query & query) const + void ForEachInIntervalAndScale(F const & f, int64_t beg, int64_t end, uint32_t scale) const { OffsetToFeatureReplacer<F> offsetToFeatureReplacer(m_FeatureVector, f); - BaseT::ForEachInIntervalAndScale(offsetToFeatureReplacer, beg, end, scale, query); + BaseT::ForEachInIntervalAndScale(offsetToFeatureReplacer, beg, end, scale); } private: @@ -464,24 +430,6 @@ private: template <class BaseT> class UniqueOffsetAdapter : public BaseT { public: - // Defines base Query type. - class Query : public BaseT::Query - { - public: - // Clear query, so that it can be reused. - // This function doesn't release caches! - void Clear() - { - m_Offsets.clear(); - BaseT::Query::Clear(); - } - - private: - // TODO: Remember max offsets.size() and initialize offsets with it? - unordered_set<uint32_t> m_Offsets; - friend class UniqueOffsetAdapter; - }; - template <typename T1> explicit UniqueOffsetAdapter(T1 const & t1) : BaseT(t1) {} @@ -489,11 +437,11 @@ public: UniqueOffsetAdapter(T1 const & t1, T2 & t2) : BaseT(t1, t2) {} template <typename F> - void ForEachInIntervalAndScale(F const & f, int64_t beg, int64_t end, uint32_t scale, - Query & query) const + void ForEachInIntervalAndScale(F const & f, int64_t beg, int64_t end, uint32_t scale) const { - UniqueOffsetFunctorAdapter<F> uniqueOffsetFunctorAdapter(query.m_Offsets, f); - BaseT::ForEachInIntervalAndScale(uniqueOffsetFunctorAdapter, beg, end, scale, query); + unordered_set<uint32_t> offsets; + UniqueOffsetFunctorAdapter<F> uniqueOffsetFunctorAdapter(offsets, f); + BaseT::ForEachInIntervalAndScale(uniqueOffsetFunctorAdapter, beg, end, scale); } private: diff --git a/indexer/interval_index.hpp b/indexer/interval_index.hpp index 312cb095a4..61d7b330bb 100644 --- a/indexer/interval_index.hpp +++ b/indexer/interval_index.hpp @@ -45,13 +45,6 @@ class IntervalIndex : public IntervalIndexBase { typedef IntervalIndexBase base_t; public: - class Query : public base_t::QueryIFace - { - public: - void Clear() {} - private: - // TODO: Add IntervalIndex cache here. - }; explicit IntervalIndex(ReaderT const & reader) : m_Reader(reader) { @@ -69,7 +62,7 @@ public: } template <typename F> - void ForEach(F const & f, uint64_t beg, uint64_t end, Query &) const + void ForEach(F const & f, uint64_t beg, uint64_t end) const { if (m_Header.m_Levels != 0 && beg != end) { @@ -81,14 +74,7 @@ public: } } - template <typename F> - void ForEach(F const & f, uint64_t beg, uint64_t end) const - { - Query query; - ForEach(f, beg, end, query); - } - - virtual void DoForEach(FunctionT const & f, uint64_t beg, uint64_t end, QueryIFace & /*query*/) + virtual void DoForEach(FunctionT const & f, uint64_t beg, uint64_t end) { ForEach(f, beg, end); } diff --git a/indexer/interval_index_iface.hpp b/indexer/interval_index_iface.hpp index 879ee59eb9..7d2ce81c8e 100644 --- a/indexer/interval_index_iface.hpp +++ b/indexer/interval_index_iface.hpp @@ -7,13 +7,7 @@ class IntervalIndexIFace public: virtual ~IntervalIndexIFace() {} - class QueryIFace - { - public: - virtual ~QueryIFace() {} - }; - typedef function<void (uint32_t)> FunctionT; - virtual void DoForEach(FunctionT const & f, uint64_t beg, uint64_t end, QueryIFace & query) = 0; + virtual void DoForEach(FunctionT const & f, uint64_t beg, uint64_t end) = 0; }; diff --git a/indexer/old/interval_index_101.hpp b/indexer/old/interval_index_101.hpp index 2a72c841fe..fd2d4bfd65 100644 --- a/indexer/old/interval_index_101.hpp +++ b/indexer/old/interval_index_101.hpp @@ -49,16 +49,6 @@ class IntervalIndex : public IntervalIndexBase public: - class Query : public base_t::QueryIFace - { - public: - void Clear() {} - - private: - friend class IntervalIndex; - vector<char> m_IntervalIndexCache; - }; - IntervalIndex(ReaderT const & reader, int cellIdBytes = 5) : m_Reader(reader), m_CellIdBytes(cellIdBytes) { @@ -67,31 +57,23 @@ public: } template <typename F> - void ForEach(F const & f, uint64_t beg, uint64_t end, Query & query) const + void ForEach(F const & f, uint64_t beg, uint64_t end) const { ASSERT_LESS(beg, 1ULL << 8 * m_CellIdBytes, (beg, end)); ASSERT_LESS_OR_EQUAL(end, 1ULL << 8 * m_CellIdBytes, (beg, end)); // end is inclusive in ForEachImpl(). --end; - ForEachImpl(f, beg, end, m_Level0Index, m_CellIdBytes - 1, query); - } - - template <typename F> - void ForEach(F const & f, uint64_t beg, uint64_t end) const - { - Query query; - ForEach(f, beg, end, query); + ForEachImpl(f, beg, end, m_Level0Index, m_CellIdBytes - 1); } - virtual void DoForEach(FunctionT const & f, uint64_t beg, uint64_t end, QueryIFace & /*query*/) + virtual void DoForEach(FunctionT const & f, uint64_t beg, uint64_t end) { ForEach(f, beg, end); } private: template <typename F> - void ForEachImpl(F const & f, uint64_t beg, uint64_t end, Index const & index, int level, - Query & query) const + void ForEachImpl(F const & f, uint64_t beg, uint64_t end, Index const & index, int level) const { uint32_t const beg0 = static_cast<uint32_t>(beg >> (8 * level)); uint32_t const end0 = static_cast<uint32_t>(end >> (8 * level)); @@ -110,7 +92,7 @@ private: { Index index1; ReadIndex(index.GetBaseOffset() + (cumCount * sizeof(Index)), index1); - ForEachImpl(f, b1, e1, index1, level - 1, query); + ForEachImpl(f, b1, e1, index1, level - 1); } else { @@ -119,8 +101,8 @@ private: uint32_t const count = index.m_Count[i]; uint32_t pos = index.GetBaseOffset() + (cumCount * step); size_t const readSize = step * count; - query.m_IntervalIndexCache.assign(readSize, 0); - char * pData = &query.m_IntervalIndexCache[0]; + vector<char> dataCache(readSize, 0); + char * pData = &dataCache[0]; m_Reader.Read(pos, pData, readSize); for (uint32_t j = 0; j < count; ++j, pData += step) // for (uint32_t j = 0; j < count; ++j, pos += step) diff --git a/indexer/scale_index.hpp b/indexer/scale_index.hpp index ecbc4f0df5..826bb22f2d 100644 --- a/indexer/scale_index.hpp +++ b/indexer/scale_index.hpp @@ -62,7 +62,6 @@ class ScaleIndex : public ScaleIndexBase { public: typedef ReaderT ReaderType; - typedef typename IntervalIndexIFace::QueryIFace Query; ScaleIndex() {} explicit ScaleIndex(ReaderT const & reader, IndexFactory & factory) @@ -91,13 +90,12 @@ public: } template <typename F> - void ForEachInIntervalAndScale(F const & f, uint64_t beg, uint64_t end, uint32_t scale, - Query & query) const + void ForEachInIntervalAndScale(F const & f, uint64_t beg, uint64_t end, uint32_t scale) const { size_t const scaleBucket = BucketByScale(scale); if (scaleBucket < m_IndexForScale.size()) for (size_t i = 0; i <= scaleBucket; ++i) - m_IndexForScale[i]->DoForEach(bind<void>(ref(f), _1), beg, end, query); + m_IndexForScale[i]->DoForEach(bind<void>(ref(f), _1), beg, end); } private: diff --git a/map/feature_vec_model.hpp b/map/feature_vec_model.hpp index d9c439a87e..642c937ed6 100644 --- a/map/feature_vec_model.hpp +++ b/map/feature_vec_model.hpp @@ -45,8 +45,7 @@ namespace model template <class ToDo> void ForEachFeature(m2::RectD const & rect, ToDo toDo) const { - index_t::Query query; - m_multiIndex.ForEachInViewport(toDo, rect, query); + m_multiIndex.ForEachInViewport(toDo, rect); // Uncomment to traverse all features (SLOW!!): // m_multiIndex.ForEachInScale(toDo, GetScaleLevel(rect)); } diff --git a/search/query.hpp b/search/query.hpp index 9f841b01e4..356259665c 100644 --- a/search/query.hpp +++ b/search/query.hpp @@ -67,7 +67,6 @@ private: strings::UniString m_prefix; scoped_ptr<IndexType const> m_pIndex; - IndexType::Query m_indexQuery; priority_queue<IntermediateResult> m_results; int m_resultsRemaining; |