[Opentrep-svn] SF.net SVN: opentrep:[201] trunk/opentrep/opentrep
Status: Beta
Brought to you by:
denis_arnaud
From: <den...@us...> - 2009-10-04 18:10:38
|
Revision: 201 http://opentrep.svn.sourceforge.net/opentrep/?rev=201&view=rev Author: denis_arnaud Date: 2009-10-04 18:10:32 +0000 (Sun, 04 Oct 2009) Log Message: ----------- [Dev] The number of (database) entries is now shown after the indexation. Modified Paths: -------------- trunk/opentrep/opentrep/OPENTREP_Service.hpp trunk/opentrep/opentrep/OPENTREP_Types.hpp trunk/opentrep/opentrep/batches/indexer.cpp trunk/opentrep/opentrep/command/IndexBuilder.cpp trunk/opentrep/opentrep/command/IndexBuilder.hpp trunk/opentrep/opentrep/service/OPENTREP_Service.cpp Modified: trunk/opentrep/opentrep/OPENTREP_Service.hpp =================================================================== --- trunk/opentrep/opentrep/OPENTREP_Service.hpp 2009-10-04 17:50:46 UTC (rev 200) +++ trunk/opentrep/opentrep/OPENTREP_Service.hpp 2009-10-04 18:10:32 UTC (rev 201) @@ -24,7 +24,7 @@ public: // /////////// Business Methods ///////////// /** Build the Xapian database (index) on the BOM held in memory. */ - void buildSearchIndex(); + NbOfDBEntries_T buildSearchIndex(); /** Match the given string, thanks to a full-text search on the underlying Xapian index (named "database"). Modified: trunk/opentrep/opentrep/OPENTREP_Types.hpp =================================================================== --- trunk/opentrep/opentrep/OPENTREP_Types.hpp 2009-10-04 17:50:46 UTC (rev 200) +++ trunk/opentrep/opentrep/OPENTREP_Types.hpp 2009-10-04 18:10:32 UTC (rev 201) @@ -96,6 +96,9 @@ /** Travel search query. */ typedef std::string TravelQuery_T; + /** Number of entries in the Xapian database. */ + typedef unsigned int NbOfDBEntries_T; + /** Word, which is the atomic element of a query string. */ typedef std::string Word_T; Modified: trunk/opentrep/opentrep/batches/indexer.cpp =================================================================== --- trunk/opentrep/opentrep/batches/indexer.cpp 2009-10-04 17:50:46 UTC (rev 200) +++ trunk/opentrep/opentrep/batches/indexer.cpp 2009-10-04 18:10:32 UTC (rev 201) @@ -212,11 +212,15 @@ lXapianDatabaseName); // Launch the indexation - opentrepService.buildSearchIndex(); + const OPENTREP::NbOfDBEntries_T lNbOfEntries = + opentrepService.buildSearchIndex(); // Close the Log outputFile logOutputFile.close(); + // + std::cout << lNbOfEntries << " entries have been processed" << std::endl; + } catch (const OPENTREP::RootException& otexp) { std::cerr << "Standard exception: " << otexp.what() << std::endl; return -1; Modified: trunk/opentrep/opentrep/command/IndexBuilder.cpp =================================================================== --- trunk/opentrep/opentrep/command/IndexBuilder.cpp 2009-10-04 17:50:46 UTC (rev 200) +++ trunk/opentrep/opentrep/command/IndexBuilder.cpp 2009-10-04 18:10:32 UTC (rev 201) @@ -141,9 +141,10 @@ } // ////////////////////////////////////////////////////////////////////// - void IndexBuilder:: + NbOfDBEntries_T IndexBuilder:: buildSearchIndex (soci::session& ioSociSession, const TravelDatabaseName_T& iTravelDatabaseName) { + NbOfDBEntries_T oNbOfEntries = 0; try { @@ -164,7 +165,6 @@ lDatabase.begin_transaction(); // Iterate through the retrieved database rows - int idx = 1; const bool shouldDoReset = true; bool hasStillData = DBManager::iterateOnStatement (lSelectStatement, lPlace, @@ -174,11 +174,13 @@ // Xapian index IndexBuilder::addDocumentToIndex (lDatabase, lPlace); + // + ++oNbOfEntries; + // DEBUG - OPENTREP_LOG_DEBUG ("[" << idx << "] " << lPlace); + OPENTREP_LOG_DEBUG ("[" << oNbOfEntries << "] " << lPlace); - // Index incrementing - ++idx; + // Iterate on the MySQL database cursor hasStillData = DBManager::iterateOnStatement (lSelectStatement, lPlace, shouldDoReset); } @@ -198,6 +200,8 @@ OPENTREP_LOG_ERROR ("Error: " << lStdError.what()); throw RootException(); } + + return oNbOfEntries; } } Modified: trunk/opentrep/opentrep/command/IndexBuilder.hpp =================================================================== --- trunk/opentrep/opentrep/command/IndexBuilder.hpp 2009-10-04 17:50:46 UTC (rev 200) +++ trunk/opentrep/opentrep/command/IndexBuilder.hpp 2009-10-04 18:10:32 UTC (rev 201) @@ -29,7 +29,8 @@ static void addDocumentToIndex (Xapian::WritableDatabase&, Place&); /** Build Xapian database. */ - static void buildSearchIndex (soci::session&, const TravelDatabaseName_T&); + static NbOfDBEntries_T buildSearchIndex (soci::session&, + const TravelDatabaseName_T&); private: /** Constructors. */ Modified: trunk/opentrep/opentrep/service/OPENTREP_Service.cpp =================================================================== --- trunk/opentrep/opentrep/service/OPENTREP_Service.cpp 2009-10-04 17:50:46 UTC (rev 200) +++ trunk/opentrep/opentrep/service/OPENTREP_Service.cpp 2009-10-04 18:10:32 UTC (rev 201) @@ -99,7 +99,9 @@ } // ////////////////////////////////////////////////////////////////////// - void OPENTREP_Service::buildSearchIndex () { + NbOfDBEntries_T OPENTREP_Service::buildSearchIndex () { + NbOfDBEntries_T oNbOfEntries = 0; + if (_opentrepServiceContext == NULL) { throw NonInitialisedServiceException(); } @@ -119,7 +121,8 @@ // Delegate the index building to the dedicated command BasChronometer lBuildSearchIndexChronometer; lBuildSearchIndexChronometer.start(); - IndexBuilder::buildSearchIndex (lSociSession, lTravelDatabaseName); + oNbOfEntries = IndexBuilder::buildSearchIndex (lSociSession, + lTravelDatabaseName); const double lBuildSearchIndexMeasure = lBuildSearchIndexChronometer.elapsed(); @@ -131,7 +134,9 @@ } catch (const std::exception& error) { OPENTREP_LOG_ERROR ("Exception: " << error.what()); throw BuildIndexException(); - } + } + + return oNbOfEntries; } // ////////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |