From ed1e8104f8139b6b6bfc94f6b596eb2fce5c0ac8 Mon Sep 17 00:00:00 2001 From: tatiana-yan Date: Mon, 27 Apr 2020 13:56:10 +0300 Subject: [PATCH] [generator] Rename datFile to dataFile. --- generator/feature_generator.cpp | 9 +- generator/feature_generator.hpp | 4 +- generator/feature_sorter.cpp | 12 +-- generator/generator_tool/generator_tool.cpp | 101 ++++++++++---------- generator/wiki_url_dumper.hpp | 2 +- indexer/index_builder.cpp | 6 +- indexer/index_builder.hpp | 2 +- 7 files changed, 68 insertions(+), 68 deletions(-) diff --git a/generator/feature_generator.cpp b/generator/feature_generator.cpp index 39f97315d0..69d15ce14b 100644 --- a/generator/feature_generator.cpp +++ b/generator/feature_generator.cpp @@ -26,9 +26,10 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// namespace feature { - FeaturesCollector::FeaturesCollector(std::string const & fName, FileWriter::Op op) - : m_datFile(fName, op), m_writeBuffer(kBufferSize) {} + : m_dataFile(fName, op), m_writeBuffer(kBufferSize) +{ +} FeaturesCollector::~FeaturesCollector() { @@ -54,14 +55,14 @@ std::pair PackValue(ValueT v) void FeaturesCollector::FlushBuffer() { - m_datFile.Write(m_writeBuffer.data(), m_writePosition); + m_dataFile.Write(m_writeBuffer.data(), m_writePosition); m_writePosition = 0; } void FeaturesCollector::Flush() { FlushBuffer(); - m_datFile.Flush(); + m_dataFile.Flush(); } void FeaturesCollector::Write(char const * src, size_t size) diff --git a/generator/feature_generator.hpp b/generator/feature_generator.hpp index 97160019c1..624c1216b8 100644 --- a/generator/feature_generator.hpp +++ b/generator/feature_generator.hpp @@ -23,7 +23,7 @@ public: virtual ~FeaturesCollector(); static uint64_t GetCurrentPosition(); - std::string const & GetFilePath() const { return m_datFile.GetName(); } + std::string const & GetFilePath() const { return m_dataFile.GetName(); } /// \brief Serializes |f|. /// \returns Feature id of serialized feature if |f| is serialized after the call /// and |kInvalidFeatureId| if not. @@ -43,7 +43,7 @@ protected: uint32_t WriteFeatureBase(std::vector const & bytes, FeatureBuilder const & fb); void Flush(); - FileWriter m_datFile; + FileWriter m_dataFile; m2::RectD m_bounds; private: diff --git a/generator/feature_sorter.cpp b/generator/feature_sorter.cpp index a5eeb80472..0f3261c856 100644 --- a/generator/feature_sorter.cpp +++ b/generator/feature_sorter.cpp @@ -74,7 +74,7 @@ public: ~FeaturesCollector2() { // Check file size. - auto const unused = CheckedFilePosCast(m_datFile); + auto const unused = CheckedFilePosCast(m_dataFile); UNUSED_VALUE(unused); } @@ -119,7 +119,7 @@ public: coding::WritePadding(*w, bytesWritten); header.m_featuresOffset = base::asserted_cast(w->Pos() - startOffset); - ReaderSource src(make_unique(m_datFile.GetName())); + ReaderSource src(make_unique(m_dataFile.GetName())); rw::ReadAndWrite(src, *w); header.m_featuresSize = base::asserted_cast(w->Pos() - header.m_featuresOffset - startOffset); @@ -337,7 +337,7 @@ bool GenerateFinalFeatures(feature::GenerateInfo const & info, string const & na feature::DataHeader::MapType mapType) { string const srcFilePath = info.GetTmpFileName(name); - string const datFilePath = info.GetTargetFileName(name); + string const dataFilePath = info.GetTargetFileName(name); // Store cellIds for middle points. CalculateMidPoints midPoints; @@ -373,10 +373,10 @@ bool GenerateFinalFeatures(feature::GenerateInfo const & info, string const & na // Transform features from raw format to optimized format. try { - // FeaturesCollector2 will create temporary file `datFilePath + FEATURES_FILE_TAG`. + // FeaturesCollector2 will create temporary file `dataFilePath + FEATURES_FILE_TAG`. // We cannot remove it in ~FeaturesCollector2(), we need to remove it in SCOPE_GUARD. - SCOPE_GUARD(_, [&](){ Platform::RemoveFileIfExists(datFilePath + FEATURES_FILE_TAG); }); - FeaturesCollector2 collector(datFilePath, header, regionData, info.m_versionDate); + SCOPE_GUARD(_, [&]() { Platform::RemoveFileIfExists(dataFilePath + FEATURES_FILE_TAG); }); + FeaturesCollector2 collector(dataFilePath, header, regionData, info.m_versionDate); for (auto const & point : midPoints.GetVector()) { diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index be815ed5ef..9c6dec810c 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -318,14 +318,14 @@ MAIN_WITH_ERROR_HANDLING([](int argc, char ** argv) if (!FLAGS_dump_wikipedia_urls.empty()) { auto const tmpPath = base::JoinPath(genInfo.m_intermediateDir, "tmp"); - auto const datFiles = platform_helpers::GetFullDataTmpFilePaths(tmpPath); + auto const dataFiles = platform_helpers::GetFullDataTmpFilePaths(tmpPath); - WikiUrlDumper wikiUrlDumper(FLAGS_dump_wikipedia_urls, datFiles); + WikiUrlDumper wikiUrlDumper(FLAGS_dump_wikipedia_urls, dataFiles); wikiUrlDumper.Dump(threadsCount); if (!FLAGS_idToWikidata.empty()) { - WikiDataFilter wikiDataFilter(FLAGS_idToWikidata, datFiles); + WikiDataFilter wikiDataFilter(FLAGS_idToWikidata, dataFiles); wikiDataFilter.Filter(threadsCount); } } @@ -335,7 +335,7 @@ MAIN_WITH_ERROR_HANDLING([](int argc, char ** argv) for (size_t i = 0; i < count; ++i) { string const & country = genInfo.m_bucketNames[i]; - string const datFile = base::JoinPath(path, country + DATA_FILE_EXTENSION); + string const dataFile = base::JoinPath(path, country + DATA_FILE_EXTENSION); string const osmToFeatureFilename = genInfo.GetTargetFileName(country) + OSM2FEATURE_FILE_EXTENSION; @@ -355,8 +355,8 @@ MAIN_WITH_ERROR_HANDLING([](int argc, char ** argv) if (!feature::GenerateFinalFeatures(genInfo, country, mapType)) continue; - LOG(LINFO, ("Generating offsets table for", datFile)); - if (!feature::BuildOffsetsTable(datFile)) + LOG(LINFO, ("Generating offsets table for", dataFile)); + if (!feature::BuildOffsetsTable(dataFile)) continue; auto const boundaryPostcodesFilename = @@ -369,22 +369,22 @@ MAIN_WITH_ERROR_HANDLING([](int argc, char ** argv) string const metalinesFilename = genInfo.GetIntermediateFileName(METALINES_FILENAME); LOG(LINFO, ("Processing metalines from", metalinesFilename)); - if (!feature::WriteMetalinesSection(datFile, metalinesFilename, osmToFeatureFilename)) + if (!feature::WriteMetalinesSection(dataFile, metalinesFilename, osmToFeatureFilename)) LOG(LCRITICAL, ("Error generating metalines section.")); } } if (FLAGS_generate_index) { - LOG(LINFO, ("Generating index for", datFile)); + LOG(LINFO, ("Generating index for", dataFile)); - if (!indexer::BuildIndexFromDataFile(datFile, FLAGS_intermediate_data_path + country)) + if (!indexer::BuildIndexFromDataFile(dataFile, FLAGS_intermediate_data_path + country)) LOG(LCRITICAL, ("Error generating index.")); } if (FLAGS_generate_search_index) { - LOG(LINFO, ("Generating search index for", datFile)); + LOG(LINFO, ("Generating search index for", dataFile)); /// @todo Make threads count according to environment (single mwm build or planet build). if (!indexer::BuildSearchIndexFromDataFile(path, country, true /* forceRebuild */, @@ -421,35 +421,35 @@ MAIN_WITH_ERROR_HANDLING([](int argc, char ** argv) LOG(LCRITICAL, ("Error generating postcodes section for", country)); } - LOG(LINFO, ("Generating rank table for", datFile)); - if (!search::SearchRankTableBuilder::CreateIfNotExists(datFile)) + LOG(LINFO, ("Generating rank table for", dataFile)); + if (!search::SearchRankTableBuilder::CreateIfNotExists(dataFile)) LOG(LCRITICAL, ("Error generating rank table.")); - LOG(LINFO, ("Generating centers table for", datFile)); - if (!indexer::BuildCentersTableFromDataFile(datFile, true /* forceRebuild */)) + LOG(LINFO, ("Generating centers table for", dataFile)); + if (!indexer::BuildCentersTableFromDataFile(dataFile, true /* forceRebuild */)) LOG(LCRITICAL, ("Error generating centers table.")); } if (FLAGS_generate_cities_boundaries) { CHECK(!FLAGS_cities_boundaries_data.empty(), ()); - LOG(LINFO, ("Generating cities boundaries for", datFile)); + LOG(LINFO, ("Generating cities boundaries for", dataFile)); generator::OsmIdToBoundariesTable table; if (!generator::DeserializeBoundariesTable(FLAGS_cities_boundaries_data, table)) LOG(LCRITICAL, ("Error deserializing boundaries table")); - if (!generator::BuildCitiesBoundaries(datFile, osmToFeatureFilename, table)) + if (!generator::BuildCitiesBoundaries(dataFile, osmToFeatureFilename, table)) LOG(LCRITICAL, ("Error generating cities boundaries.")); } if (FLAGS_generate_cities_ids) { - LOG(LINFO, ("Generating cities ids for", datFile)); - if (!generator::BuildCitiesIds(datFile, osmToFeatureFilename)) + LOG(LINFO, ("Generating cities ids for", dataFile)); + if (!generator::BuildCitiesIds(dataFile, osmToFeatureFilename)) LOG(LCRITICAL, ("Error generating cities ids.")); } if (!FLAGS_srtm_path.empty()) - routing::BuildRoadAltitudes(datFile, FLAGS_srtm_path); + routing::BuildRoadAltitudes(dataFile, FLAGS_srtm_path); if (!FLAGS_transit_path.empty()) routing::transit::BuildTransit(path, country, osmToFeatureFilename, FLAGS_transit_path); @@ -465,7 +465,7 @@ MAIN_WITH_ERROR_HANDLING([](int argc, char ** argv) { string const camerasFilename = genInfo.GetIntermediateFileName(CAMERAS_TO_WAYS_FILENAME); - BuildCamerasInfo(datFile, camerasFilename, osmToFeatureFilename); + BuildCamerasInfo(dataFile, camerasFilename, osmToFeatureFilename); } } @@ -483,27 +483,27 @@ MAIN_WITH_ERROR_HANDLING([](int argc, char ** argv) string const restrictionsFilename = genInfo.GetIntermediateFileName(RESTRICTIONS_FILENAME); string const roadAccessFilename = genInfo.GetIntermediateFileName(ROAD_ACCESS_FILENAME); - routing::BuildRoutingIndex(datFile, country, *countryParentGetter); - routing::BuildRoadRestrictions(path, datFile, country, restrictionsFilename, + routing::BuildRoutingIndex(dataFile, country, *countryParentGetter); + routing::BuildRoadRestrictions(path, dataFile, country, restrictionsFilename, osmToFeatureFilename, *countryParentGetter); - routing::BuildRoadAccessInfo(datFile, roadAccessFilename, osmToFeatureFilename); + routing::BuildRoadAccessInfo(dataFile, roadAccessFilename, osmToFeatureFilename); } if (FLAGS_make_city_roads) { CHECK(!FLAGS_cities_boundaries_data.empty(), ()); - LOG(LINFO, ("Generating cities boundaries roads for", datFile)); + LOG(LINFO, ("Generating cities boundaries roads for", dataFile)); auto const boundariesPath = genInfo.GetIntermediateFileName(ROUTING_CITY_BOUNDARIES_DUMP_FILENAME); - if (!routing::BuildCityRoads(datFile, boundariesPath)) + if (!routing::BuildCityRoads(dataFile, boundariesPath)) LOG(LCRITICAL, ("Generating city roads error.")); } if (FLAGS_generate_maxspeed) { - LOG(LINFO, ("Generating maxspeeds section for", datFile)); + LOG(LINFO, ("Generating maxspeeds section for", dataFile)); string const maxspeedsFilename = genInfo.GetIntermediateFileName(MAXSPEEDS_FILENAME); - routing::BuildMaxspeedsSection(datFile, osmToFeatureFilename, maxspeedsFilename); + routing::BuildMaxspeedsSection(dataFile, osmToFeatureFilename, maxspeedsFilename); } if (FLAGS_make_cross_mwm || FLAGS_make_transit_cross_mwm) @@ -519,39 +519,39 @@ MAIN_WITH_ERROR_HANDLING([](int argc, char ** argv) if (FLAGS_make_cross_mwm) { - routing::BuildRoutingCrossMwmSection(path, datFile, country, genInfo.m_intermediateDir, + routing::BuildRoutingCrossMwmSection(path, dataFile, country, genInfo.m_intermediateDir, *countryParentGetter, osmToFeatureFilename, FLAGS_disable_cross_mwm_progress); } if (FLAGS_make_transit_cross_mwm) - routing::BuildTransitCrossMwmSection(path, datFile, country, *countryParentGetter); + routing::BuildTransitCrossMwmSection(path, dataFile, country, *countryParentGetter); } if (!FLAGS_ugc_data.empty()) { - if (!BuildUgcMwmSection(FLAGS_ugc_data, datFile, osmToFeatureFilename)) + if (!BuildUgcMwmSection(FLAGS_ugc_data, dataFile, osmToFeatureFilename)) LOG(LCRITICAL, ("Error generating UGC mwm section.")); - if (!BuildRatingsMwmSection(FLAGS_ugc_data, datFile, osmToFeatureFilename)) + if (!BuildRatingsMwmSection(FLAGS_ugc_data, dataFile, osmToFeatureFilename)) LOG(LCRITICAL, ("Error generating ratings mwm section.")); } if (!FLAGS_wikipedia_pages.empty()) { if (!FLAGS_idToWikidata.empty()) - BuildDescriptionsSection(FLAGS_wikipedia_pages, datFile, FLAGS_idToWikidata); + BuildDescriptionsSection(FLAGS_wikipedia_pages, dataFile, FLAGS_idToWikidata); else - BuildDescriptionsSection(FLAGS_wikipedia_pages, datFile); + BuildDescriptionsSection(FLAGS_wikipedia_pages, dataFile); } // This section must be built with the same isolines file as had been used at the features stage. if (FLAGS_generate_isolines_info) - BuildIsolinesInfoSection(FLAGS_isolines_path, country, datFile); + BuildIsolinesInfoSection(FLAGS_isolines_path, country, dataFile); if (FLAGS_generate_popular_places) { - if (!BuildPopularPlacesMwmSection(genInfo.m_popularPlacesFilename, datFile, + if (!BuildPopularPlacesMwmSection(genInfo.m_popularPlacesFilename, dataFile, osmToFeatureFilename)) { LOG(LCRITICAL, ("Error generating popular places mwm section.")); @@ -560,54 +560,53 @@ MAIN_WITH_ERROR_HANDLING([](int argc, char ** argv) if (FLAGS_generate_traffic_keys) { - if (!traffic::GenerateTrafficKeysFromDataFile(datFile)) + if (!traffic::GenerateTrafficKeysFromDataFile(dataFile)) LOG(LCRITICAL, ("Error generating traffic keys.")); } } - string const datFile = base::JoinPath(path, FLAGS_output + DATA_FILE_EXTENSION); + string const dataFile = base::JoinPath(path, FLAGS_output + DATA_FILE_EXTENSION); if (FLAGS_calc_statistics) { - LOG(LINFO, ("Calculating statistics for", datFile)); - + LOG(LINFO, ("Calculating statistics for", dataFile)); auto file = OfstreamWithExceptions(genInfo.GetIntermediateFileName(FLAGS_output, STATS_EXTENSION)); - stats::FileContainerStatistic(file, datFile); - stats::FileContainerStatistic(file, datFile + ROUTING_FILE_EXTENSION); + stats::FileContainerStatistic(file, dataFile); + stats::FileContainerStatistic(file, dataFile + ROUTING_FILE_EXTENSION); stats::MapInfo info; - stats::CalcStatistic(datFile, info); + stats::CalcStatistic(dataFile, info); stats::PrintStatistic(file, info); } if (FLAGS_type_statistics) { - LOG(LINFO, ("Calculating type statistics for", datFile)); + LOG(LINFO, ("Calculating type statistics for", dataFile)); stats::MapInfo info; - stats::CalcStatistic(datFile, info); + stats::CalcStatistic(dataFile, info); auto file = OfstreamWithExceptions(genInfo.GetIntermediateFileName(FLAGS_output, STATS_EXTENSION)); stats::PrintTypeStatistic(file, info); } if (FLAGS_dump_types) - feature::DumpTypes(datFile); + feature::DumpTypes(dataFile); if (FLAGS_dump_prefixes) - feature::DumpPrefixes(datFile); + feature::DumpPrefixes(dataFile); if (FLAGS_dump_search_tokens) - feature::DumpSearchTokens(datFile, 100 /* maxTokensToShow */); + feature::DumpSearchTokens(dataFile, 100 /* maxTokensToShow */); if (FLAGS_dump_feature_names != "") - feature::DumpFeatureNames(datFile, FLAGS_dump_feature_names); + feature::DumpFeatureNames(dataFile, FLAGS_dump_feature_names); if (FLAGS_unpack_mwm) - UnpackMwm(datFile); + UnpackMwm(dataFile); if (!FLAGS_delete_section.empty()) - DeleteSection(datFile, FLAGS_delete_section); + DeleteSection(dataFile, FLAGS_delete_section); if (FLAGS_generate_packed_borders) borders::GeneratePackedBorders(path); @@ -616,7 +615,7 @@ MAIN_WITH_ERROR_HANDLING([](int argc, char ** argv) borders::UnpackBorders(path, FLAGS_unpack_borders); if (FLAGS_check_mwm) - check_model::ReadFeatures(datFile); + check_model::ReadFeatures(dataFile); return EXIT_SUCCESS; }); diff --git a/generator/wiki_url_dumper.hpp b/generator/wiki_url_dumper.hpp index 24ea1435f1..154e12695f 100644 --- a/generator/wiki_url_dumper.hpp +++ b/generator/wiki_url_dumper.hpp @@ -12,7 +12,7 @@ namespace generator class WikiUrlDumper { public: - explicit WikiUrlDumper(std::string const & path, std::vector const & datFiles); + explicit WikiUrlDumper(std::string const & path, std::vector const & dataFiles); static void DumpOne(std::string const & path, std::ostream & stream); diff --git a/indexer/index_builder.cpp b/indexer/index_builder.cpp index 2da66f9049..87729b687d 100644 --- a/indexer/index_builder.cpp +++ b/indexer/index_builder.cpp @@ -8,19 +8,19 @@ namespace indexer { - bool BuildIndexFromDataFile(std::string const & datFile, std::string const & tmpFile) + bool BuildIndexFromDataFile(std::string const & dataFile, std::string const & tmpFile) { try { std::string const idxFileName(tmpFile + GEOM_INDEX_TMP_EXT); { - FeaturesVectorTest features(datFile); + FeaturesVectorTest features(dataFile); FileWriter writer(idxFileName); BuildIndex(features.GetHeader(), features.GetVector(), writer, tmpFile); } - FilesContainerW(datFile, FileWriter::OP_WRITE_EXISTING).Write(idxFileName, INDEX_FILE_TAG); + FilesContainerW(dataFile, FileWriter::OP_WRITE_EXISTING).Write(idxFileName, INDEX_FILE_TAG); FileWriter::DeleteFileX(idxFileName); } catch (Reader::Exception const & e) diff --git a/indexer/index_builder.hpp b/indexer/index_builder.hpp index f3f3c178de..8e1193c663 100644 --- a/indexer/index_builder.hpp +++ b/indexer/index_builder.hpp @@ -22,5 +22,5 @@ void BuildIndex(feature::DataHeader const & header, TFeaturesVector const & feat } // doesn't throw exceptions - bool BuildIndexFromDataFile(std::string const & datFile, std::string const & tmpFile); + bool BuildIndexFromDataFile(std::string const & dataFile, std::string const & tmpFile); } // namespace indexer