From 060374379265ae5dc00166dc21391f2f12972a2a Mon Sep 17 00:00:00 2001 From: Sergey Magidovich Date: Fri, 19 Feb 2016 16:46:59 +0300 Subject: [PATCH] Store seconds since epoch in mwm as version. --- base/base.pro | 4 +- base/base_tests/timer_test.cpp | 11 ++++ base/gmtime.cpp | 17 +++++ base/gmtime.hpp | 9 +++ base/timegm.cpp | 16 ++--- base/timegm.hpp | 2 +- base/timer.cpp | 40 +++++++----- base/timer.hpp | 12 ++-- generator/generator_tool/generator_tool.cpp | 2 +- indexer/data_factory.cpp | 2 +- indexer/data_header.cpp | 2 +- indexer/indexer_tests/test_mwm_set.hpp | 2 +- map/framework.cpp | 2 +- map/mwm_tests/mwm_index_test.cpp | 2 +- platform/local_country_file_utils.cpp | 4 +- platform/mwm_version.cpp | 60 ++++++++++++++---- platform/mwm_version.hpp | 28 ++++++--- platform/platform_tests/mwm_version_test.cpp | 62 +++++++++++++++++++ platform/platform_tests/platform_tests.pro | 1 + .../platform_tests_support/scoped_mwm.cpp | 2 +- routing/road_graph_router.cpp | 2 +- routing/routing_mapping.cpp | 2 +- routing/routing_tests/road_graph_builder.cpp | 2 +- .../routing_tests/routing_mapping_test.cpp | 2 +- search/retrieval.cpp | 2 +- .../search_quality_tests.cpp | 2 +- search/v2/house_to_street_table.cpp | 2 +- 27 files changed, 229 insertions(+), 65 deletions(-) create mode 100644 base/gmtime.cpp create mode 100644 base/gmtime.hpp create mode 100644 platform/platform_tests/mwm_version_test.cpp diff --git a/base/base.pro b/base/base.pro index 642c3f56a8..58887276ef 100644 --- a/base/base.pro +++ b/base/base.pro @@ -10,6 +10,7 @@ include($$ROOT_DIR/common.pri) SOURCES += \ base.cpp \ condition.cpp \ + gmtime.cpp \ exception.cpp \ internal/message.cpp \ logging.cpp \ @@ -42,7 +43,8 @@ HEADERS += \ condition.hpp \ const_helper.hpp \ exception.hpp \ - internal/message.hpp \ + gmtime.hpp \ + internal/messagex.hpp \ limited_priority_queue.hpp \ logging.hpp \ macros.hpp \ diff --git a/base/base_tests/timer_test.cpp b/base/base_tests/timer_test.cpp index c75a49507d..fa8a492613 100644 --- a/base/base_tests/timer_test.cpp +++ b/base/base_tests/timer_test.cpp @@ -59,3 +59,14 @@ UNIT_TEST(Timer_TimestampConversion) TEST_EQUAL(INVALID_TIME_STAMP, StringToTimestamp("2100--1-02T11:08:34-10:00"), ()); TEST_EQUAL(INVALID_TIME_STAMP, StringToTimestamp("2012-12-02T11:08:34-25:88"), ()); } + +UNIT_TEST(Timer_GenerateYYMMDD) +{ + TEST_EQUAL(my::GenerateYYMMDD(116, 0, 26), 160126, ()); +} + +UNIT_TEST(Timer_TimeTConversion) +{ + auto const now = ::time(nullptr); + TEST_EQUAL(my::SecondsSinceEpochToTimeT(my::TimeTToSecondsSinceEpoch(now)), now, ()); +} diff --git a/base/gmtime.cpp b/base/gmtime.cpp new file mode 100644 index 0000000000..2dc63ab571 --- /dev/null +++ b/base/gmtime.cpp @@ -0,0 +1,17 @@ +#include "base/gmtime.hpp" + +#include "std/target_os.hpp" + +namespace my +{ +std::tm GmTime(time_t const time) +{ + std::tm result{}; +#ifndef OMIM_OS_WINDOWS + gmtime_r(&time, &result); +#else + gmtime_s(&result, &time); +#endif + return result; +} +} // namespace my diff --git a/base/gmtime.hpp b/base/gmtime.hpp new file mode 100644 index 0000000000..c67e9f7ab8 --- /dev/null +++ b/base/gmtime.hpp @@ -0,0 +1,9 @@ +#pragma once + +#include "std/ctime.hpp" + +namespace my +{ +/// A cross-platform replacenemt of gmtime_r +std::tm GmTime(time_t const time); +} // namespace my diff --git a/base/timegm.cpp b/base/timegm.cpp index 6b324f4e20..659ad067ec 100644 --- a/base/timegm.cpp +++ b/base/timegm.cpp @@ -1,6 +1,9 @@ -#include "timegm.hpp" +#include "base/timegm.hpp" #include "base/assert.hpp" +#include "base/timer.hpp" + +#include "std/chrono.hpp" // There are issues with this implementation due to absence // of time_t fromat specification. There are no guarantees @@ -49,10 +52,10 @@ bool IsLeapYear(int year) time_t TimeGM(std::tm const & tm) { int year; - time_t days; - time_t hours; - time_t minutes; - time_t seconds; + int days; + int hours; + int minutes; + int seconds; year = 1900 + tm.tm_year; days = 365 * (year - 1970) + LeapDaysCount(1970, year); @@ -66,7 +69,7 @@ time_t TimeGM(std::tm const & tm) minutes = hours * 60 + tm.tm_min; seconds = minutes * 60 + tm.tm_sec; - return seconds; + return my::SecondsSinceEpochToTimeT(seconds); } time_t TimeGM(int year, int month, int day, int hour, int min, int sec) @@ -85,5 +88,4 @@ time_t TimeGM(int year, int month, int day, int hour, int min, int sec) t.tm_sec = sec; return TimeGM(t); } - } // namespace base diff --git a/base/timegm.hpp b/base/timegm.hpp index 74dfbc5d8d..b5bc0e763d 100644 --- a/base/timegm.hpp +++ b/base/timegm.hpp @@ -1,5 +1,6 @@ #pragma once +#include "std/cstdint.hpp" #include "std/ctime.hpp" namespace base @@ -23,5 +24,4 @@ time_t TimeGM(std::tm const & tm); // min - 0...59 // sec - 0...59 time_t TimeGM(int year, int month, int day, int hour, int min, int sec); - } // base diff --git a/base/timer.cpp b/base/timer.cpp index d700d1b899..60d87ff730 100644 --- a/base/timer.cpp +++ b/base/timer.cpp @@ -1,14 +1,15 @@ -#include "base/timer.hpp" #include "base/assert.hpp" #include "base/macros.hpp" #include "base/timegm.hpp" +#include "base/timer.hpp" -#include "std/target_os.hpp" -#include "std/systime.hpp" -#include "std/cstdio.hpp" -#include "std/sstream.hpp" -#include "std/iomanip.hpp" #include "std/algorithm.hpp" +#include "std/chrono.hpp" +#include "std/cstdio.hpp" +#include "std/iomanip.hpp" +#include "std/sstream.hpp" +#include "std/systime.hpp" +#include "std/target_os.hpp" namespace my { @@ -49,17 +50,17 @@ string FormatCurrentTime() return s; } -uint32_t GenerateTimestamp(int year, int month, int day) +uint32_t GenerateYYMMDD(int year, int month, int day) { - return (year - 100) * 10000 + (month + 1) * 100 + day; + uint32_t result = (year - 100) * 100; + result = (result + month + 1) * 100; + result = result + day; + return result; } -uint32_t TodayAsYYMMDD() +uint64_t SecondsSinceEpoch() { - time_t rawTime = time(NULL); - tm const * const pTm = gmtime(&rawTime); - CHECK(pTm, ("Can't get current date.")); - return GenerateTimestamp(pTm->tm_year, pTm->tm_mon, pTm->tm_mday); + return TimeTToSecondsSinceEpoch(::time(nullptr)); } string TimestampToString(time_t time) @@ -82,7 +83,6 @@ string TimestampToString(time_t time) namespace { - bool IsValid(tm const & t) { /// @todo Funny thing, but "00" month is accepted as valid in get_time function. @@ -90,7 +90,6 @@ bool IsValid(tm const & t) return (t.tm_mday >= 1 && t.tm_mday <= 31 && t.tm_mon >= 0 && t.tm_mon <= 11); } - } time_t StringToTimestamp(string const & s) @@ -157,4 +156,15 @@ double HighResTimer::ElapsedSeconds() const return duration_cast>(high_resolution_clock::now() - m_start).count(); } +time_t SecondsSinceEpochToTimeT(uint64_t secondsSinceEpoch) +{ + time_point const tpoint{seconds(secondsSinceEpoch)}; + return system_clock::to_time_t(tpoint); +} + +uint64_t TimeTToSecondsSinceEpoch(time_t time) +{ + auto const tpoint = system_clock::from_time_t(time); + return duration_cast(tpoint.time_since_epoch()).count(); +} } diff --git a/base/timer.hpp b/base/timer.hpp index 0ff9a0a1e6..bd793f92c1 100644 --- a/base/timer.hpp +++ b/base/timer.hpp @@ -36,13 +36,13 @@ public: string FormatCurrentTime(); /// Generates timestamp for a specified day. -/// \param year The number of years since 1900. -/// \param month The number of month since January, in the range 0 to 11. -/// \param day The day of the month, in the range 1 to 31. +/// \param year The number of years since 1900. +/// \param month The number of month since January, in the range 0 to 11. +/// \param day The day of the month, in the range 1 to 31. /// \return Timestamp. -uint32_t GenerateTimestamp(int year, int month, int day); +uint32_t GenerateYYMMDD(int year, int month, int day); -uint32_t TodayAsYYMMDD(); +uint64_t SecondsSinceEpoch(); /// Always creates strings in UTC time: 1997-07-16T07:30:15Z /// Returns empty string on error @@ -71,4 +71,6 @@ public: double ElapsedSeconds() const; }; +time_t SecondsSinceEpochToTimeT(uint64_t secondsSinceEpoch); +uint64_t TimeTToSecondsSinceEpoch(time_t time); } diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index c269679b3e..c9d9e12ca9 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -66,7 +66,7 @@ DEFINE_bool(make_cross_section, false, "Make corss section in routing file for c DEFINE_string(osm_file_name, "", "Input osm area file"); DEFINE_string(osm_file_type, "xml", "Input osm area file type [xml, o5m]"); DEFINE_string(user_resource_path, "", "User defined resource path for classificator.txt and etc."); -DEFINE_uint64(planet_version, my::TodayAsYYMMDD(), "Version as YYMMDD, by default - today"); +DEFINE_uint64(planet_version, my::SecondsSinceEpoch(), "Version as seconds since epoch, by default - now"); int main(int argc, char ** argv) { diff --git a/indexer/data_factory.cpp b/indexer/data_factory.cpp index f2f20a47d7..b9ac8abc86 100644 --- a/indexer/data_factory.cpp +++ b/indexer/data_factory.cpp @@ -11,7 +11,7 @@ void IndexFactory::Load(FilesContainerR const & cont) IntervalIndexIFace * IndexFactory::CreateIndex(ModelReaderPtr reader) const { - if (m_version.format == version::Format::v1) + if (m_version.GetFormat() == version::Format::v1) return new old_101::IntervalIndex(reader); return new IntervalIndex(reader); } diff --git a/indexer/data_header.cpp b/indexer/data_header.cpp index 317ffdbf7b..52b914b990 100644 --- a/indexer/data_header.cpp +++ b/indexer/data_header.cpp @@ -110,7 +110,7 @@ namespace feature version::MwmVersion version; if (version::ReadVersion(cont, version)) - Load(headerReader, version.format); + Load(headerReader, version.GetFormat()); else LoadV1(headerReader); } diff --git a/indexer/indexer_tests/test_mwm_set.hpp b/indexer/indexer_tests/test_mwm_set.hpp index 20ccf02cf5..4835730091 100644 --- a/indexer/indexer_tests/test_mwm_set.hpp +++ b/indexer/indexer_tests/test_mwm_set.hpp @@ -22,7 +22,7 @@ protected: unique_ptr info(new MwmInfo()); info->m_maxScale = n; info->m_limitRect = m2::RectD(0, 0, 1, 1); - info->m_version.format = version::Format::lastFormat; + info->m_version.SetFormat(version::Format::lastFormat); return info; } diff --git a/map/framework.cpp b/map/framework.cpp index 45fd876030..c5f0c73d59 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -522,7 +522,7 @@ void Framework::RegisterAllMaps() MwmSet::MwmId const & id = p.first; ASSERT(id.IsAlive(), ()); - minFormat = min(minFormat, static_cast(id.GetInfo()->m_version.format)); + minFormat = min(minFormat, static_cast(id.GetInfo()->m_version.GetFormat())); } m_searchEngine->SetSupportOldFormat(minFormat < static_cast(version::Format::v3)); diff --git a/map/mwm_tests/mwm_index_test.cpp b/map/mwm_tests/mwm_index_test.cpp index c87f08b9a7..1076b320e0 100644 --- a/map/mwm_tests/mwm_index_test.cpp +++ b/map/mwm_tests/mwm_index_test.cpp @@ -46,7 +46,7 @@ bool RunTest(string const & countryFileName, int lowS, int highS) MwmSet::MwmId const & id = p.first; ASSERT(id.IsAlive(), ()); - version::Format const version = id.GetInfo()->m_version.format; + version::Format const version = id.GetInfo()->m_version.GetFormat(); if (version == version::Format::unknownFormat) return false; diff --git a/platform/local_country_file_utils.cpp b/platform/local_country_file_utils.cpp index e23f3a7e5c..7e6a0a56b3 100644 --- a/platform/local_country_file_utils.cpp +++ b/platform/local_country_file_utils.cpp @@ -270,8 +270,8 @@ void FindAllLocalMapsAndCleanup(int64_t latestVersion, string const & dataDir, platform.GetReader(file + DATA_FILE_EXTENSION, GetSpecialFilesSearchScope())); // Assume that empty path means the resource file. - LocalCountryFile worldFile(string(), CountryFile(file), - version::ReadVersionTimestamp(reader)); + LocalCountryFile worldFile{string(), CountryFile(file), + version::ReadVersionDate(reader)}; worldFile.m_files = MapOptions::Map; if (i != localFiles.end()) { diff --git a/platform/mwm_version.cpp b/platform/mwm_version.cpp index d5acde1b16..f3dc45fda6 100644 --- a/platform/mwm_version.cpp +++ b/platform/mwm_version.cpp @@ -5,16 +5,42 @@ #include "coding/varint.hpp" #include "coding/writer.hpp" +#include "base/assert.hpp" +#include "base/gmtime.hpp" +#include "base/string_utils.hpp" +#include "base/timegm.hpp" #include "base/timer.hpp" #include "defines.hpp" -#include "std/ctime.hpp" +#include "std/array.hpp" namespace version { namespace { +uint64_t VersionToSecondsSinceEpoch(uint32_t version) +{ + auto constexpr partsCount = 3; + // From left to right YY MM DD. + array parts{}; // Initialize with zeros. + for (auto i = partsCount - 1; i >= 0; --i) + { + parts[i] = version % 100; + version /= 100; + } + ASSERT_EQUAL(version, 0, ("Version is too big.")); + + ASSERT_LESS_OR_EQUAL(parts[1], 12, ("Month should be in range [1, 12]")); + ASSERT_LESS_OR_EQUAL(parts[2], 31, ("Day should be in range [1, 31]")); + + std::tm tm{}; + tm.tm_year = parts[0] + 100; + tm.tm_mon = parts[1] - 1; + tm.tm_mday = parts[2]; + + return my::TimeTToSecondsSinceEpoch(base::TimeGM(tm)); +} char const MWM_PROLOG[] = "MWM"; @@ -27,29 +53,39 @@ void ReadVersionT(TSource & src, MwmVersion & version) if (strcmp(prolog, MWM_PROLOG) != 0) { - version.format = Format::v2; - version.timestamp = - my::GenerateTimestamp(2011 - 1900 /* number of years since 1900 */, - 10 /* number of month since January */, 1 /* month day */); + version.SetFormat(Format::v2); + version.SetSecondsSinceEpoch(VersionToSecondsSinceEpoch(111101)); return; } // Read format value "as-is". It's correctness will be checked later // with the correspondent return value. - version.format = static_cast(ReadVarUint(src)); - version.timestamp = ReadVarUint(src); + version.SetFormat(static_cast(ReadVarUint(src))); + if (version.GetFormat() < Format::v8) + version.SetSecondsSinceEpoch(VersionToSecondsSinceEpoch(ReadVarUint(src))); + else + version.SetSecondsSinceEpoch(ReadVarUint(src)); } } // namespace -MwmVersion::MwmVersion() : format(Format::unknownFormat), timestamp(0) {} +uint32_t MwmVersion::GetVersion() const +{ + auto const tm = my::GmTime(my::SecondsSinceEpochToTimeT(m_secondsSinceEpoch)); + return my::GenerateYYMMDD(tm.tm_year, tm.tm_mon, tm.tm_mday); +} -void WriteVersion(Writer & w, uint32_t versionDate) +string DebugPrint(Format f) +{ + return "v" + strings::to_string(static_cast(f) + 1); +} + +void WriteVersion(Writer & w, uint64_t secondsSinceEpoch) { w.Write(MWM_PROLOG, ARRAY_SIZE(MWM_PROLOG)); // write inner data version WriteVarUint(w, static_cast(Format::lastFormat)); - WriteVarUint(w, versionDate); + WriteVarUint(w, secondsSinceEpoch); } void ReadVersion(ReaderSrc & src, MwmVersion & version) { ReadVersionT(src, version); } @@ -65,13 +101,13 @@ bool ReadVersion(FilesContainerR const & container, MwmVersion & version) return true; } -uint32_t ReadVersionTimestamp(ModelReaderPtr const & reader) +uint32_t ReadVersionDate(ModelReaderPtr const & reader) { MwmVersion version; if (!ReadVersion(FilesContainerR(reader), version)) return 0; - return version.timestamp; + return version.GetVersion(); } bool IsSingleMwm(int64_t version) diff --git a/platform/mwm_version.hpp b/platform/mwm_version.hpp index db6870f950..0f18e0b74d 100644 --- a/platform/mwm_version.hpp +++ b/platform/mwm_version.hpp @@ -1,6 +1,7 @@ #pragma once #include "std/cstdint.hpp" +#include "std/string.hpp" class FilesContainerR; class ReaderSrc; @@ -19,20 +20,31 @@ enum class Format v5, // July 2015 (feature id is the index in vector now). v6, // October 2015 (offsets vector is in mwm now). v7, // November 2015 (supply different search index formats). - v8, // January 2016 (long strings in metadata). + v8, // February 2016 (long strings in metadata; store seconds since epoch in MwmVersion). lastFormat = v8 }; -struct MwmVersion -{ - MwmVersion(); +string DebugPrint(Format f); - Format format; - uint32_t timestamp; +class MwmVersion +{ +public: + Format GetFormat() const { return m_format; } + uint64_t GetSecondsSinceEpoch() const { return m_secondsSinceEpoch; } + /// \return version as YYMMDD. + uint32_t GetVersion() const; + + void SetFormat(Format format) { m_format = format; } + void SetSecondsSinceEpoch(uint64_t secondsSinceEpoch) { m_secondsSinceEpoch = secondsSinceEpoch; } + +private: + /// Data layout format in mwm file. + Format m_format{Format::unknownFormat}; + uint64_t m_secondsSinceEpoch{0}; }; /// Writes latest format and current timestamp to the writer. -void WriteVersion(Writer & w, uint32_t versionDate); +void WriteVersion(Writer & w, uint64_t secondsSinceEpoch); /// Reads mwm version from src. void ReadVersion(ReaderSrc & src, MwmVersion & version); @@ -43,7 +55,7 @@ void ReadVersion(ReaderSrc & src, MwmVersion & version); bool ReadVersion(FilesContainerR const & container, MwmVersion & version); /// Helper function that is used in FindAllLocalMaps. -uint32_t ReadVersionTimestamp(ModelReaderPtr const & reader); +uint32_t ReadVersionDate(ModelReaderPtr const & reader); /// \returns true if version is version of an mwm which was generated after small mwm update. /// This means it contains routing file as well. diff --git a/platform/platform_tests/mwm_version_test.cpp b/platform/platform_tests/mwm_version_test.cpp new file mode 100644 index 0000000000..3acc598a2e --- /dev/null +++ b/platform/platform_tests/mwm_version_test.cpp @@ -0,0 +1,62 @@ +#include "testing/testing.hpp" + +#include "coding/reader_wrapper.hpp" +#include "coding/varint.hpp" +#include "coding/writer.hpp" + +#include "platform/mwm_version.hpp" + +#include "std/string.hpp" + +namespace +{ +string WriteMwmVersion(version::Format const format, uint64_t const version) +{ + string data; + MemWriter writer(data); + WriterSink> sink(writer); + + char const prolog[] = "MWM"; + sink.Write(prolog, ARRAY_SIZE(prolog)); + + WriteVarUint(sink, static_cast(format)); + WriteVarUint(sink, version); + + return data; +} + +version::MwmVersion ReadMwmVersion(string const & data) +{ + MemReader reader(data.data(), data.size()); + ReaderSrc source(reader); + + version::MwmVersion version; + version::ReadVersion(source, version); + + return version; +} +} // namespace + +UNIT_TEST(MwmVersion_OldFormat) +{ + auto const secondsSinceEpoch = 1455235200; // 160212 + auto const dataVersion = 160212; + // Before Format::v8 there was a data version written to mwm. + auto const data = WriteMwmVersion(version::Format::v7, dataVersion); + auto const mwmVersion = ReadMwmVersion(data); + TEST_EQUAL(mwmVersion.GetSecondsSinceEpoch(), secondsSinceEpoch, ()); + TEST_EQUAL(mwmVersion.GetFormat(), version::Format::v7, ()); + TEST_EQUAL(mwmVersion.GetVersion(), dataVersion, ()); +} + +UNIT_TEST(MwmVersion_NewFormat) +{ + auto const secondsSinceEpoch = 1455870947; // 160219 + auto const dataVersion = 160219; + // After Format::v8 seconds since epoch are stored in mwm. + auto const data = WriteMwmVersion(version::Format::v8, secondsSinceEpoch); + auto const mwmVersion = ReadMwmVersion(data); + TEST_EQUAL(mwmVersion.GetSecondsSinceEpoch(), secondsSinceEpoch, ()); + TEST_EQUAL(mwmVersion.GetFormat(), version::Format::v8, ()); + TEST_EQUAL(mwmVersion.GetVersion(), dataVersion, ()); +} diff --git a/platform/platform_tests/platform_tests.pro b/platform/platform_tests/platform_tests.pro index 2047466119..af6ffa5709 100644 --- a/platform/platform_tests/platform_tests.pro +++ b/platform/platform_tests/platform_tests.pro @@ -32,4 +32,5 @@ SOURCES += \ local_country_file_tests.cpp \ location_test.cpp \ measurement_tests.cpp \ + mwm_version_test.cpp \ platform_test.cpp \ diff --git a/platform/platform_tests_support/scoped_mwm.cpp b/platform/platform_tests_support/scoped_mwm.cpp index f4a3b1fe1e..c7bc9e413f 100644 --- a/platform/platform_tests_support/scoped_mwm.cpp +++ b/platform/platform_tests_support/scoped_mwm.cpp @@ -26,7 +26,7 @@ ScopedMwm::ScopedMwm(string const & relativePath) : m_file(relativePath, "") // Each writer must be in it's own scope to avoid conflicts on the final write. { FileWriter versionWriter = container.GetWriter(VERSION_FILE_TAG); - version::WriteVersion(versionWriter, my::TodayAsYYMMDD()); + version::WriteVersion(versionWriter, my::SecondsSinceEpoch()); } FileWriter w = container.GetWriter(HEADER_FILE_TAG); diff --git a/routing/road_graph_router.cpp b/routing/road_graph_router.cpp index ec92eb6334..cf678a987d 100644 --- a/routing/road_graph_router.cpp +++ b/routing/road_graph_router.cpp @@ -70,7 +70,7 @@ bool CheckMwmVersion(vector> const & vicinities, vectorGetCountryName()); } return !mwmNames.empty(); diff --git a/routing/routing_mapping.cpp b/routing/routing_mapping.cpp index 70f26f7e85..51a7b0a228 100644 --- a/routing/routing_mapping.cpp +++ b/routing/routing_mapping.cpp @@ -43,7 +43,7 @@ bool CheckMwmConsistency(LocalCountryFile const & localFile) version::MwmVersion version2; version::ReadVersion(src2, version2); - return version1.timestamp == version2.timestamp; + return version1.GetVersion() == version2.GetVersion(); } } // namespace diff --git a/routing/routing_tests/road_graph_builder.cpp b/routing/routing_tests/road_graph_builder.cpp index 093a195578..00f8f55d95 100644 --- a/routing/routing_tests/road_graph_builder.cpp +++ b/routing/routing_tests/road_graph_builder.cpp @@ -43,7 +43,7 @@ private: unique_ptr info(new MwmInfo()); info->m_maxScale = 1; info->m_limitRect = m2::RectD(0, 0, 1, 1); - info->m_version.format = version::Format::lastFormat; + info->m_version.SetFormat(version::Format::lastFormat); return info; } unique_ptr CreateValue(MwmInfo &) const override diff --git a/routing/routing_tests/routing_mapping_test.cpp b/routing/routing_tests/routing_mapping_test.cpp index 9ada2fe061..1cebbe4a50 100644 --- a/routing/routing_tests/routing_mapping_test.cpp +++ b/routing/routing_tests/routing_mapping_test.cpp @@ -52,7 +52,7 @@ private: FilesContainerW dataCont(localFile.GetPath(MapOptions::CarRouting)); FileWriter w1 = dataCont.GetWriter(VERSION_FILE_TAG); - version::WriteVersion(w1, my::TodayAsYYMMDD()); + version::WriteVersion(w1, my::SecondsSinceEpoch()); FileWriter w2 = dataCont.GetWriter(ROUTING_MATRIX_FILE_TAG); w2.Write("smth", 4); } diff --git a/search/retrieval.cpp b/search/retrieval.cpp index 706de67f2e..df13a68404 100644 --- a/search/retrieval.cpp +++ b/search/retrieval.cpp @@ -435,7 +435,7 @@ unique_ptr Retrieval::RetrieveAddressFeatures( MwmSet::MwmId const & id, MwmValue & value, my::Cancellable const & cancellable, SearchQueryParams const & params) { - version::MwmTraits mwmTraits(value.GetMwmVersion().format); + version::MwmTraits mwmTraits(value.GetMwmVersion().GetFormat()); if (mwmTraits.GetSearchIndexFormat() == version::MwmTraits::SearchIndexFormat::FeaturesWithRankAndCenter) diff --git a/search/search_quality_tests/search_quality_tests.cpp b/search/search_quality_tests/search_quality_tests.cpp index 6d08bb2313..ecde241a26 100644 --- a/search/search_quality_tests/search_quality_tests.cpp +++ b/search/search_quality_tests/search_quality_tests.cpp @@ -132,7 +132,7 @@ uint64_t ReadVersionFromHeader(platform::LocalCountryFile const & mwm) version::MwmVersion version; version::ReadVersion(src, version); - return version.timestamp; + return version.GetVersion(); } void CalcStatistics(vector const & a, double & avg, double & maximum, double & var, diff --git a/search/v2/house_to_street_table.cpp b/search/v2/house_to_street_table.cpp index 351e431f1c..8c15dc59f3 100644 --- a/search/v2/house_to_street_table.cpp +++ b/search/v2/house_to_street_table.cpp @@ -48,7 +48,7 @@ public: unique_ptr HouseToStreetTable::Load(MwmValue & value) { - version::MwmTraits traits(value.GetMwmVersion().format); + version::MwmTraits traits(value.GetMwmVersion().GetFormat()); auto const format = traits.GetHouseToStreetTableFormat(); unique_ptr result;