diff --git a/coding/coding_tests/var_record_reader_test.cpp b/coding/coding_tests/var_record_reader_test.cpp index 1195b6c71b..0fdd7132bf 100644 --- a/coding/coding_tests/var_record_reader_test.cpp +++ b/coding/coding_tests/var_record_reader_test.cpp @@ -19,14 +19,14 @@ namespace { struct SaveForEachParams { - explicit SaveForEachParams(vector > & data) : m_Data(data) {} + explicit SaveForEachParams(vector> & data) : m_data(data) {} void operator()(uint64_t pos, vector && data) const { - m_Data.emplace_back(pos, string(data.begin(), data.end())); + m_data.emplace_back(pos, string(data.begin(), data.end())); } - vector > & m_Data; + vector> & m_data; }; } diff --git a/coding/var_record_reader.hpp b/coding/var_record_reader.hpp index c72561931f..204c4163ac 100644 --- a/coding/var_record_reader.hpp +++ b/coding/var_record_reader.hpp @@ -16,12 +16,12 @@ template class VarRecordReader { public: - VarRecordReader(ReaderT const & reader) : m_reader(reader), m_readerSize(reader.Size()) {} + VarRecordReader(ReaderT const & reader) : m_reader(reader) {} std::vector ReadRecord(uint64_t const pos) const { - ASSERT_LESS(pos, m_readerSize, ()); ReaderSource source(m_reader); + ASSERT_LESS(pos, source.Size(), ()); source.Skip(pos); uint32_t const recordSize = ReadVarUint(source); std::vector buffer(recordSize); @@ -31,20 +31,17 @@ public: void ForEachRecord(std::function &&)> const & f) const { - uint64_t pos = 0; ReaderSource source(m_reader); - while (pos < m_readerSize) + while (source.Size() > 0) { + auto const pos = source.Pos(); uint32_t const recordSize = ReadVarUint(source); std::vector buffer(recordSize); source.Read(buffer.data(), recordSize); f(static_cast(pos), std::move(buffer)); - pos = source.Pos(); } - ASSERT_EQUAL(pos, m_ReaderSize, ()); } protected: ReaderT m_reader; - uint64_t m_readerSize; }; diff --git a/indexer/feature.cpp b/indexer/feature.cpp index 8f0d8b100c..c4c6ea2d0c 100644 --- a/indexer/feature.cpp +++ b/indexer/feature.cpp @@ -109,13 +109,13 @@ int GetScaleIndex(SharedLoadInfo const & loadInfo, int scale, return -1; } -uint32_t CalcOffset(ArrayByteSource const & source, const char * start) +uint32_t CalcOffset(ArrayByteSource const & source, char const * start) { ASSERT_GREATER_OR_EQUAL(source.PtrC(), start, ()); - return static_cast(source.PtrC() - start); + return static_cast(distance(start, source.PtrC())); } -uint8_t Header(FeatureType::Buffer const & data) { return static_cast(data[0]); } +uint8_t Header(vector const & data) { return static_cast(data[0]); } void ReadOffsets(SharedLoadInfo const & loadInfo, ArrayByteSource & src, uint8_t mask, FeatureType::GeometryOffsets & offsets) @@ -181,17 +181,11 @@ uint8_t ReadByte(TSource & src) } } // namespace -FeatureType::FeatureType(SharedLoadInfo const * loadInfo, Buffer && buffer) : m_data(buffer) +FeatureType::FeatureType(SharedLoadInfo const * loadInfo, vector && buffer) + : m_data(buffer), m_loadInfo(loadInfo) { - CHECK(loadInfo, ()); - m_loadInfo = loadInfo; + CHECK(m_loadInfo, ()); m_header = Header(m_data); - - m_offsets.Reset(); - m_ptsSimpMask = 0; - m_limitRect.MakeEmpty(); - m_parsed.Reset(); - m_innerStats.MakeZero(); } FeatureType::FeatureType(osm::MapObject const & emo) diff --git a/indexer/feature.hpp b/indexer/feature.hpp index d659e023fa..662658c2b6 100644 --- a/indexer/feature.hpp +++ b/indexer/feature.hpp @@ -31,10 +31,9 @@ class MapObject; class FeatureType { public: - using Buffer = std::vector; using GeometryOffsets = buffer_vector; - FeatureType(feature::SharedLoadInfo const * loadInfo, Buffer && buffer); + FeatureType(feature::SharedLoadInfo const * loadInfo, std::vector && buffer); FeatureType(osm::MapObject const & emo); feature::GeomType GetGeomType() const; @@ -244,7 +243,7 @@ private: // Non-owning pointer to shared load info. SharedLoadInfo created once per FeaturesVector. feature::SharedLoadInfo const * m_loadInfo = nullptr; - Buffer m_data; + std::vector m_data; ParsedFlags m_parsed; Offsets m_offsets; diff --git a/indexer/features_vector.hpp b/indexer/features_vector.hpp index 1e27adc82f..8d1e67dec4 100644 --- a/indexer/features_vector.hpp +++ b/indexer/features_vector.hpp @@ -54,7 +54,6 @@ private: feature::SharedLoadInfo m_loadInfo; VarRecordReader m_recordReader; - mutable std::vector m_buffer; feature::FeaturesOffsetsTable const * m_table; }; diff --git a/indexer/indexer_tests/CMakeLists.txt b/indexer/indexer_tests/CMakeLists.txt index 2b051e2312..fe1e9ac3bd 100644 --- a/indexer/indexer_tests/CMakeLists.txt +++ b/indexer/indexer_tests/CMakeLists.txt @@ -27,7 +27,7 @@ set( postcodes_matcher_tests.cpp postcodes_tests.cpp rank_table_test.cpp - read_features_test.cpp + read_features_tests.cpp scale_index_reading_tests.cpp scales_test.cpp search_string_utils_test.cpp diff --git a/indexer/indexer_tests/read_features_test.cpp b/indexer/indexer_tests/read_features_tests.cpp similarity index 83% rename from indexer/indexer_tests/read_features_test.cpp rename to indexer/indexer_tests/read_features_tests.cpp index f2aa92e20a..7ee8348de8 100644 --- a/indexer/indexer_tests/read_features_test.cpp +++ b/indexer/indexer_tests/read_features_tests.cpp @@ -26,13 +26,13 @@ UNIT_TEST(ReadFeatures_Smoke) FeaturesLoaderGuard const guard(dataSource, handle.GetId()); LOG(LINFO, (guard.GetNumFeatures())); - for (uint32_t i = 0; i < guard.GetNumFeatures() - 1; ++i) + for (uint32_t i = 0; i + 1 < guard.GetNumFeatures(); ++i) { LOG(LINFO, ("Trying", i, i + 1)); auto ft1 = guard.GetFeatureByIndex(i); auto ft2 = guard.GetFeatureByIndex(i + 1); - ft2->ForEachType([](auto const t) {}); - ft1->ForEachType([](auto const t) {}); + ft2->ForEachType([](auto const /* t */) {}); + ft1->ForEachType([](auto const /* t */) {}); } } diff --git a/xcode/indexer/indexer.xcodeproj/project.pbxproj b/xcode/indexer/indexer.xcodeproj/project.pbxproj index 18875ea897..9d4b6e1aa0 100644 --- a/xcode/indexer/indexer.xcodeproj/project.pbxproj +++ b/xcode/indexer/indexer.xcodeproj/project.pbxproj @@ -66,6 +66,7 @@ 3D928F681D50F9FE001670E0 /* data_source_helpers.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3D928F661D50F9FE001670E0 /* data_source_helpers.hpp */; }; 40009062201F5CB000963E18 /* cell_value_pair.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4000905D201F5CAF00963E18 /* cell_value_pair.hpp */; }; 40662D32236059BF006A124D /* tree_node.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 40662D2F236059BF006A124D /* tree_node.hpp */; }; + 4067554C242BB04800EB8F8B /* read_features_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4067554B242BB04800EB8F8B /* read_features_tests.cpp */; }; 406970A221AEF2F20024DDB2 /* brands_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 406970A121AEF2F10024DDB2 /* brands_tests.cpp */; }; 4088CE2021AE993F00E2702A /* brands_holder.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4088CE1E21AE993F00E2702A /* brands_holder.hpp */; }; 4088CE2121AE993F00E2702A /* brands_holder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4088CE1F21AE993F00E2702A /* brands_holder.cpp */; }; @@ -292,6 +293,7 @@ 4000905D201F5CAF00963E18 /* cell_value_pair.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cell_value_pair.hpp; sourceTree = ""; }; 4052928E21496D2B00D821F1 /* categories_cuisines.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = categories_cuisines.txt; path = ../../data/categories_cuisines.txt; sourceTree = ""; }; 40662D2F236059BF006A124D /* tree_node.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = tree_node.hpp; path = complex/tree_node.hpp; sourceTree = ""; }; + 4067554B242BB04800EB8F8B /* read_features_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = read_features_tests.cpp; sourceTree = ""; }; 406970A121AEF2F10024DDB2 /* brands_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = brands_tests.cpp; sourceTree = ""; }; 4088CE1E21AE993F00E2702A /* brands_holder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = brands_holder.hpp; sourceTree = ""; }; 4088CE1F21AE993F00E2702A /* brands_holder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = brands_holder.cpp; sourceTree = ""; }; @@ -569,6 +571,7 @@ 670C60F81AB0657700C38A8C /* indexer_tests */ = { isa = PBXGroup; children = ( + 4067554B242BB04800EB8F8B /* read_features_tests.cpp */, 40BC58C9237EACDF006B2C4E /* postcodes_tests.cpp */, 391C0C8522BD255E003DC252 /* feature_to_osm_tests.cpp */, 406970A121AEF2F10024DDB2 /* brands_tests.cpp */, @@ -1049,6 +1052,7 @@ 675341071A3F540F00A0A8C3 /* data_factory.cpp in Sources */, 34583BCB1C88552100F94664 /* map_object.cpp in Sources */, 675B562320D25C9800A521D2 /* feature_source.cpp in Sources */, + 4067554C242BB04800EB8F8B /* read_features_tests.cpp in Sources */, 6753412E1A3F540F00A0A8C3 /* index_builder.cpp in Sources */, 675341011A3F540F00A0A8C3 /* classificator_loader.cpp in Sources */, 456E1B191F90E5B7009C32E1 /* ftypes_sponsored.cpp in Sources */,