diff options
author | vng <viktor.govako@gmail.com> | 2015-08-07 16:16:39 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:59:55 +0300 |
commit | 8a2c486d2c8368422304ed894ada19ffb93d80be (patch) | |
tree | 5c1147dc31445673fcab2aafc1f35296ba9686ab /indexer/features_offsets_table.cpp | |
parent | ca342cc8422424e998047cdd00d943db524edced (diff) |
[mwm] Store World’s temporary index files in writable directory according to their inner version.
Diffstat (limited to 'indexer/features_offsets_table.cpp')
-rw-r--r-- | indexer/features_offsets_table.cpp | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/indexer/features_offsets_table.cpp b/indexer/features_offsets_table.cpp index fdd4f87481..f9fd17a59b 100644 --- a/indexer/features_offsets_table.cpp +++ b/indexer/features_offsets_table.cpp @@ -50,6 +50,7 @@ namespace feature return unique_ptr<FeaturesOffsetsTable>(new FeaturesOffsetsTable(elias_fano_builder)); } + // static unique_ptr<FeaturesOffsetsTable> FeaturesOffsetsTable::LoadImpl(string const & filePath) { return unique_ptr<FeaturesOffsetsTable>(new FeaturesOffsetsTable(filePath)); @@ -64,20 +65,14 @@ namespace feature } // static - unique_ptr<FeaturesOffsetsTable> FeaturesOffsetsTable::CreateIfNotExistsAndLoad( - LocalCountryFile const & localFile) + unique_ptr<FeaturesOffsetsTable> FeaturesOffsetsTable::CreateImpl( + platform::LocalCountryFile const & localFile, + FilesContainerR const & cont, string const & storePath) { - string const offsetsFilePath = CountryIndexes::GetPath(localFile, CountryIndexes::Index::Offsets); - - if (GetPlatform().IsFileExistsByFullPath(offsetsFilePath)) - return LoadImpl(offsetsFilePath); - - LOG(LINFO, ("Creating features offset table file", offsetsFilePath)); + LOG(LINFO, ("Creating features offset table file", storePath)); VERIFY(CountryIndexes::PreparePlaceOnDisk(localFile), ()); - FilesContainerR cont(localFile.GetPath(MapOptions::Map)); - Builder builder; FeaturesVector::ForEachOffset(cont.GetReader(DATA_FILE_TAG), [&builder] (uint32_t offset) { @@ -85,13 +80,38 @@ namespace feature }); unique_ptr<FeaturesOffsetsTable> table(Build(builder)); - table->Save(offsetsFilePath); + table->Save(storePath); return table; } + // static + unique_ptr<FeaturesOffsetsTable> FeaturesOffsetsTable::CreateIfNotExistsAndLoad( + LocalCountryFile const & localFile, FilesContainerR const & cont) + { + string const offsetsFilePath = CountryIndexes::GetPath(localFile, CountryIndexes::Index::Offsets); + + if (Platform::IsFileExistsByFullPath(offsetsFilePath)) + return LoadImpl(offsetsFilePath); + + return CreateImpl(localFile, cont, offsetsFilePath); + } + + // static + unique_ptr<FeaturesOffsetsTable> FeaturesOffsetsTable::CreateIfNotExistsAndLoad( + LocalCountryFile const & localFile) + { + string const offsetsFilePath = CountryIndexes::GetPath(localFile, CountryIndexes::Index::Offsets); + + if (Platform::IsFileExistsByFullPath(offsetsFilePath)) + return LoadImpl(offsetsFilePath); + + return CreateImpl(localFile, FilesContainerR(localFile.GetPath(MapOptions::Map)), offsetsFilePath); + } + + // static unique_ptr<FeaturesOffsetsTable> FeaturesOffsetsTable::CreateIfNotExistsAndLoad(FilesContainerR const & cont) { - return CreateIfNotExistsAndLoad((LocalCountryFile::MakeTemporary(cont.GetFileName()))); + return CreateIfNotExistsAndLoad(LocalCountryFile::MakeTemporary(cont.GetFileName()), cont); } void FeaturesOffsetsTable::Save(string const & filePath) |