mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
Merge pull request #960 from xiaoyifang/opt/slob-fulltext-creation
opt: boost slob fulltext speed
This commit is contained in:
commit
2b1d91638e
|
@ -584,6 +584,8 @@ class SlobDictionary: public BtreeIndexing::BtreeDictionary
|
|||
SlobFile sf;
|
||||
QString texCgiPath, texCachePath;
|
||||
|
||||
string idxFileName;
|
||||
|
||||
public:
|
||||
|
||||
SlobDictionary( string const & id, string const & indexFile, vector< string > const & dictionaryFiles );
|
||||
|
@ -662,12 +664,11 @@ private:
|
|||
friend class SlobResourceRequest;
|
||||
};
|
||||
|
||||
SlobDictionary::SlobDictionary( string const & id,
|
||||
string const & indexFile,
|
||||
vector< string > const & dictionaryFiles ):
|
||||
BtreeDictionary( id, dictionaryFiles ),
|
||||
idx( indexFile, "rb" ),
|
||||
idxHeader( idx.read< IdxHeader >() )
|
||||
SlobDictionary::SlobDictionary( string const & id, string const & indexFile, vector< string > const & dictionaryFiles ):
|
||||
BtreeDictionary( id, dictionaryFiles ),
|
||||
idxFileName( indexFile ),
|
||||
idx( indexFile, "rb" ),
|
||||
idxHeader( idx.read< IdxHeader >() )
|
||||
{
|
||||
// Open data file
|
||||
|
||||
|
@ -1088,26 +1089,7 @@ quint64 SlobDictionary::getArticlePos( uint32_t articleNumber )
|
|||
|
||||
void SlobDictionary::sortArticlesOffsetsForFTS( QVector< uint32_t > & offsets, QAtomicInt & isCancelled )
|
||||
{
|
||||
QVector< uint32_t > newOffsets;
|
||||
newOffsets.reserve( offsets.size() );
|
||||
|
||||
{
|
||||
QMutexLocker _( &slobMutex );
|
||||
|
||||
SlobFile::RefOffsetsVector const & sortedOffsets = sf.getSortedRefOffsets();
|
||||
|
||||
qint32 entries = sf.getRefsCount();
|
||||
for ( qint32 i = 0; i < entries; i++ ) {
|
||||
if ( Utils::AtomicInt::loadAcquire( isCancelled ) )
|
||||
throw exUserAbort();
|
||||
if ( offsets.contains( sortedOffsets[ i ].second ) )
|
||||
newOffsets.append( sortedOffsets[ i ].second );
|
||||
}
|
||||
}
|
||||
|
||||
offsets.reserve( newOffsets.size() );
|
||||
for ( int i = 0; i < newOffsets.size(); i++ )
|
||||
offsets[ i ] = newOffsets.at( i );
|
||||
//Currently , we use xapian to create the fulltext index. The order of offsets is no important.
|
||||
}
|
||||
|
||||
void SlobDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration )
|
||||
|
@ -1130,7 +1112,8 @@ void SlobDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
|
|||
|
||||
try
|
||||
{
|
||||
FtsHelpers::makeFTSIndex( this, isCancelled );
|
||||
const auto slob_dic = std::make_unique< SlobDictionary >( getId(), idxFileName, getDictionaryFilenames() );
|
||||
FtsHelpers::makeFTSIndex( slob_dic.get(), isCancelled );
|
||||
FTS_index_completed.ref();
|
||||
}
|
||||
catch( std::exception &ex )
|
||||
|
|
Loading…
Reference in a new issue