From f8209a898160a146cf22cf127989c07834f4e085 Mon Sep 17 00:00:00 2001 From: vng Date: Sat, 11 Feb 2012 00:34:31 +0300 Subject: [search] Fix bug with points coding in search index generation. --- generator/dumper.cpp | 3 +-- indexer/search_index_builder.cpp | 7 ++++--- indexer/search_trie.hpp | 7 ++++++- search/search_query.cpp | 3 +-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/generator/dumper.cpp b/generator/dumper.cpp index d03fb66254..8053344fa6 100644 --- a/generator/dumper.cpp +++ b/generator/dumper.cpp @@ -202,8 +202,7 @@ namespace feature feature::DataHeader header; header.Load(container.GetReader(HEADER_FILE_TAG)); - serial::CodingParams cp(search::POINT_CODING_BITS, - header.GetDefCodingParams().GetBasePointUint64()); + serial::CodingParams cp(search::GetCPForTrie(header.GetDefCodingParams())); scoped_ptr pTrieRoot( ::trie::reader::ReadTrie(container.GetReader(SEARCH_INDEX_FILE_TAG), diff --git a/indexer/search_index_builder.cpp b/indexer/search_index_builder.cpp index 5d47d063ff..2b20e112cb 100644 --- a/indexer/search_index_builder.cpp +++ b/indexer/search_index_builder.cpp @@ -164,8 +164,7 @@ void indexer::BuildSearchIndex(FeaturesVector const & featuresVector, Writer & w { { StringsFile names(tmpFilePath); - serial::CodingParams cp(search::POINT_CODING_BITS, - featuresVector.GetCodingParams().GetBasePointUint64()); + serial::CodingParams cp(search::GetCPForTrie(featuresVector.GetCodingParams())); featuresVector.ForEachOffset(FeatureInserter(names, cp)); @@ -182,7 +181,7 @@ void indexer::BuildSearchIndex(FeaturesVector const & featuresVector, Writer & w bool indexer::BuildSearchIndexFromDatFile(string const & fName) { - LOG(LINFO, ("Start building search index ...")); + LOG(LINFO, ("Start building search index. Bits = ", search::POINT_CODING_BITS)); try { @@ -200,6 +199,8 @@ bool indexer::BuildSearchIndexFromDatFile(string const & fName) FileWriter writer(tmpFile); BuildSearchIndex(featuresVector, writer, pl.WritablePathForFile(fName + ".search_index_1.tmp")); + + LOG(LINFO, ("Search index size = ", writer.Size())); } { diff --git a/indexer/search_trie.hpp b/indexer/search_trie.hpp index cd899f19ed..f44d8b5166 100644 --- a/indexer/search_trie.hpp +++ b/indexer/search_trie.hpp @@ -51,6 +51,11 @@ typedef ::trie::reader::EmptyValueReader EdgeValueReader; trie::EdgeValueReader::ValueType> TrieIterator; static const uint8_t CATEGORIES_LANG = 128; - static const uint8_t POINT_CODING_BITS = 24; + static const uint8_t POINT_CODING_BITS = 20; + inline serial::CodingParams GetCPForTrie(serial::CodingParams const & orig) + { + CoordPointT const p = PointU2PointD(orig.GetBasePoint(), orig.GetCoordBits()); + return serial::CodingParams(POINT_CODING_BITS, m2::PointD(p.first, p.second)); + } } // namespace search diff --git a/search/search_query.cpp b/search/search_query.cpp index bd6049a009..9d8b0fba1f 100644 --- a/search/search_query.cpp +++ b/search/search_query.cpp @@ -629,8 +629,7 @@ void Query::SearchFeatures(vector > const & tokens, if (pMwm->m_cont.IsReaderExist(SEARCH_INDEX_FILE_TAG)) { feature::DataHeader const & header = pMwm->GetHeader(); - serial::CodingParams cp(POINT_CODING_BITS, - header.GetDefCodingParams().GetBasePointUint64()); + serial::CodingParams cp(GetCPForTrie(header.GetDefCodingParams())); scoped_ptr pTrieRoot(::trie::reader::ReadTrie( pMwm->m_cont.GetReader(SEARCH_INDEX_FILE_TAG), -- cgit v1.2.3