Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2018-07-03 16:07:21 +0300
committerIlya Zverev <ilya@zverev.info>2018-07-03 16:22:29 +0300
commit0429997605e2cf7ffd3c2dfff7e5c69bacdeb369 (patch)
tree2162fd08b42bfca01f6461b3db0955440d4826b4
parent2de3574160138fa77f086a8017207552b782d60d (diff)
[generator][search] review fixes
-rw-r--r--defines.hpp2
-rw-r--r--generator/generator_tool/generator_tool.cpp2
-rw-r--r--generator/popular_places_section_builder.cpp38
-rw-r--r--indexer/rank_table.cpp12
-rw-r--r--search/intermediate_result.hpp2
-rw-r--r--search/pre_ranker.cpp5
-rw-r--r--search/result.cpp2
7 files changed, 34 insertions, 29 deletions
diff --git a/defines.hpp b/defines.hpp
index 156ef54d28..8a485a4af6 100644
--- a/defines.hpp
+++ b/defines.hpp
@@ -40,7 +40,7 @@
#define CROSS_MWM_FILE_TAG "cross_mwm"
#define FEATURE_OFFSETS_FILE_TAG "offs"
#define SEARCH_RANKS_FILE_TAG "ranks"
-#define POPULARITY_RANKS_FILE_TAG "popularity_ranks"
+#define POPULARITY_RANKS_FILE_TAG "popularity"
#define REGION_INFO_FILE_TAG "rgninfo"
#define METALINES_FILE_TAG "metalines"
// Temporary addresses section that is used in search index generation.
diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp
index 93639d7867..aebcd74bb1 100644
--- a/generator/generator_tool/generator_tool.cpp
+++ b/generator/generator_tool/generator_tool.cpp
@@ -127,9 +127,7 @@ DEFINE_string(booking_data, "", "Path to booking data in .tsv format.");
DEFINE_string(opentable_data, "", "Path to opentable data in .tsv format.");
DEFINE_string(viator_data, "", "Path to viator data in .tsv format.");
-// UGC
DEFINE_string(ugc_data, "", "Input UGC source database file name");
-// Pipular places
DEFINE_string(popular_places_data, "", "Input Popular Places source file name");
// Printing stuff.
diff --git a/generator/popular_places_section_builder.cpp b/generator/popular_places_section_builder.cpp
index 20ef44a870..2f9cdb78f6 100644
--- a/generator/popular_places_section_builder.cpp
+++ b/generator/popular_places_section_builder.cpp
@@ -2,6 +2,7 @@
#include "generator/gen_mwm_info.hpp"
#include "generator/ugc_translator.hpp"
+#include "generator/utils.hpp"
#include "ugc/binary/index_ugc.hpp"
#include "ugc/binary/serdes.hpp"
@@ -14,8 +15,11 @@
#include "base/osm_id.hpp"
#include "base/string_utils.hpp"
+#include <cstdint>
+#include <limits>
#include <unordered_map>
#include <utility>
+#include <vector>
namespace
{
@@ -50,13 +54,14 @@ void LoadPopularPlaces(std::string const & srcFilename, PopularPlaces & places)
if (popularityIndex > std::numeric_limits<PopularityIndex>::max())
{
LOG(LERROR, ("The popularity index value is higher than max supported value:", srcFilename,
- "parsed row:", row));
+ "parsed row:", row));
return;
}
+
osm::Id id(osmId);
- auto const result = places.emplace(id, static_cast<PopularityIndex>(popularityIndex));
+ auto const result = places.emplace(std::move(id), static_cast<PopularityIndex>(popularityIndex));
- if (result.second == false)
+ if (!result.second)
{
LOG(LERROR, ("Popular place duplication in file:", srcFilename, "parsed row:", row));
return;
@@ -74,27 +79,28 @@ bool BuildPopularPlacesMwmSection(std::string const & srcFilename, std::string c
LOG(LINFO, ("Build Popular Places section"));
- gen::OsmID2FeatureID osmIdsToFeatureIds;
- if (!osmIdsToFeatureIds.ReadFromFile(osmToFeatureFilename))
- return false;
-
- std::unordered_map<uint32_t, osm::Id> featureToOsmId;
- osmIdsToFeatureIds.ForEach([&featureToOsmId](gen::OsmID2FeatureID::ValueT const & p) {
- featureToOsmId.emplace(p.second /* feature id */, p.first /* osm id */);
- });
+ std::unordered_map<uint32_t, osm::Id> featureIdToOsmId;
+ ForEachOsmId2FeatureId(osmToFeatureFilename,
+ [&featureIdToOsmId](osm::Id const & osmId, uint32_t fId)
+ {
+ featureIdToOsmId.emplace(fId, osmId);
+ });
PopularPlaces places;
LoadPopularPlaces(srcFilename, places);
bool popularPlaceFound = false;
- std::vector<uint8_t> content;
- feature::ForEachFromDat(mwmFile, [&](FeatureType const & f, uint32_t featureId) {
- auto const it = featureToOsmId.find(featureId);
- CHECK(it != featureToOsmId.cend(),
+ std::vector<PopularityIndex> content;
+ feature::ForEachFromDat(mwmFile, [&](FeatureType const & f, uint32_t featureId)
+ {
+ ASSERT_EQUAL(content.size(), featureId, ());
+
+ auto const it = featureIdToOsmId.find(featureId);
+ CHECK(it != featureIdToOsmId.cend(),
("FeatureID", featureId, "is not found in", osmToFeatureFilename));
- uint32_t rank = 0;
+ PopularityIndex rank = 0;
auto const placesIt = places.find(it->second);
if (placesIt != places.cend())
diff --git a/indexer/rank_table.cpp b/indexer/rank_table.cpp
index e0f2f19d67..0424462d8f 100644
--- a/indexer/rank_table.cpp
+++ b/indexer/rank_table.cpp
@@ -170,7 +170,7 @@ private:
// Following two functions create a rank section and serialize |table|
// to it. If there was an old section with ranks, these functions
// overwrite it.
-void SerializeRankTable(RankTable & table, FilesContainerW & wcont, std::string const & sectionName)
+void SerializeRankTable(RankTable & table, FilesContainerW & wcont, string const & sectionName)
{
if (wcont.IsExist(sectionName))
wcont.DeleteSection(sectionName);
@@ -186,7 +186,7 @@ void SerializeRankTable(RankTable & table, FilesContainerW & wcont, std::string
wcont.Finish();
}
-void SerializeRankTable(RankTable & table, string const & mapPath, std::string const & sectionName)
+void SerializeRankTable(RankTable & table, string const & mapPath, string const & sectionName)
{
FilesContainerW wcont(mapPath, FileWriter::OP_WRITE_EXISTING);
SerializeRankTable(table, wcont, sectionName);
@@ -253,7 +253,7 @@ uint8_t CalcSearchRank(FeatureType const & ft)
// Creates rank table if it does not exists in |rcont| or has wrong
// endianness. Otherwise (table exists and has correct format) returns
// null.
-unique_ptr<RankTable> CreateRankTableIfNotExists(FilesContainerR & rcont)
+unique_ptr<RankTable> CreateSearchRankTableIfNotExists(FilesContainerR & rcont)
{
unique_ptr<RankTable> table;
@@ -335,7 +335,7 @@ bool SearchRankTableBuilder::CreateIfNotExists(platform::LocalCountryFile const
mapPath = reader.GetName();
FilesContainerR rcont(reader);
- table = CreateRankTableIfNotExists(rcont);
+ table = CreateSearchRankTableIfNotExists(rcont);
}
if (table)
@@ -358,7 +358,7 @@ bool SearchRankTableBuilder::CreateIfNotExists(string const & mapPath) noexcept
unique_ptr<RankTable> table;
{
FilesContainerR rcont(mapPath);
- table = CreateRankTableIfNotExists(rcont);
+ table = CreateSearchRankTableIfNotExists(rcont);
}
if (table)
@@ -375,7 +375,7 @@ bool SearchRankTableBuilder::CreateIfNotExists(string const & mapPath) noexcept
// static
void RankTableBuilder::Create(vector<uint8_t> const & ranks, FilesContainerW & wcont,
- std::string const & sectionName)
+ string const & sectionName)
{
RankTableV0 table(ranks);
SerializeRankTable(table, wcont, sectionName);
diff --git a/search/intermediate_result.hpp b/search/intermediate_result.hpp
index 8b5b10de6b..a2cd42ff20 100644
--- a/search/intermediate_result.hpp
+++ b/search/intermediate_result.hpp
@@ -34,7 +34,7 @@ public:
static bool LessRank(PreRankerResult const & r1, PreRankerResult const & r2);
static bool LessDistance(PreRankerResult const & r1, PreRankerResult const & r2);
- FeatureID GetId() const { return m_id; }
+ FeatureID const & GetId() const { return m_id; }
double GetDistance() const { return m_info.m_distanceToPivot; }
uint8_t GetRank() const { return m_info.m_rank; }
uint8_t GetPopularity() const { return m_info.m_popularity; }
diff --git a/search/pre_ranker.cpp b/search/pre_ranker.cpp
index 773ff83320..4ed40dea2b 100644
--- a/search/pre_ranker.cpp
+++ b/search/pre_ranker.cpp
@@ -94,11 +94,12 @@ void PreRanker::FillMissingFieldsInPreResults()
}
if (!ranks)
ranks = make_unique<DummyRankTable>();
+ if (!popularityRanks)
+ popularityRanks = make_unique<DummyRankTable>();
}
info.m_rank = ranks->Get(id.m_index);
- if (popularityRanks)
- info.m_popularity = popularityRanks->Get(id.m_index);
+ info.m_popularity = popularityRanks->Get(id.m_index);
m2::PointD center;
if (centers && centers->Get(id.m_index, center))
diff --git a/search/result.cpp b/search/result.cpp
index 28c0392f7a..1289dd6732 100644
--- a/search/result.cpp
+++ b/search/result.cpp
@@ -274,7 +274,7 @@ void Results::InsertResult(vector<Result>::iterator where, Result && result)
m_results.insert(where, move(result));
}
-std::string DebugPrint(search::Results const & results)
+string DebugPrint(search::Results const & results)
{
return ::my::impl::DebugPrintSequence(results.begin(), results.end());
}