+ small beautify

This commit is contained in:
kelson42 2010-04-14 16:27:11 +00:00
parent cdd43db32d
commit 9d92cec52d
1 changed files with 14 additions and 9 deletions

View File

@ -78,10 +78,14 @@ namespace kiwix {
return false; return false;
} }
/* Begin the Xapian transation */
this->writableDatabase->begin_transaction(true);
while(this->currentArticleOffset < thresholdOffset && while(this->currentArticleOffset < thresholdOffset &&
this->currentArticleOffset < this->lastArticleOffset) { this->currentArticleOffset < this->lastArticleOffset) {
zim::Article currentArticle; zim::Article currentArticle;
Xapian::Document currentDocument;
/* Get next non redirect article */ /* Get next non redirect article */
do { do {
@ -109,10 +113,10 @@ namespace kiwix {
if (found == string::npos) { if (found == string::npos) {
/* Put the data in the document */ /* Put the data in the document */
Xapian::Document document; currentDocument.clear_values();
document.add_value(0, this->htmlParser.title); currentDocument.add_value(0, this->htmlParser.title);
document.set_data(currentArticle.getLongUrl().c_str()); currentDocument.set_data(currentArticle.getLongUrl().c_str());
indexer.set_document(document); indexer.set_document(currentDocument);
/* Debug output */ /* Debug output */
std::cout << "Indexing " << currentArticle.getLongUrl() << "..." << std::endl; std::cout << "Indexing " << currentArticle.getLongUrl() << "..." << std::endl;
@ -135,13 +139,13 @@ namespace kiwix {
} }
/* add to the database */ /* add to the database */
this->writableDatabase->add_document(document); this->writableDatabase->add_document(currentDocument);
} }
} }
} }
/* Write Xapian DB to the disk */ /* Flush and close Xapian transaction*/
this->writableDatabase->flush(); this->writableDatabase->commit_transaction();
/* increment the offset and set returned value */ /* increment the offset and set returned value */
if (this->currentArticleOffset < this->lastArticleOffset) { if (this->currentArticleOffset < this->lastArticleOffset) {
@ -180,6 +184,7 @@ namespace kiwix {
} }
std::cout << "Read " << this->stopWords.size() << " lines.\n"; std::cout << "Read " << this->stopWords.size() << " lines.\n";
return true;
} }
} }