1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-10 22:20:43 +02:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Christian Muehlhaeuser
588b9898dd * Backported breakpad building fix. 2013-06-05 09:17:59 +02:00
Teo Mrnjavac
072a2e8d78 Avoid crash in SuperCollection. 2013-05-10 10:04:29 +02:00
Christian Muehlhaeuser
247c184ba3 * Updated ChangeLog. 2013-05-07 04:31:32 +02:00
Christian Muehlhaeuser
af6f96728f * Worked around Lucene memory leak and improved our own memory foot-print during indexing. 2013-05-07 04:30:24 +02:00
Christian Muehlhaeuser
03b581856f * Updated README.md. 2013-05-05 04:59:06 +02:00
8 changed files with 83 additions and 71 deletions

View File

@@ -1,3 +1,6 @@
Version 0.7.1:
* Heavily reduced memory footprint during and after indexing the database.
Version 0.7.0:
* JavaScript Resolvers can now expose collections.
* Introduced bundle system for JavaScript Resolvers, called "axes".

View File

@@ -44,7 +44,7 @@ Required dependencies:
* TagLib 1.6.2 - http://developer.kde.org/~wheeler/taglib.html
* Boost 1.3 - http://www.boost.org/
* CLucene 0.9.23 (0.9.21 will fail) - http://clucene.sourceforge.net/download.shtml
* libechonest 2.0.2 - http://projects.kde.org/projects/playground/libs/libechonest/
* libechonest 2.0.3 - http://projects.kde.org/projects/playground/libs/libechonest/
* Attica 0.4.0 - ftp://ftp.kde.org/pub/kde/stable/attica/
* QuaZip 0.4.3 - http://quazip.sourceforge.net/
* liblastfm 1.0.1 - https://github.com/lastfm/liblastfm/

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2012 Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
@@ -49,6 +49,8 @@ DatabaseCommand_UpdateSearchIndex::DatabaseCommand_UpdateSearchIndex()
DatabaseCommand_UpdateSearchIndex::~DatabaseCommand_UpdateSearchIndex()
{
tDebug() << Q_FUNC_INFO;
#ifndef ENABLE_HEADLESS
if ( ! m_statusJob.isNull() )
m_statusJob.data()->done();
@@ -61,35 +63,30 @@ DatabaseCommand_UpdateSearchIndex::exec( DatabaseImpl* db )
{
db->m_fuzzyIndex->beginIndexing();
QMap< unsigned int, QMap< QString, QString > > data;
TomahawkSqlQuery q = db->newquery();
q.exec( "SELECT track.id, track.name, artist.name, artist.id FROM track, artist WHERE artist.id = track.artist" );
while ( q.next() )
{
QMap< QString, QString > track;
track.insert( "track", q.value( 1 ).toString() );
track.insert( "artist", q.value( 2 ).toString() );
track.insert( "artistid", q.value( 3 ).toString() );
IndexData ida;
ida.id = q.value( 0 ).toUInt();
ida.artistId = q.value( 3 ).toUInt();
ida.track = q.value( 1 ).toString();
ida.artist = q.value( 2 ).toString();
data.insert( q.value( 0 ).toUInt(), track );
db->m_fuzzyIndex->appendFields( ida );
}
db->m_fuzzyIndex->appendFields( data );
data.clear();
q.exec( "SELECT album.id, album.name FROM album" );
while ( q.next() )
{
QMap< QString, QString > album;
album.insert( "album", q.value( 1 ).toString() );
IndexData ida;
ida.id = q.value( 0 ).toUInt();
ida.album = q.value( 1 ).toString();
data.insert( q.value( 0 ).toUInt(), album );
db->m_fuzzyIndex->appendFields( ida );
}
db->m_fuzzyIndex->appendFields( data );
qDebug() << "Building index finished.";
tDebug( LOGVERBOSE ) << "Building index finished.";
db->m_fuzzyIndex->endIndexing();
}

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,6 +25,15 @@
class IndexingJobItem;
struct IndexData
{
unsigned int id;
unsigned int artistId;
QString artist;
QString album;
QString track;
};
class DLLEXPORT DatabaseCommand_UpdateSearchIndex : public DatabaseCommand
{
Q_OBJECT

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,7 +24,6 @@
#include <CLucene.h>
#include <CLucene/queryParser/MultiFieldQueryParser.h>
#include "DatabaseCommand_UpdateSearchIndex.h"
#include "DatabaseImpl.h"
#include "Database.h"
#include "utils/TomahawkUtils.h"
@@ -112,10 +111,11 @@ FuzzyIndex::beginIndexing()
try
{
qDebug() << Q_FUNC_INFO << "Starting indexing.";
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Starting indexing.";
if ( m_luceneReader != 0 )
{
qDebug() << "Deleting old lucene stuff.";
tDebug( LOGVERBOSE ) << "Deleting old lucene stuff.";
m_luceneSearcher->close();
m_luceneReader->close();
delete m_luceneSearcher;
@@ -124,8 +124,8 @@ FuzzyIndex::beginIndexing()
m_luceneReader = 0;
}
qDebug() << "Creating new index writer.";
IndexWriter luceneWriter( m_luceneDir, m_analyzer, true );
tDebug( LOGVERBOSE ) << "Creating new index writer.";
m_luceneWriter = new IndexWriter( m_luceneDir, m_analyzer, true );
}
catch( CLuceneError& error )
{
@@ -138,62 +138,52 @@ FuzzyIndex::beginIndexing()
void
FuzzyIndex::endIndexing()
{
m_luceneWriter->optimize();
m_luceneWriter->close();
delete m_luceneWriter;
m_luceneWriter = 0;
m_mutex.unlock();
emit indexReady();
}
void
FuzzyIndex::appendFields( const QMap< unsigned int, QMap< QString, QString > >& trackData )
FuzzyIndex::appendFields( const IndexData& data )
{
try
{
tDebug() << "Appending to index:" << trackData.count();
bool create = !IndexReader::indexExists( TomahawkUtils::appDataDir().absoluteFilePath( "tomahawk.lucene" ).toStdString().c_str() );
IndexWriter luceneWriter( m_luceneDir, m_analyzer, create );
Document doc;
QMapIterator< unsigned int, QMap< QString, QString > > it( trackData );
while ( it.hasNext() )
if ( !data.track.isEmpty() )
{
it.next();
unsigned int id = it.key();
QMap< QString, QString > values = it.value();
doc.add( *( _CLNEW Field( _T( "fulltext" ), DatabaseImpl::sortname( QString( "%1 %2" ).arg( data.artist ).arg( data.track ) ).toStdWString().c_str(),
Field::STORE_NO | Field::INDEX_UNTOKENIZED ) ) );
if ( values.contains( "track" ) )
{
doc.add( *( _CLNEW Field( _T( "fulltext" ), DatabaseImpl::sortname( QString( "%1 %2" ).arg( values.value( "artist" ) ).arg( values.value( "track" ) ) ).toStdWString().c_str(),
Field::STORE_NO | Field::INDEX_UNTOKENIZED ) ) );
doc.add( *( _CLNEW Field( _T( "track" ), DatabaseImpl::sortname( data.track ).toStdWString().c_str(),
Field::STORE_NO | Field::INDEX_UNTOKENIZED ) ) );
doc.add( *( _CLNEW Field( _T( "track" ), DatabaseImpl::sortname( values.value( "track" ) ).toStdWString().c_str(),
Field::STORE_NO | Field::INDEX_UNTOKENIZED ) ) );
doc.add( *( _CLNEW Field( _T( "artist" ), DatabaseImpl::sortname( data.artist ).toStdWString().c_str(),
Field::STORE_NO | Field::INDEX_UNTOKENIZED ) ) );
doc.add( *( _CLNEW Field( _T( "artist" ), DatabaseImpl::sortname( values.value( "artist" ) ).toStdWString().c_str(),
Field::STORE_NO | Field::INDEX_UNTOKENIZED ) ) );
doc.add( *( _CLNEW Field( _T( "artistid" ), QString::number( data.artistId ).toStdWString().c_str(),
Field::STORE_YES | Field::INDEX_NO ) ) );
doc.add( *( _CLNEW Field( _T( "artistid" ), values.value( "artistid" ).toStdWString().c_str(),
Field::STORE_YES | Field::INDEX_NO ) ) );
doc.add( *( _CLNEW Field( _T( "trackid" ), QString::number( id ).toStdWString().c_str(),
Field::STORE_YES | Field::INDEX_NO ) ) );
}
else if ( values.contains( "album" ) )
{
doc.add( *( _CLNEW Field( _T( "album" ), DatabaseImpl::sortname( values.value( "album" ) ).toStdWString().c_str(),
Field::STORE_NO | Field::INDEX_UNTOKENIZED ) ) );
doc.add( *( _CLNEW Field( _T( "albumid" ), QString::number( id ).toStdWString().c_str(),
Field::STORE_YES | Field::INDEX_NO ) ) );
}
else
Q_ASSERT( false );
luceneWriter.addDocument( &doc );
doc.clear();
doc.add( *( _CLNEW Field( _T( "trackid" ), QString::number( data.id ).toStdWString().c_str(),
Field::STORE_YES | Field::INDEX_NO ) ) );
}
else if ( !data.album.isEmpty() )
{
doc.add( *( _CLNEW Field( _T( "album" ), DatabaseImpl::sortname( data.album ).toStdWString().c_str(),
Field::STORE_NO | Field::INDEX_UNTOKENIZED ) ) );
luceneWriter.optimize();
luceneWriter.close();
doc.add( *( _CLNEW Field( _T( "albumid" ), QString::number( data.id ).toStdWString().c_str(),
Field::STORE_YES | Field::INDEX_NO ) ) );
}
else
Q_ASSERT( false );
m_luceneWriter->addDocument( &doc );
}
catch( CLuceneError& error )
{
@@ -223,7 +213,7 @@ FuzzyIndex::search( const Tomahawk::query_ptr& query )
{
if ( !IndexReader::indexExists( TomahawkUtils::appDataDir().absoluteFilePath( "tomahawk.lucene" ).toStdString().c_str() ) )
{
qDebug() << Q_FUNC_INFO << "index didn't exist.";
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "index didn't exist.";
return resultsmap;
}
@@ -314,7 +304,7 @@ FuzzyIndex::searchAlbum( const Tomahawk::query_ptr& query )
{
if ( !IndexReader::indexExists( TomahawkUtils::appDataDir().absoluteFilePath( "tomahawk.lucene" ).toStdString().c_str() ) )
{
qDebug() << Q_FUNC_INFO << "index didn't exist.";
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "index didn't exist.";
return resultsmap;
}

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Copyright 2010-2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,6 +26,7 @@
#include <QMutex>
#include "Query.h"
#include "DatabaseCommand_UpdateSearchIndex.h"
namespace lucene
{
@@ -60,7 +61,7 @@ public:
void beginIndexing();
void endIndexing();
void appendFields( const QMap< unsigned int, QMap< QString, QString > >& trackData );
void appendFields( const IndexData& data );
signals:
void indexReady();
@@ -82,6 +83,7 @@ private:
lucene::analysis::SimpleAnalyzer* m_analyzer;
lucene::store::Directory* m_luceneDir;
lucene::index::IndexReader* m_luceneReader;
lucene::index::IndexWriter* m_luceneWriter;
lucene::search::IndexSearcher* m_luceneSearcher;
};

View File

@@ -27,6 +27,7 @@
#include "database/DatabaseImpl.h"
#include "collection/AlbumsRequest.h"
#include "collection/ArtistsRequest.h"
#include "database/DatabaseCommand_AllAlbums.h"
#include "PlayableItem.h"
#include "utils/Logger.h"
@@ -73,7 +74,11 @@ TreeProxyModel::onRowsInserted( const QModelIndex& parent, int /* start */, int
if ( pi->artist().isNull() )
return;
Tomahawk::AlbumsRequest* cmd = m_model->collection()->requestAlbums( pi->artist() );
Tomahawk::AlbumsRequest* cmd = 0;
if ( !m_model->collection().isNull() )
cmd = m_model->collection()->requestAlbums( pi->artist() );
else
cmd = new DatabaseCommand_AllAlbums( Tomahawk::collection_ptr(), pi->artist() );
cmd->setFilter( m_filter );
@@ -115,7 +120,11 @@ TreeProxyModel::setFilter( const QString& pattern )
}
else
{
Tomahawk::ArtistsRequest* cmd = m_model->collection()->requestArtists();
Tomahawk::ArtistsRequest* cmd = 0;
if ( !m_model->collection().isNull() )
cmd = m_model->collection()->requestArtists();
else
cmd = new DatabaseCommand_AllArtists(); //for SuperCollection, TODO: replace with a proper proxy-ArtistsRequest
cmd->setFilter( pattern );
m_artistsFilterCmd = cmd;

View File

@@ -34,7 +34,9 @@
#ifndef ENABLE_HEADLESS
#include "TomahawkSettingsGui.h"
#include "breakpad/BreakPad.h"
#ifdef WITH_BREAKPAD
#include "breakpad/BreakPad.h"
#endif
#endif