diff options
author | Sergey Yershov <yershov@corp.mail.ru> | 2015-01-13 12:57:49 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:36:08 +0300 |
commit | eaf43ae6feedb2e4e5f59e3932968d32c8f9f965 (patch) | |
tree | e019ca7960f0e230634ca877ff230a030219aca6 /indexer | |
parent | a873972368be4f5a386ced6d671b6bed81a2164c (diff) |
Optimization memory reallocation while reading variable length records
Simple optimization get_mark_value
Correct working with paths in generator_tool
Diffstat (limited to 'indexer')
-rw-r--r-- | indexer/features_vector.hpp | 4 | ||||
-rw-r--r-- | indexer/search_index_builder.cpp | 15 |
2 files changed, 9 insertions, 10 deletions
diff --git a/indexer/features_vector.hpp b/indexer/features_vector.hpp index 93bea22d58..2cdf92f6fe 100644 --- a/indexer/features_vector.hpp +++ b/indexer/features_vector.hpp @@ -17,8 +17,8 @@ public: void Get(uint64_t pos, FeatureType & ft) const { - uint32_t offset; - m_RecordReader.ReadRecord(pos, m_buffer, offset); + uint32_t offset = 0, size = 0; + m_RecordReader.ReadRecord(pos, m_buffer, offset, size); ft.Deserialize(m_LoadInfo.GetLoader(), &m_buffer[offset]); } diff --git a/indexer/search_index_builder.cpp b/indexer/search_index_builder.cpp index 5b8373e9d8..6e898e6cb6 100644 --- a/indexer/search_index_builder.cpp +++ b/indexer/search_index_builder.cpp @@ -396,15 +396,15 @@ void BuildSearchIndex(FilesContainerR const & cont, CategoriesHolder const & cat } -bool indexer::BuildSearchIndexFromDatFile(string const & fName, bool forceRebuild) +bool indexer::BuildSearchIndexFromDatFile(string const & datFile, bool forceRebuild) { LOG(LINFO, ("Start building search index. Bits = ", search::POINT_CODING_BITS)); try { Platform & pl = GetPlatform(); - string const datFile = pl.WritablePathForFile(fName); - string const tmpFile = pl.WritablePathForFile(fName + ".search_index_2.tmp"); + string const tmpFile1 = datFile + ".search_index_1.tmp"; + string const tmpFile2 = datFile + ".search_index_2.tmp"; { FilesContainerR readCont(datFile); @@ -412,12 +412,11 @@ bool indexer::BuildSearchIndexFromDatFile(string const & fName, bool forceRebuil if (!forceRebuild && readCont.IsExist(SEARCH_INDEX_FILE_TAG)) return true; - FileWriter writer(tmpFile); + FileWriter writer(tmpFile2); CategoriesHolder catHolder(pl.GetReader(SEARCH_CATEGORIES_FILE_NAME)); - BuildSearchIndex(readCont, catHolder, writer, - pl.WritablePathForFile(fName + ".search_index_1.tmp")); + BuildSearchIndex(readCont, catHolder, writer, tmpFile1); LOG(LINFO, ("Search index size = ", writer.Size())); } @@ -426,10 +425,10 @@ bool indexer::BuildSearchIndexFromDatFile(string const & fName, bool forceRebuil // Write to container in reversed order. FilesContainerW writeCont(datFile, FileWriter::OP_WRITE_EXISTING); FileWriter writer = writeCont.GetWriter(SEARCH_INDEX_FILE_TAG); - rw_ops::Reverse(FileReader(tmpFile), writer); + rw_ops::Reverse(FileReader(tmpFile2), writer); } - FileWriter::DeleteFileX(tmpFile); + FileWriter::DeleteFileX(tmpFile2); } catch (Reader::Exception const & e) { |