diff options
author | Sergey Yershov <yershov@corp.mail.ru> | 2015-08-25 13:15:23 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 03:03:15 +0300 |
commit | 770fd9da5a779f3adb64820859a38c0a7dd01a5a (patch) | |
tree | 37adc3bc91f7e7e5e0779fdd13680221633e494f | |
parent | 7fcd6ec8c4259a010433d72fce5bb299d24b8381 (diff) |
Remove unused stream reader/writer
-rw-r--r-- | coding/file_reader_stream.hpp | 27 | ||||
-rw-r--r-- | coding/file_writer_stream.hpp | 19 | ||||
-rw-r--r-- | generator/intermediate_data.hpp (renamed from generator/data_cache_file.hpp) | 62 | ||||
-rw-r--r-- | xcode/coding/coding.xcodeproj/project.pbxproj | 8 | ||||
-rw-r--r-- | xcode/generator/generator.xcodeproj/project.pbxproj | 8 |
5 files changed, 26 insertions, 98 deletions
diff --git a/coding/file_reader_stream.hpp b/coding/file_reader_stream.hpp deleted file mode 100644 index 8bbc7a0925..0000000000 --- a/coding/file_reader_stream.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include "coding/streams.hpp" -#include "coding/file_reader.hpp" - - -class FileReaderStream : public stream::ReaderStream<ReaderSource<FileReader> > -{ - typedef stream::ReaderStream<ReaderSource<FileReader> > base_type; - - FileReader m_file; - ReaderSource<FileReader> m_reader; - -public: - FileReaderStream(string const & fName) - : base_type(m_reader), m_file(fName), m_reader(m_file) - { - } - - using base_type::operator >>; - - // It is neccesary for DataFileReader. - void Seek(uint64_t pos) - { - m_reader = m_file.SubReader(pos, m_file.Size() - pos); - } -}; diff --git a/coding/file_writer_stream.hpp b/coding/file_writer_stream.hpp deleted file mode 100644 index d6861a5475..0000000000 --- a/coding/file_writer_stream.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "coding/streams.hpp" -#include "coding/file_writer.hpp" - -class FileWriterStream : public stream::WriterStream<FileWriter> -{ - typedef stream::WriterStream<FileWriter> base_type; - - FileWriter m_file; - -public: - FileWriterStream(string const & fName) - : base_type(m_file), m_file(fName) {} - - using base_type::operator <<; - - int64_t Pos() const { return m_file.Pos(); } -}; diff --git a/generator/data_cache_file.hpp b/generator/intermediate_data.hpp index 3e2be4b731..585cf2ab7c 100644 --- a/generator/data_cache_file.hpp +++ b/generator/intermediate_data.hpp @@ -3,8 +3,6 @@ #include "generator/osm_decl.hpp" #include "coding/file_name_utils.hpp" -#include "coding/file_reader_stream.hpp" -#include "coding/file_writer_stream.hpp" #include "base/logging.hpp" @@ -161,12 +159,11 @@ public: template <EMode T> typename enable_if<T == EMode::Read, void>::type InitStorage() { - if (m_preload) - { - size_t sz = m_storage.Size(); - m_data.resize(sz); - m_storage.Read(0, m_data.data(), sz); - } + if (!m_preload) + return; + size_t sz = m_storage.Size(); + m_data.resize(sz); + m_storage.Read(0, m_data.data(), sz); } template <class TValue, EMode T = TMode> @@ -183,48 +180,33 @@ public: uint32_t sz = static_cast<uint32_t>(m_data.size()); m_storage.Write(&sz, sizeof(sz)); m_storage.Write(m_data.data(), sz * sizeof(TBuffer::value_type)); - -// std::ofstream ff((m_name+".wlog").c_str(), std::ios::binary | std::ios::app); -// ff << id << " " << value.ToString() << std::endl; -// if (id == 1942060) -// ff << id << " " << value.Dump() << std::endl; } template <class TValue, EMode T = TMode> typename enable_if<T == EMode::Read, bool>::type Read(TKey id, TValue & value) { - uint64_t pos; - if (m_offsets.GetValueByKey(id, pos)) + uint64_t pos = 0; + if (!m_offsets.GetValueByKey(id, pos)) { - uint32_t valueSize = m_preload ? *((uint32_t *)(m_data.data() + pos)) : 0; - size_t offset = pos + sizeof(uint32_t); - - if (!m_preload) - { - // in case not in memory work we read buffer - m_storage.Read(pos, &valueSize, sizeof(valueSize)); - m_data.resize(valueSize); - m_storage.Read(pos + sizeof(valueSize), m_data.data(), valueSize); - offset = 0; - } - - // prepare correct reader - MemReader reader(m_data.data() + offset, valueSize); - - value.Read(reader); + LOG_SHORT(LWARNING, ("Can't find offset in file", m_offsets.GetFileName(), "by id", id)); + return false; + } + uint32_t valueSize = m_preload ? *(reinterpret_cast<uint32_t *>(m_data.data() + pos)) : 0; + size_t offset = pos + sizeof(uint32_t); -// std::ofstream ff((m_name+".rlog").c_str(), std::ios::binary | std::ios::app); -// ff << id << " " << value.ToString() << std::endl; -// if (id == 1942060) -// ff << id << " " << value.Dump() << std::endl; - return true; - } - else + if (!m_preload) { - LOG_SHORT(LWARNING, ("Can't find offset in file", m_offsets.GetFileName(), "by id", id)); - return false; + // in case not-in-memory work we read buffer + m_storage.Read(pos, &valueSize, sizeof(valueSize)); + m_data.resize(valueSize); + m_storage.Read(pos + sizeof(valueSize), m_data.data(), valueSize); + offset = 0; } + + MemReader reader(m_data.data() + offset, valueSize); + value.Read(reader); + return true; } inline void SaveOffsets() { m_offsets.WriteAll(); } diff --git a/xcode/coding/coding.xcodeproj/project.pbxproj b/xcode/coding/coding.xcodeproj/project.pbxproj index 6741bb32d4..a08a418de5 100644 --- a/xcode/coding/coding.xcodeproj/project.pbxproj +++ b/xcode/coding/coding.xcodeproj/project.pbxproj @@ -40,11 +40,9 @@ 6753429B1A3F588C00A0A8C3 /* file_container.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675342441A3F588B00A0A8C3 /* file_container.hpp */; }; 6753429C1A3F588C00A0A8C3 /* file_name_utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 675342451A3F588B00A0A8C3 /* file_name_utils.cpp */; }; 6753429D1A3F588C00A0A8C3 /* file_name_utils.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675342461A3F588B00A0A8C3 /* file_name_utils.hpp */; }; - 6753429E1A3F588C00A0A8C3 /* file_reader_stream.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675342471A3F588B00A0A8C3 /* file_reader_stream.hpp */; }; 6753429F1A3F588C00A0A8C3 /* file_reader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 675342481A3F588B00A0A8C3 /* file_reader.cpp */; }; 675342A01A3F588C00A0A8C3 /* file_reader.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675342491A3F588B00A0A8C3 /* file_reader.hpp */; }; 675342A11A3F588C00A0A8C3 /* file_sort.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 6753424A1A3F588B00A0A8C3 /* file_sort.hpp */; }; - 675342A21A3F588C00A0A8C3 /* file_writer_stream.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 6753424B1A3F588B00A0A8C3 /* file_writer_stream.hpp */; }; 675342A31A3F588C00A0A8C3 /* file_writer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6753424C1A3F588B00A0A8C3 /* file_writer.cpp */; }; 675342A41A3F588C00A0A8C3 /* file_writer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 6753424D1A3F588B00A0A8C3 /* file_writer.hpp */; }; 675342A71A3F588C00A0A8C3 /* hex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 675342501A3F588B00A0A8C3 /* hex.cpp */; }; @@ -131,11 +129,9 @@ 675342441A3F588B00A0A8C3 /* file_container.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_container.hpp; sourceTree = "<group>"; }; 675342451A3F588B00A0A8C3 /* file_name_utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_name_utils.cpp; sourceTree = "<group>"; }; 675342461A3F588B00A0A8C3 /* file_name_utils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_name_utils.hpp; sourceTree = "<group>"; }; - 675342471A3F588B00A0A8C3 /* file_reader_stream.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_reader_stream.hpp; sourceTree = "<group>"; }; 675342481A3F588B00A0A8C3 /* file_reader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_reader.cpp; sourceTree = "<group>"; }; 675342491A3F588B00A0A8C3 /* file_reader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_reader.hpp; sourceTree = "<group>"; }; 6753424A1A3F588B00A0A8C3 /* file_sort.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_sort.hpp; sourceTree = "<group>"; }; - 6753424B1A3F588B00A0A8C3 /* file_writer_stream.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_writer_stream.hpp; sourceTree = "<group>"; }; 6753424C1A3F588B00A0A8C3 /* file_writer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_writer.cpp; sourceTree = "<group>"; }; 6753424D1A3F588B00A0A8C3 /* file_writer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_writer.hpp; sourceTree = "<group>"; }; 675342501A3F588B00A0A8C3 /* hex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = hex.cpp; sourceTree = "<group>"; }; @@ -268,11 +264,9 @@ 675342441A3F588B00A0A8C3 /* file_container.hpp */, 675342451A3F588B00A0A8C3 /* file_name_utils.cpp */, 675342461A3F588B00A0A8C3 /* file_name_utils.hpp */, - 675342471A3F588B00A0A8C3 /* file_reader_stream.hpp */, 675342481A3F588B00A0A8C3 /* file_reader.cpp */, 675342491A3F588B00A0A8C3 /* file_reader.hpp */, 6753424A1A3F588B00A0A8C3 /* file_sort.hpp */, - 6753424B1A3F588B00A0A8C3 /* file_writer_stream.hpp */, 6753424C1A3F588B00A0A8C3 /* file_writer.cpp */, 6753424D1A3F588B00A0A8C3 /* file_writer.hpp */, 675342501A3F588B00A0A8C3 /* hex.cpp */, @@ -384,7 +378,6 @@ 675342C71A3F588C00A0A8C3 /* url_encode.hpp in Headers */, 675342BE1A3F588C00A0A8C3 /* sha2.hpp in Headers */, 674A29C91B26F93F001A525C /* png_memory_encoder.hpp in Headers */, - 675342A21A3F588C00A0A8C3 /* file_writer_stream.hpp in Headers */, 675342AA1A3F588C00A0A8C3 /* lodepng_io.hpp in Headers */, 675342BC1A3F588C00A0A8C3 /* reader.hpp in Headers */, 675342D21A3F588C00A0A8C3 /* zip_creator.hpp in Headers */, @@ -395,7 +388,6 @@ 675342941A3F588C00A0A8C3 /* compressed_varnum_vector.hpp in Headers */, 675342C01A3F588C00A0A8C3 /* streams_sink.hpp in Headers */, 6753428A1A3F588C00A0A8C3 /* blob_storage.hpp in Headers */, - 6753429E1A3F588C00A0A8C3 /* file_reader_stream.hpp in Headers */, 670D04C11B0BA92D0013A7AC /* xmlparser.hpp in Headers */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/xcode/generator/generator.xcodeproj/project.pbxproj b/xcode/generator/generator.xcodeproj/project.pbxproj index f0e9320fbc..1b443d52e3 100644 --- a/xcode/generator/generator.xcodeproj/project.pbxproj +++ b/xcode/generator/generator.xcodeproj/project.pbxproj @@ -19,7 +19,7 @@ 675340611A3F2A7400A0A8C3 /* check_model.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 6753402E1A3F2A7400A0A8C3 /* check_model.hpp */; }; 675340621A3F2A7400A0A8C3 /* coastlines_generator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6753402F1A3F2A7400A0A8C3 /* coastlines_generator.cpp */; }; 675340631A3F2A7400A0A8C3 /* coastlines_generator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675340301A3F2A7400A0A8C3 /* coastlines_generator.hpp */; }; - 675340641A3F2A7400A0A8C3 /* data_cache_file.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675340311A3F2A7400A0A8C3 /* data_cache_file.hpp */; }; + 675340641A3F2A7400A0A8C3 /* intermediate_data.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675340311A3F2A7400A0A8C3 /* intermediate_data.hpp */; }; 675340671A3F2A7400A0A8C3 /* dumper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 675340341A3F2A7400A0A8C3 /* dumper.cpp */; }; 675340681A3F2A7400A0A8C3 /* dumper.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 675340351A3F2A7400A0A8C3 /* dumper.hpp */; }; 675340691A3F2A7400A0A8C3 /* feature_builder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 675340361A3F2A7400A0A8C3 /* feature_builder.cpp */; }; @@ -74,7 +74,7 @@ 6753402E1A3F2A7400A0A8C3 /* check_model.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = check_model.hpp; sourceTree = "<group>"; }; 6753402F1A3F2A7400A0A8C3 /* coastlines_generator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = coastlines_generator.cpp; sourceTree = "<group>"; }; 675340301A3F2A7400A0A8C3 /* coastlines_generator.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = coastlines_generator.hpp; sourceTree = "<group>"; }; - 675340311A3F2A7400A0A8C3 /* data_cache_file.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = data_cache_file.hpp; sourceTree = "<group>"; }; + 675340311A3F2A7400A0A8C3 /* intermediate_data.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = intermediate_data.hpp; sourceTree = "<group>"; }; 675340341A3F2A7400A0A8C3 /* dumper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dumper.cpp; sourceTree = "<group>"; }; 675340351A3F2A7400A0A8C3 /* dumper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = dumper.hpp; sourceTree = "<group>"; }; 675340361A3F2A7400A0A8C3 /* feature_builder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = feature_builder.cpp; sourceTree = "<group>"; }; @@ -155,7 +155,7 @@ 6753402E1A3F2A7400A0A8C3 /* check_model.hpp */, 6753402F1A3F2A7400A0A8C3 /* coastlines_generator.cpp */, 675340301A3F2A7400A0A8C3 /* coastlines_generator.hpp */, - 675340311A3F2A7400A0A8C3 /* data_cache_file.hpp */, + 675340311A3F2A7400A0A8C3 /* intermediate_data.hpp */, 675340341A3F2A7400A0A8C3 /* dumper.cpp */, 675340351A3F2A7400A0A8C3 /* dumper.hpp */, 675340361A3F2A7400A0A8C3 /* feature_builder.cpp */, @@ -217,7 +217,7 @@ 6753407F1A3F2A7400A0A8C3 /* osm2type.hpp in Headers */, 670B84BD1A8CDB0000CE4492 /* osm_source.hpp in Headers */, 675340631A3F2A7400A0A8C3 /* coastlines_generator.hpp in Headers */, - 675340641A3F2A7400A0A8C3 /* data_cache_file.hpp in Headers */, + 675340641A3F2A7400A0A8C3 /* intermediate_data.hpp in Headers */, 675340781A3F2A7400A0A8C3 /* osm_decl.hpp in Headers */, 6753406B1A3F2A7400A0A8C3 /* feature_emitter_iface.hpp in Headers */, 6753408C1A3F2A7400A0A8C3 /* world_map_generator.hpp in Headers */, |