opt: remove fulltext unused logic (#1733)

* opt: remove fulltext unused logic

the firstIteration is not used any more
This commit is contained in:
xiaoyifang 2024-08-24 07:45:45 +08:00 committed by GitHub
parent 3ca7c39e69
commit fc3ea0045e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 26 additions and 51 deletions

View file

@ -259,7 +259,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override void setFTSParameters( Config::FullTextSearch const & fts ) override
{ {
@ -544,7 +544,7 @@ QString const & AardDictionary::getDescription()
return dictionaryDescription; return dictionaryDescription;
} }
void AardDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) void AardDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{ {
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -556,8 +556,6 @@ void AardDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( ensureInitDone().size() ) if ( ensureInitDone().size() )
return; return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Aard: Building the full-text index for dictionary: %s\n", getName().c_str() ); gdDebug( "Aard: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -215,7 +215,7 @@ public:
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override void setFTSParameters( Config::FullTextSearch const & fts ) override
{ {
@ -414,7 +414,7 @@ void BglDictionary::getArticleText( uint32_t articleAddress, QString & headword,
} }
} }
void BglDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) void BglDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{ {
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -423,8 +423,6 @@ void BglDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( haveFTSIndex() ) if ( haveFTSIndex() )
return; return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Bgl: Building the full-text index for dictionary: %s\n", getName().c_str() ); gdDebug( "Bgl: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -136,7 +136,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override void setFTSParameters( Config::FullTextSearch const & fts ) override
{ {
@ -435,7 +435,7 @@ QString const & DictdDictionary::getDescription()
return dictionaryDescription; return dictionaryDescription;
} }
void DictdDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) void DictdDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{ {
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -447,8 +447,6 @@ void DictdDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteratio
if ( ensureInitDone().size() ) if ( ensureInitDone().size() )
return; return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "DictD: Building the full-text index for dictionary: %s\n", getName().c_str() ); gdDebug( "DictD: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -523,7 +523,7 @@ public:
} }
/// Make index for full-text search /// Make index for full-text search
virtual void makeFTSIndex( QAtomicInt &, bool ) {} virtual void makeFTSIndex( QAtomicInt & ) {}
/// Set full-text search parameters /// Set full-text search parameters
virtual void setFTSParameters( Config::FullTextSearch const & ) {} virtual void setFTSParameters( Config::FullTextSearch const & ) {}

View file

@ -229,7 +229,7 @@ public:
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override void setFTSParameters( Config::FullTextSearch const & fts ) override
{ {
@ -1072,7 +1072,7 @@ QString DslDictionary::getMainFilename()
return getDictionaryFilenames()[ 0 ].c_str(); return getDictionaryFilenames()[ 0 ].c_str();
} }
void DslDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) void DslDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{ {
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) { || FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) {
@ -1086,8 +1086,6 @@ void DslDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( !ensureInitDone().empty() ) if ( !ensureInitDone().empty() )
return; return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Dsl: Building the full-text index for dictionary: %s\n", getName().c_str() ); gdDebug( "Dsl: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -148,7 +148,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override void setFTSParameters( Config::FullTextSearch const & fts ) override
{ {
@ -425,7 +425,7 @@ QString const & EpwingDictionary::getDescription()
return dictionaryDescription; return dictionaryDescription;
} }
void EpwingDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) void EpwingDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{ {
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -435,8 +435,6 @@ void EpwingDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIterati
if ( haveFTSIndex() ) if ( haveFTSIndex() )
return; return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Epwing: Building the full-text index for dictionary: %s\n", getName().c_str() ); gdDebug( "Epwing: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -404,7 +404,7 @@ public:
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override void setFTSParameters( Config::FullTextSearch const & fts ) override
{ {
@ -546,7 +546,7 @@ QString GlsDictionary::getMainFilename()
return getDictionaryFilenames()[ 0 ].c_str(); return getDictionaryFilenames()[ 0 ].c_str();
} }
void GlsDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) void GlsDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{ {
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -558,8 +558,6 @@ void GlsDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( ensureInitDone().size() ) if ( ensureInitDone().size() )
return; return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Gls: Building the full-text index for dictionary: %s\n", getName().c_str() ); gdDebug( "Gls: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -254,7 +254,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override void setFTSParameters( Config::FullTextSearch const & fts ) override
{ {
@ -438,7 +438,7 @@ void MdxDictionary::doDeferredInit()
} }
} }
void MdxDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) void MdxDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{ {
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -450,8 +450,6 @@ void MdxDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
// if( !ensureInitDone().empty() ) // if( !ensureInitDone().empty() )
// return; // return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "MDict: Building the full-text index for dictionary: %s", getName().c_str() ); gdDebug( "MDict: Building the full-text index for dictionary: %s", getName().c_str() );

View file

@ -173,7 +173,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override void setFTSParameters( Config::FullTextSearch const & fts ) override
{ {
@ -379,7 +379,7 @@ void SdictDictionary::loadArticle( uint32_t address, string & articleText )
articleText.append( "</div>" ); articleText.append( "</div>" );
} }
void SdictDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) void SdictDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{ {
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -391,8 +391,6 @@ void SdictDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteratio
if ( ensureInitDone().size() ) if ( ensureInitDone().size() )
return; return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "SDict: Building the full-text index for dictionary: %s\n", getName().c_str() ); gdDebug( "SDict: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -636,7 +636,7 @@ public:
quint64 getArticlePos( uint32_t articleNumber ); quint64 getArticlePos( uint32_t articleNumber );
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override void setFTSParameters( Config::FullTextSearch const & fts ) override
{ {
@ -891,7 +891,7 @@ quint64 SlobDictionary::getArticlePos( uint32_t articleNumber )
return ( ( (quint64)( entry.binIndex ) ) << 32 ) | entry.itemIndex; return ( ( (quint64)( entry.binIndex ) ) << 32 ) | entry.itemIndex;
} }
void SlobDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) void SlobDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{ {
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -903,8 +903,6 @@ void SlobDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( !ensureInitDone().empty() ) if ( !ensureInitDone().empty() )
return; return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Slob: Building the full-text index for dictionary: %s\n", getName().c_str() ); gdDebug( "Slob: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -196,7 +196,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override void setFTSParameters( Config::FullTextSearch const & fts ) override
{ {
@ -1085,7 +1085,7 @@ QString StardictDictionary::getMainFilename()
return getDictionaryFilenames()[ 0 ].c_str(); return getDictionaryFilenames()[ 0 ].c_str();
} }
void StardictDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) void StardictDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{ {
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -1097,8 +1097,6 @@ void StardictDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstItera
if ( ensureInitDone().size() ) if ( ensureInitDone().size() )
return; return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Stardict: Building the full-text index for dictionary: %s\n", getName().c_str() ); gdDebug( "Stardict: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -196,7 +196,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override void setFTSParameters( Config::FullTextSearch const & fts ) override
{ {
@ -369,7 +369,7 @@ QString XdxfDictionary::getMainFilename()
return getDictionaryFilenames()[ 0 ].c_str(); return getDictionaryFilenames()[ 0 ].c_str();
} }
void XdxfDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) void XdxfDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{ {
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -381,8 +381,6 @@ void XdxfDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( ensureInitDone().size() ) if ( ensureInitDone().size() )
return; return;
if ( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "Xdxf: Building the full-text index for dictionary: %s\n", getName().c_str() ); gdDebug( "Xdxf: Building the full-text index for dictionary: %s\n", getName().c_str() );

View file

@ -217,7 +217,7 @@ public:
getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override; getSearchResults( QString const & searchString, int searchMode, bool matchCase, bool ignoreDiacritics ) override;
void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override; void getArticleText( uint32_t articleAddress, QString & headword, QString & text ) override;
void makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) override; void makeFTSIndex( QAtomicInt & isCancelled ) override;
void setFTSParameters( Config::FullTextSearch const & fts ) override void setFTSParameters( Config::FullTextSearch const & fts ) override
{ {
@ -480,7 +480,7 @@ QString const & ZimDictionary::getDescription()
return dictionaryDescription; return dictionaryDescription;
} }
void ZimDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration ) void ZimDictionary::makeFTSIndex( QAtomicInt & isCancelled )
{ {
if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName ) if ( !( Dictionary::needToRebuildIndex( getDictionaryFilenames(), ftsIdxName )
|| FtsHelpers::ftsIndexIsOldOrBad( this ) ) ) || FtsHelpers::ftsIndexIsOldOrBad( this ) ) )
@ -492,9 +492,6 @@ void ZimDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if ( !ensureInitDone().empty() ) if ( !ensureInitDone().empty() )
return; return;
if ( firstIteration )
return;
gdDebug( "Zim: Building the full-text index for dictionary: %s\n", getName().c_str() ); gdDebug( "Zim: Building the full-text index for dictionary: %s\n", getName().c_str() );
try { try {
FtsHelpers::makeFTSIndex( this, isCancelled ); FtsHelpers::makeFTSIndex( this, isCancelled );

View file

@ -34,7 +34,7 @@ void Indexing::run()
const QString & dictionaryName = QString::fromUtf8( dictionary->getName().c_str() ); const QString & dictionaryName = QString::fromUtf8( dictionary->getName().c_str() );
qDebug() << "[FULLTEXT] checking fts for the dictionary:" << dictionaryName; qDebug() << "[FULLTEXT] checking fts for the dictionary:" << dictionaryName;
emit sendNowIndexingName( dictionaryName ); emit sendNowIndexingName( dictionaryName );
dictionary->makeFTSIndex( isCancelled, false ); dictionary->makeFTSIndex( isCancelled );
} ); } );
synchronizer.addFuture( f ); synchronizer.addFuture( f );
} }