mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 03:10:12 +02:00
* Made Pipeline more robust (mutex-protection).
* Use _CLNEW instead of the vanilla "new" when allocating Lucene's objects. * Limit WelcomeWidget's initial recently played tracks to 50 songs.
This commit is contained in:
@@ -19,7 +19,7 @@ FuzzyIndex::FuzzyIndex( DatabaseImpl& db )
|
|||||||
bool create = !lucene::index::IndexReader::indexExists( lucenePath.toStdString().c_str() );
|
bool create = !lucene::index::IndexReader::indexExists( lucenePath.toStdString().c_str() );
|
||||||
m_luceneDir = lucene::store::FSDirectory::getDirectory( lucenePath.toStdString().c_str(), create );
|
m_luceneDir = lucene::store::FSDirectory::getDirectory( lucenePath.toStdString().c_str(), create );
|
||||||
|
|
||||||
m_analyzer = new lucene::analysis::SimpleAnalyzer();
|
m_analyzer = _CLNEW lucene::analysis::SimpleAnalyzer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -68,13 +68,13 @@ FuzzyIndex::appendFields( const QString& table, const QMap< unsigned int, QStrin
|
|||||||
QString name = it.value();
|
QString name = it.value();
|
||||||
|
|
||||||
{
|
{
|
||||||
lucene::document::Field* field = new lucene::document::Field( table.toStdWString().c_str(), name.toStdWString().c_str(),
|
lucene::document::Field* field = _CLNEW lucene::document::Field( table.toStdWString().c_str(), name.toStdWString().c_str(),
|
||||||
lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_UNTOKENIZED );
|
lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_UNTOKENIZED );
|
||||||
doc.add( *field );
|
doc.add( *field );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
lucene::document::Field* field = new lucene::document::Field( _T( "id" ), QString::number( id ).toStdWString().c_str(),
|
lucene::document::Field* field = _CLNEW lucene::document::Field( _T( "id" ), QString::number( id ).toStdWString().c_str(),
|
||||||
lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO );
|
lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO );
|
||||||
doc.add( *field );
|
doc.add( *field );
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ FuzzyIndex::search( const QString& table, const QString& name )
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_luceneReader = lucene::index::IndexReader::open( m_luceneDir );
|
m_luceneReader = lucene::index::IndexReader::open( m_luceneDir );
|
||||||
m_luceneSearcher = new lucene::search::IndexSearcher( m_luceneReader );
|
m_luceneSearcher = _CLNEW lucene::search::IndexSearcher( m_luceneReader );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( name.isEmpty() )
|
if ( name.isEmpty() )
|
||||||
@@ -119,8 +119,7 @@ FuzzyIndex::search( const QString& table, const QString& name )
|
|||||||
lucene::queryParser::QueryParser parser( table.toStdWString().c_str(), m_analyzer );
|
lucene::queryParser::QueryParser parser( table.toStdWString().c_str(), m_analyzer );
|
||||||
lucene::search::Hits* hits = 0;
|
lucene::search::Hits* hits = 0;
|
||||||
|
|
||||||
lucene::search::FuzzyQuery* qry = new lucene::search::FuzzyQuery( new lucene::index::Term( table.toStdWString().c_str(),
|
lucene::search::FuzzyQuery* qry = _CLNEW lucene::search::FuzzyQuery( _CLNEW lucene::index::Term( table.toStdWString().c_str(), name.toStdWString().c_str() ) );
|
||||||
name.toStdWString().c_str() ) );
|
|
||||||
hits = m_luceneSearcher->search( qry );
|
hits = m_luceneSearcher->search( qry );
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < hits->length(); i++ )
|
for ( unsigned int i = 0; i < hits->length(); i++ )
|
||||||
|
@@ -85,16 +85,16 @@ Pipeline::resolve( const QList<query_ptr>& qlist, bool prioritized )
|
|||||||
m_qids.insert( q->id(), q );
|
m_qids.insert( q->id(), q );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( prioritized )
|
if ( prioritized )
|
||||||
{
|
{
|
||||||
for( int i = qlist.count() - 1; i >= 0; i-- )
|
for( int i = qlist.count() - 1; i >= 0; i-- )
|
||||||
m_queries_pending.insert( 0, qlist.at( i ) );
|
m_queries_pending.insert( 0, qlist.at( i ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_queries_pending.append( qlist );
|
m_queries_pending.append( qlist );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_index_ready && m_queries_pending.count() )
|
if ( m_index_ready && m_queries_pending.count() )
|
||||||
@@ -161,19 +161,25 @@ Pipeline::reportResults( QID qid, const QList< result_ptr >& results )
|
|||||||
void
|
void
|
||||||
Pipeline::shuntNext()
|
Pipeline::shuntNext()
|
||||||
{
|
{
|
||||||
if ( m_queries_pending.isEmpty() )
|
query_ptr q;
|
||||||
|
|
||||||
{
|
{
|
||||||
emit idle();
|
QMutexLocker lock( &m_mut );
|
||||||
return;
|
|
||||||
|
if ( m_queries_pending.isEmpty() )
|
||||||
|
{
|
||||||
|
emit idle();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Since resolvers are async, we now dispatch to the highest weighted ones
|
||||||
|
and after timeout, dispatch to next highest etc, aborting when solved
|
||||||
|
*/
|
||||||
|
q = m_queries_pending.takeFirst();
|
||||||
|
q->setLastPipelineWeight( 101 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Since resolvers are async, we now dispatch to the highest weighted ones
|
|
||||||
and after timeout, dispatch to next highest etc, aborting when solved
|
|
||||||
*/
|
|
||||||
|
|
||||||
query_ptr q = m_queries_pending.takeFirst();
|
|
||||||
q->setLastPipelineWeight( 101 );
|
|
||||||
shunt( q ); // bump into next stage of pipeline (highest weights are 100)
|
shunt( q ); // bump into next stage of pipeline (highest weights are 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,7 +6,8 @@ using namespace Tomahawk;
|
|||||||
|
|
||||||
|
|
||||||
Result::Result( const QVariant& v, const collection_ptr& collection )
|
Result::Result( const QVariant& v, const collection_ptr& collection )
|
||||||
: m_v( v )
|
: QObject()
|
||||||
|
, m_v( v )
|
||||||
, m_collection( collection )
|
, m_collection( collection )
|
||||||
{
|
{
|
||||||
QVariantMap m = m_v.toMap();
|
QVariantMap m = m_v.toMap();
|
||||||
|
@@ -27,7 +27,7 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
|
|||||||
|
|
||||||
m_tracksModel = new PlaylistModel( ui->tracksView );
|
m_tracksModel = new PlaylistModel( ui->tracksView );
|
||||||
ui->tracksView->setModel( m_tracksModel );
|
ui->tracksView->setModel( m_tracksModel );
|
||||||
m_tracksModel->loadHistory( Tomahawk::source_ptr() );
|
m_tracksModel->loadHistory( Tomahawk::source_ptr(), 50 );
|
||||||
|
|
||||||
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user