mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Full-text search: Use separate thread pool for search requests
This commit is contained in:
parent
c5f0f536fa
commit
e333a03d7c
8
aard.cc
8
aard.cc
|
@ -274,7 +274,8 @@ class AardDictionary: public BtreeIndexing::BtreeDictionary
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics );
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr );
|
||||
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
|
||||
|
||||
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
|
||||
|
@ -657,9 +658,10 @@ sptr< Dictionary::DataRequest > AardDictionary::getSearchResults( QString const
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics, ftsThreadPoolPtr );
|
||||
}
|
||||
|
||||
/// AardDictionary::getArticle()
|
||||
|
|
8
bgl.cc
8
bgl.cc
|
@ -244,7 +244,8 @@ namespace
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics );
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr );
|
||||
virtual QString const& getDescription();
|
||||
|
||||
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
|
||||
|
@ -1211,9 +1212,10 @@ sptr< Dictionary::DataRequest > BglDictionary::getSearchResults( QString const &
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics, ftsThreadPoolPtr );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -135,7 +135,8 @@ public:
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics );
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr );
|
||||
void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
|
||||
|
||||
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
|
||||
|
@ -599,9 +600,10 @@ sptr< Dictionary::DataRequest > DictdDictionary::getSearchResults( QString const
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics, ftsThreadPoolPtr );
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
|
@ -175,7 +175,7 @@ sptr< DataRequest > Class::getResource( string const & /*name*/ )
|
|||
return new DataRequestInstant( false );
|
||||
}
|
||||
|
||||
sptr< DataRequest > Class::getSearchResults(const QString &, int, bool, int, int, bool, bool )
|
||||
sptr< DataRequest > Class::getSearchResults(const QString &, int, bool, int, int, bool, bool, QThreadPool * )
|
||||
{
|
||||
return new DataRequestInstant( false );
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <map>
|
||||
#include <QObject>
|
||||
#include <QIcon>
|
||||
#include <QThreadPool>
|
||||
#include "cpp_features.hh"
|
||||
#include "sptr.hh"
|
||||
#include "ex.hh"
|
||||
|
@ -400,7 +401,8 @@ public:
|
|||
int distanceBetweenWords,
|
||||
int maxArticlesPerDictionary,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics );
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr );
|
||||
|
||||
// Return dictionary description if presented
|
||||
virtual QString const& getDescription();
|
||||
|
|
8
dsl.cc
8
dsl.cc
|
@ -236,7 +236,8 @@ public:
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics );
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr );
|
||||
virtual QString const& getDescription();
|
||||
|
||||
virtual QString getMainFilename();
|
||||
|
@ -2047,9 +2048,10 @@ sptr< Dictionary::DataRequest > DslDictionary::getSearchResults( QString const &
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics, ftsThreadPoolPtr );
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
|
@ -130,7 +130,8 @@ public:
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics );
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr );
|
||||
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
|
||||
|
||||
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
|
||||
|
@ -796,9 +797,10 @@ sptr< Dictionary::DataRequest > EpwingDictionary::getSearchResults( QString cons
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics, ftsThreadPoolPtr );
|
||||
}
|
||||
|
||||
int EpwingDictionary::japaneseWriting( gd::wchar ch )
|
||||
|
|
|
@ -1149,6 +1149,12 @@ void FTSResultsRequest::fullSearch( QStringList & searchWords, QRegExp & regexp
|
|||
|
||||
void FTSResultsRequest::run()
|
||||
{
|
||||
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
|
||||
{
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( dict.ensureInitDone().size() )
|
||||
{
|
||||
setErrorString( QString::fromUtf8( dict.ensureInitDone().c_str() ) );
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
|
||||
FTSResultsRequest( BtreeIndexing::BtreeDictionary & dict_, QString const & searchString_,
|
||||
int searchMode_, bool matchCase_, int distanceBetweenWords_, int maxResults_,
|
||||
bool ignoreWordsOrder_, bool ignoreDiacritics_ ):
|
||||
bool ignoreWordsOrder_, bool ignoreDiacritics_, QThreadPool * ftsThreadPoolPtr ):
|
||||
dict( dict_ ),
|
||||
searchString( searchString_ ),
|
||||
searchMode( searchMode_ ),
|
||||
|
@ -145,7 +145,7 @@ public:
|
|||
searchString = gd::toQString( Folding::applyDiacriticsOnly( gd::toWString( searchString_ ) ) );
|
||||
|
||||
foundHeadwords = new QList< FTS::FtsHeadword >;
|
||||
QThreadPool::globalInstance()->start(
|
||||
ftsThreadPoolPtr->start(
|
||||
new FTSResultsRequestRunnable( *this, hasExited ), -100 );
|
||||
}
|
||||
|
||||
|
|
|
@ -138,11 +138,15 @@ FullTextSearchDialog::FullTextSearchDialog( QWidget * parent,
|
|||
group( 0 ),
|
||||
ignoreWordsOrder( cfg_.preferences.fts.ignoreWordsOrder ),
|
||||
ignoreDiacritics( cfg_.preferences.fts.ignoreDiacritics ),
|
||||
ftsThreadPool( this ),
|
||||
searchInProgress( false ),
|
||||
ftsIdx( ftsidx )
|
||||
, helpAction( this )
|
||||
{
|
||||
ui.setupUi( this );
|
||||
|
||||
ftsThreadPool.setExpiryTimeout( -1 );
|
||||
|
||||
setAttribute( Qt::WA_DeleteOnClose, false );
|
||||
setWindowFlags( windowFlags() & ~Qt::WindowContextHelpButtonHint );
|
||||
|
||||
|
@ -429,11 +433,13 @@ void FullTextSearchDialog::accept()
|
|||
distanceBetweenWords,
|
||||
maxResultsPerDict,
|
||||
ignoreWordsOrder,
|
||||
ignoreDiacritics
|
||||
ignoreDiacritics,
|
||||
&ftsThreadPool
|
||||
);
|
||||
connect( req.get(), SIGNAL( finished() ),
|
||||
this, SLOT( searchReqFinished() ), Qt::QueuedConnection );
|
||||
|
||||
searchInProgress = true;
|
||||
searchReqs.push_back( req );
|
||||
}
|
||||
|
||||
|
@ -486,8 +492,9 @@ void FullTextSearchDialog::searchReqFinished()
|
|||
else
|
||||
break;
|
||||
}
|
||||
if ( searchReqs.empty() )
|
||||
if ( searchReqs.empty() && searchInProgress )
|
||||
{
|
||||
searchInProgress = false;
|
||||
ui.searchProgressBar->hide();
|
||||
ui.OKButton->setEnabled( true );
|
||||
QApplication::beep();
|
||||
|
|
|
@ -177,6 +177,8 @@ class FullTextSearchDialog : public QDialog
|
|||
std::vector< sptr< Dictionary::Class > > activeDicts;
|
||||
bool ignoreWordsOrder;
|
||||
bool ignoreDiacritics;
|
||||
QThreadPool ftsThreadPool;
|
||||
bool searchInProgress;
|
||||
|
||||
std::list< sptr< Dictionary::DataRequest > > searchReqs;
|
||||
|
||||
|
|
8
gls.cc
8
gls.cc
|
@ -489,7 +489,8 @@ public:
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics );
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr );
|
||||
|
||||
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
|
||||
|
||||
|
@ -1559,9 +1560,10 @@ sptr< Dictionary::DataRequest > GlsDictionary::getSearchResults( QString const &
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics, ftsThreadPoolPtr );
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
8
mdx.cc
8
mdx.cc
|
@ -257,7 +257,8 @@ public:
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics );
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr );
|
||||
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
|
||||
|
||||
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
|
||||
|
@ -536,9 +537,10 @@ sptr< Dictionary::DataRequest > MdxDictionary::getSearchResults( QString const &
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics, ftsThreadPoolPtr );
|
||||
}
|
||||
|
||||
/// MdxDictionary::getArticle
|
||||
|
|
8
sdict.cc
8
sdict.cc
|
@ -174,7 +174,8 @@ class SdictDictionary: public BtreeIndexing::BtreeDictionary
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics );
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr );
|
||||
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
|
||||
|
||||
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
|
||||
|
@ -483,9 +484,10 @@ sptr< Dictionary::DataRequest > SdictDictionary::getSearchResults( QString const
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics, ftsThreadPoolPtr );
|
||||
}
|
||||
|
||||
/// SdictDictionary::getArticle()
|
||||
|
|
8
slob.cc
8
slob.cc
|
@ -623,7 +623,8 @@ class SlobDictionary: public BtreeIndexing::BtreeDictionary
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics );
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr );
|
||||
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
|
||||
|
||||
quint64 getArticlePos(uint32_t articleNumber );
|
||||
|
@ -1344,9 +1345,10 @@ sptr< Dictionary::DataRequest > SlobDictionary::getSearchResults( QString const
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString, searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString, searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics, ftsThreadPoolPtr );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -192,7 +192,8 @@ public:
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics );
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr );
|
||||
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
|
||||
|
||||
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
|
||||
|
@ -1270,9 +1271,10 @@ sptr< Dictionary::DataRequest > StardictDictionary::getSearchResults( QString co
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics, ftsThreadPoolPtr );
|
||||
}
|
||||
|
||||
/// StardictDictionary::findHeadwordsForSynonym()
|
||||
|
|
8
xdxf.cc
8
xdxf.cc
|
@ -181,7 +181,8 @@ public:
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics );
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr );
|
||||
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
|
||||
|
||||
virtual void makeFTSIndex(QAtomicInt & isCancelled, bool firstIteration );
|
||||
|
@ -426,9 +427,10 @@ sptr< Dictionary::DataRequest > XdxfDictionary::getSearchResults( QString const
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics, ftsThreadPoolPtr );
|
||||
}
|
||||
|
||||
/// XdxfDictionary::getArticle()
|
||||
|
|
8
zim.cc
8
zim.cc
|
@ -708,7 +708,8 @@ class ZimDictionary: public BtreeIndexing::BtreeDictionary
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics );
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr );
|
||||
virtual void getArticleText( uint32_t articleAddress, QString & headword, QString & text );
|
||||
|
||||
quint32 getArticleText( uint32_t articleAddress, QString & headword, QString & text,
|
||||
|
@ -1288,9 +1289,10 @@ sptr< Dictionary::DataRequest > ZimDictionary::getSearchResults( QString const &
|
|||
int distanceBetweenWords,
|
||||
int maxResults,
|
||||
bool ignoreWordsOrder,
|
||||
bool ignoreDiacritics )
|
||||
bool ignoreDiacritics,
|
||||
QThreadPool * ftsThreadPoolPtr )
|
||||
{
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics );
|
||||
return new FtsHelpers::FTSResultsRequest( *this, searchString,searchMode, matchCase, distanceBetweenWords, maxResults, ignoreWordsOrder, ignoreDiacritics, ftsThreadPoolPtr );
|
||||
}
|
||||
|
||||
/// ZimDictionary::getArticle()
|
||||
|
|
Loading…
Reference in a new issue