[search] Do not generate index after downloading if it's already exist.

This commit is contained in:
vng 2012-02-29 18:07:49 +03:00 committed by Alex Zolotarev
parent b888a6b631
commit 8747a8be7a
3 changed files with 6 additions and 3 deletions

View file

@ -212,7 +212,7 @@ int main(int argc, char ** argv)
{
LOG(LINFO, ("Generating search index for ", datFile));
if (!indexer::BuildSearchIndexFromDatFile(country + DATA_FILE_EXTENSION))
if (!indexer::BuildSearchIndexFromDatFile(country + DATA_FILE_EXTENSION, true))
LOG(LCRITICAL, ("Error generating search index."));
}
}

View file

@ -295,7 +295,7 @@ void indexer::BuildSearchIndex(FeaturesVector const & featuresV, Writer & writer
FileWriter::DeleteFileX(tmpFilePath);
}
bool indexer::BuildSearchIndexFromDatFile(string const & fName)
bool indexer::BuildSearchIndexFromDatFile(string const & fName, bool forceRebuild)
{
LOG(LINFO, ("Start building search index. Bits = ", search::POINT_CODING_BITS));
@ -308,6 +308,9 @@ bool indexer::BuildSearchIndexFromDatFile(string const & fName)
{
FilesContainerR readCont(datFile);
if (!forceRebuild && readCont.IsReaderExist(SEARCH_INDEX_FILE_TAG))
return true;
feature::DataHeader header;
header.Load(readCont.GetReader(HEADER_FILE_TAG));

View file

@ -8,5 +8,5 @@ namespace indexer
{
void BuildSearchIndex(FeaturesVector const & featuresVector, Writer & writer,
string const & tmpFilePath);
bool BuildSearchIndexFromDatFile(string const & fName);
bool BuildSearchIndexFromDatFile(string const & fName, bool forceRebuild = false);
} // namespace indexer