diff --git a/coding/file_container.cpp b/coding/file_container.cpp index f0868c2ed4..453b2322bd 100644 --- a/coding/file_container.cpp +++ b/coding/file_container.cpp @@ -17,7 +17,7 @@ #endif -template void Read(TSource & src, FilesContainerBase::Info & i) +template void Read(TSource & src, InfoT & i) { rw::Read(src, i.m_tag); @@ -25,7 +25,7 @@ template void Read(TSource & src, FilesContainerBase::Info & i) i.m_size = ReadVarUint(src); } -template void Write(TSink & sink, FilesContainerBase::Info const & i) +template void Write(TSink & sink, InfoT const & i) { rw::Write(sink, i.m_tag); diff --git a/coding/file_container.hpp b/coding/file_container.hpp index 89af73b54a..54ae5ed2bc 100644 --- a/coding/file_container.hpp +++ b/coding/file_container.hpp @@ -12,6 +12,12 @@ class FilesContainerBase public: typedef string Tag; + bool IsExist(Tag const & tag) const + { + return GetInfo(tag) != 0; + } + +protected: struct Info { Tag m_tag; @@ -20,18 +26,12 @@ public: Info() {} Info(Tag const & tag, uint64_t offset) : m_tag(tag), m_offset(offset) {} - - friend string DebugPrint(Info const & info); }; + friend string DebugPrint(Info const & info); + Info const * GetInfo(Tag const & tag) const; - bool IsExist(Tag const & tag) const - { - return GetInfo(tag) != 0; - } - -protected: struct LessInfo { bool operator() (Info const & t1, Info const & t2) const @@ -87,6 +87,12 @@ protected: template void ReadInfo(ReaderT & reader); + +public: + template void ForEachTag(ToDo toDo) const + { + for_each(m_info.begin(), m_info.end(), toDo); + } }; class FilesContainerR : public FilesContainerBase diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index d183851f77..0e7cce858f 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -230,6 +230,7 @@ int main(int argc, char ** argv) LOG(LINFO, ("Calculating statistics for ", datFile)); stats::FileContainerStatistic(datFile); + stats::FileContainerStatistic(datFile + ROUTING_FILE_EXTENSION); stats::MapInfo info; stats::CalcStatistic(datFile, info); diff --git a/generator/routing_generator.cpp b/generator/routing_generator.cpp index b5f7f659b9..aa84c46fa9 100644 --- a/generator/routing_generator.cpp +++ b/generator/routing_generator.cpp @@ -1,14 +1,15 @@ #include "routing_generator.hpp" #include "gen_mwm_info.hpp" -#include "../coding/file_container.hpp" - #include "../indexer/index.hpp" #include "../indexer/classificator_loader.hpp" #include "../indexer/feature.hpp" #include "../indexer/ftypes_matcher.hpp" #include "../indexer/mercator.hpp" +#include "../coding/file_container.hpp" +#include "../coding/internal/file_data.hpp" + #include "../geometry/distance_on_sphere.hpp" #include "../routing/osrm2feature_map.hpp" @@ -193,13 +194,13 @@ void GenerateNodesInfo(string const & mwmName, string const & osrmName) LOG(LINFO, ("All:", all, "Found:", found, "Not found:", all - found, "More that one segs in node:", moreThan1Seg, "Multiple:", multiple, "Equal:", equal)); - LOG(LINFO, ("Stored:", stored)); LOG(LINFO, ("Collect all data into one file...")); + string const fPath = mwmName + ROUTING_FILE_EXTENSION; try { - FilesContainerW writer(mwmName + ROUTING_FILE_EXTENSION); + FilesContainerW writer(fPath); mapping.Save(writer); @@ -221,6 +222,10 @@ void GenerateNodesInfo(string const & mwmName, string const & osrmName) { LOG(LCRITICAL, ("Can't write routing index", ex.Msg())); } + + uint64_t sz; + VERIFY(my::GetFileSize(fPath, sz), ()); + LOG(LINFO, ("Nodes stored:", stored, "Routing index file size:", sz)); } } diff --git a/generator/statistics.cpp b/generator/statistics.cpp index 339e1796d6..ab9e7ad0e9 100644 --- a/generator/statistics.cpp +++ b/generator/statistics.cpp @@ -8,6 +8,7 @@ #include "../indexer/data_factory.hpp" #include "../base/string_utils.hpp" +#include "../base/logging.hpp" #include "../std/iostream.hpp" #include "../std/iomanip.hpp" @@ -19,41 +20,17 @@ namespace stats { void FileContainerStatistic(string const & fPath) { - feature::DataHeader header; - ModelReaderPtr reader(new FileReader(fPath)); - LoadMapHeader(reader, header); - - vector tags; - tags.push_back(VERSION_FILE_TAG); - tags.push_back(HEADER_FILE_TAG); - tags.push_back(DATA_FILE_TAG); - - cout << "Geometry zoom levels: "; - for (size_t i = 0; i < header.GetScalesCount(); ++i) + try { - cout << header.GetScale(i) << " "; - - tags.push_back(feature::GetTagForIndex(GEOMETRY_FILE_TAG, i)); - tags.push_back(feature::GetTagForIndex(TRIANGLE_FILE_TAG, i)); + FilesContainerR cont(fPath); + cont.ForEachTag([&cont] (FilesContainerR::Tag const & tag) + { + cout << setw(10) << tag << " : " << cont.GetReader(tag).Size() << endl; + }); } - - cout << endl; - - tags.push_back(INDEX_FILE_TAG); - tags.push_back(SEARCH_INDEX_FILE_TAG); - - FilesContainerR cont(reader); - for (size_t i = 0; i < tags.size(); ++i) + catch (Reader::Exception const & ex) { - cout << setw(7) << tags[i] << " : "; - try - { - cout << cont.GetReader(tags[i]).Size() << endl; - } - catch (Reader::Exception const &) - { - cout << '-' << endl; - } + LOG(LWARNING, ("Error reading file:", fPath, ex.Msg())); } }