From f837e9e7e5ecfb8fab7c71d81291cbb62182f8fe Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 16 Sep 2014 01:02:59 +0200 Subject: [PATCH 01/11] * Ported to lucene++. --- CMakeLists.txt | 3 + CMakeModules/FindLucene++.cmake | 2 +- src/libtomahawk/CMakeLists.txt | 5 +- src/libtomahawk/Query.h | 6 +- src/libtomahawk/TomahawkSettings.cpp | 6 +- src/libtomahawk/TomahawkSettings.h | 2 +- .../database/fuzzyindex/FuzzyIndex.cpp | 190 ++++++++---------- .../database/fuzzyindex/FuzzyIndex.h | 33 +-- 8 files changed, 110 insertions(+), 137 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 523f66ce0..29916f8b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,6 +250,9 @@ macro_log_feature(ECHONEST_FOUND "Echonest" "Qt library for communicating with T macro_optional_find_package(CLucene 0.9.23) macro_log_feature(CLucene_FOUND "CLucene" "The open-source, C++ search engine" "http://clucene.sf.net" TRUE "" "CLucene is used for indexing the collection") +macro_optional_find_package(Lucene++ 3.0.0) +macro_log_feature(LUCENEPP_FOUND "Lucene++" "The open-source, C++ search engine" "https://github.com/luceneplusplus/LucenePlusPlus/" TRUE "" "Lucene++ is used for indexing the collection") + if( NOT TOMAHAWK_QT5 ) macro_optional_find_package(QJSON 0.8.1) macro_log_feature(QJSON_FOUND "QJson" "Qt library that maps JSON data to QVariant objects" "http://qjson.sf.net" TRUE "" "libqjson is used for encoding communication between Tomahawk instances") diff --git a/CMakeModules/FindLucene++.cmake b/CMakeModules/FindLucene++.cmake index f30f9ac1a..1d7cdeabd 100644 --- a/CMakeModules/FindLucene++.cmake +++ b/CMakeModules/FindLucene++.cmake @@ -71,7 +71,7 @@ ENDIF(WIN32) SET(LUCENEPP_GOOD_VERSION TRUE) FIND_PATH(LUCENEPP_LIBRARY_DIR - NAMES liblucene++.so + NAMES liblucene++.dylib PATHS ${TRIAL_LIBRARY_PATHS} ${TRIAL_INCLUDE_PATHS} NO_DEFAULT_PATH) IF (LUCENEPP_LIBRARY_DIR) MESSAGE(STATUS "Found Lucene++ library dir: ${LUCENEPP_LIBRARY_DIR}") diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index 8224e8be2..d7e6dcd11 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -406,7 +406,7 @@ include_directories( ${QT_INCLUDE_DIR} ${QJSON_INCLUDE_DIR} ${ECHONEST_INCLUDE_DIR} - ${CLUCENE_INCLUDE_DIRS} + ${LUCENEPP_INCLUDE_DIRS} ${PHONON_INCLUDES} ${Boost_INCLUDE_DIR} @@ -525,12 +525,13 @@ TARGET_LINK_LIBRARIES( tomahawklib ${LIBPORTFWD_LIBRARIES} ${QTKEYCHAIN_LIBRARIES} + boost_system LINK_PUBLIC # External deps ${QJSON_LIBRARIES} ${TAGLIB_LIBRARIES} - ${CLUCENE_LIBRARIES} + ${LUCENEPP_LIBRARIES} ${ECHONEST_LIBRARIES} ${QT_QTSQL_LIBRARY} ${QT_QTUITOOLS_LIBRARY} diff --git a/src/libtomahawk/Query.h b/src/libtomahawk/Query.h index 2a4e4f701..9a9d02135 100644 --- a/src/libtomahawk/Query.h +++ b/src/libtomahawk/Query.h @@ -19,8 +19,8 @@ */ #pragma once -#ifndef QUERY_H -#define QUERY_H +#ifndef TOMAHAWK_QUERY_H +#define TOMAHAWK_QUERY_H #include #include @@ -154,4 +154,4 @@ private: Q_DECLARE_METATYPE( Tomahawk::query_ptr ) -#endif // QUERY_H +#endif // TOMAHAWK_QUERY_H diff --git a/src/libtomahawk/TomahawkSettings.cpp b/src/libtomahawk/TomahawkSettings.cpp index 05f848c84..631554d62 100644 --- a/src/libtomahawk/TomahawkSettings.cpp +++ b/src/libtomahawk/TomahawkSettings.cpp @@ -429,7 +429,6 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion ) setValue( "configuration", configuration ); endGroup(); - } // Add a Last.Fm account since we now moved the infoplugin into the account @@ -674,6 +673,11 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion ) } #endif //Q_OS_MAC } + else if ( oldVersion == 15 ) + { + // 0.8.0 switches to Lucene++. Force a reindex. + QTimer::singleShot( 0, this, SLOT( updateIndex() ) ); + } } diff --git a/src/libtomahawk/TomahawkSettings.h b/src/libtomahawk/TomahawkSettings.h index 491455557..3e9f800d7 100644 --- a/src/libtomahawk/TomahawkSettings.h +++ b/src/libtomahawk/TomahawkSettings.h @@ -31,7 +31,7 @@ #include #include -#define TOMAHAWK_SETTINGS_VERSION 15 +#define TOMAHAWK_SETTINGS_VERSION 16 /** * Convenience wrapper around QSettings for tomahawk-specific config diff --git a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp index f51588be4..b389207af 100644 --- a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp +++ b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp @@ -29,47 +29,36 @@ #include #include -#include -#include +#include -using namespace lucene::analysis; -using namespace lucene::analysis::standard; -using namespace lucene::document; -using namespace lucene::store; -using namespace lucene::index; -using namespace lucene::queryParser; -using namespace lucene::search; +using namespace Lucene; FuzzyIndex::FuzzyIndex( QObject* parent, const QString& filename, bool wipe ) : QObject( parent ) - , m_luceneReader( 0 ) - , m_luceneSearcher( 0 ) { m_lucenePath = TomahawkUtils::appDataDir().absoluteFilePath( filename ); - QByteArray path = m_lucenePath.toUtf8(); - const char* cPath = path.constData(); bool failed = false; - tDebug() << "Opening Lucene directory:" << path; + tDebug() << "Opening Lucene directory:" << m_lucenePath; try { - m_analyzer = _CLNEW SimpleAnalyzer(); - m_luceneDir = FSDirectory::getDirectory( cPath ); + m_analyzer = newLucene(LuceneVersion::LUCENE_CURRENT); + m_luceneDir = FSDirectory::open( m_lucenePath.toStdWString() ); } - catch ( CLuceneError& error ) + catch ( LuceneException& error ) { - tDebug() << "Caught CLucene error:" << error.what(); + tDebug() << "Caught Lucene error:" << error.what(); failed = true; } - if ( failed ) +/* if ( failed ) { tDebug() << "Initializing RAM directory instead."; m_luceneDir = _CLNEW RAMDirectory(); wipe = true; - } + }*/ if ( wipe ) wipeIndex(); @@ -78,10 +67,10 @@ FuzzyIndex::FuzzyIndex( QObject* parent, const QString& filename, bool wipe ) FuzzyIndex::~FuzzyIndex() { - delete m_luceneSearcher; +/* delete m_luceneSearcher; delete m_luceneReader; delete m_analyzer; - delete m_luceneDir; + delete m_luceneDir;*/ } @@ -113,24 +102,22 @@ FuzzyIndex::beginIndexing() try { tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Starting indexing:" << m_lucenePath; - if ( m_luceneReader != 0 ) + if ( m_luceneReader ) { tDebug( LOGVERBOSE ) << "Deleting old lucene stuff."; m_luceneSearcher->close(); m_luceneReader->close(); - delete m_luceneSearcher; - delete m_luceneReader; - m_luceneSearcher = 0; - m_luceneReader = 0; + m_luceneSearcher.reset(); + m_luceneReader.reset(); } tDebug( LOGVERBOSE ) << "Creating new index writer."; - m_luceneWriter = new IndexWriter( m_luceneDir, m_analyzer, true ); + m_luceneWriter = newLucene( m_luceneDir, m_analyzer, true, IndexWriter::MaxFieldLengthLIMITED ); } - catch( CLuceneError& error ) + catch( LuceneException& error ) { - tDebug() << "Caught CLucene error:" << error.what(); + tDebug() << "Caught Lucene error:" << error.what(); Q_ASSERT( false ); } } @@ -142,8 +129,7 @@ FuzzyIndex::endIndexing() tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Finishing indexing:" << m_lucenePath; // m_luceneWriter->optimize(); m_luceneWriter->close(); - delete m_luceneWriter; - m_luceneWriter = 0; + m_luceneWriter.reset(); m_mutex.unlock(); emit indexReady(); @@ -155,41 +141,41 @@ FuzzyIndex::appendFields( const Tomahawk::IndexData& data ) { try { - Document doc; + DocumentPtr doc = newLucene(); if ( !data.track.isEmpty() ) { - doc.add( *( _CLNEW Field( _T( "fulltext" ), Tomahawk::DatabaseImpl::sortname( QString( "%1 %2" ).arg( data.artist ).arg( data.track ) ).toStdWString().c_str(), - Field::STORE_NO | Field::INDEX_UNTOKENIZED ) ) ); + doc->add(newLucene(L"fulltext", Tomahawk::DatabaseImpl::sortname( QString( "%1 %2" ).arg( data.artist ).arg( data.track ) ).toStdWString(), + Field::STORE_NO, Field::INDEX_NOT_ANALYZED ) ); - doc.add( *( _CLNEW Field( _T( "track" ), Tomahawk::DatabaseImpl::sortname( data.track ).toStdWString().c_str(), - Field::STORE_NO | Field::INDEX_UNTOKENIZED ) ) ); + doc->add(newLucene(L"track", Tomahawk::DatabaseImpl::sortname( data.track ).toStdWString(), + Field::STORE_NO, Field::INDEX_NOT_ANALYZED ) ); - doc.add( *( _CLNEW Field( _T( "artist" ), Tomahawk::DatabaseImpl::sortname( data.artist ).toStdWString().c_str(), - Field::STORE_NO | Field::INDEX_UNTOKENIZED ) ) ); + doc->add(newLucene(L"artist", Tomahawk::DatabaseImpl::sortname( data.artist ).toStdWString(), + Field::STORE_NO, Field::INDEX_NOT_ANALYZED ) ); - doc.add( *( _CLNEW Field( _T( "artistid" ), QString::number( data.artistId ).toStdWString().c_str(), - Field::STORE_YES | Field::INDEX_NO ) ) ); + doc->add(newLucene(L"artistid", QString::number( data.artistId ).toStdWString(), + Field::STORE_YES, Field::INDEX_NO ) ); - doc.add( *( _CLNEW Field( _T( "trackid" ), QString::number( data.id ).toStdWString().c_str(), - Field::STORE_YES | Field::INDEX_NO ) ) ); + doc->add(newLucene(L"trackid", QString::number( data.id ).toStdWString(), + Field::STORE_YES, Field::INDEX_NO ) ); } else if ( !data.album.isEmpty() ) { - doc.add( *( _CLNEW Field( _T( "album" ), Tomahawk::DatabaseImpl::sortname( data.album ).toStdWString().c_str(), - Field::STORE_NO | Field::INDEX_UNTOKENIZED ) ) ); + doc->add(newLucene(L"album", Tomahawk::DatabaseImpl::sortname( data.album ).toStdWString(), + Field::STORE_NO, Field::INDEX_NOT_ANALYZED ) ); - doc.add( *( _CLNEW Field( _T( "albumid" ), QString::number( data.id ).toStdWString().c_str(), - Field::STORE_YES | Field::INDEX_NO ) ) ); + doc->add(newLucene(L"albumid", QString::number( data.id ).toStdWString(), + Field::STORE_YES, Field::INDEX_NO ) ); } else return; - m_luceneWriter->addDocument( &doc ); + m_luceneWriter->addDocument( doc ); } - catch( CLuceneError& error ) + catch( LuceneException& error ) { - tDebug() << "Caught CLucene error:" << error.what(); + tDebug() << "Caught Lucene error:" << error.what(); QTimer::singleShot( 0, this, SLOT( wipeIndex() ) ); } @@ -199,21 +185,20 @@ FuzzyIndex::appendFields( const Tomahawk::IndexData& data ) void FuzzyIndex::deleteIndex() { - if ( m_luceneReader != 0 ) + if ( m_luceneReader ) { tDebug( LOGVERBOSE ) << "Deleting old lucene stuff."; m_luceneSearcher->close(); m_luceneReader->close(); - delete m_luceneSearcher; - delete m_luceneReader; - m_luceneSearcher = 0; - m_luceneReader = 0; + m_luceneSearcher.reset(); + m_luceneReader.reset(); } TomahawkUtils::removeDirectory( m_lucenePath ); } + void FuzzyIndex::updateIndex() { @@ -238,63 +223,60 @@ FuzzyIndex::search( const Tomahawk::query_ptr& query ) { if ( !m_luceneReader ) { - if ( !IndexReader::indexExists( m_lucenePath.toStdString().c_str() ) ) + if ( !IndexReader::indexExists( m_luceneDir ) ) { tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "index didn't exist."; return resultsmap; } m_luceneReader = IndexReader::open( m_luceneDir ); - m_luceneSearcher = _CLNEW IndexSearcher( m_luceneReader ); + m_luceneSearcher = newLucene( m_luceneReader ); } float minScore; - const TCHAR** fields = 0; - MultiFieldQueryParser parser( fields, m_analyzer ); - BooleanQuery* qry = _CLNEW BooleanQuery(); + Collection fields;// = newCollection(); + MultiFieldQueryParserPtr parser = newLucene(LuceneVersion::LUCENE_CURRENT, fields, m_analyzer ); + BooleanQueryPtr qry = newLucene(); if ( query->isFullTextQuery() ) { - QString escapedQuery = QString::fromWCharArray( parser.escape( Tomahawk::DatabaseImpl::sortname( query->fullTextQuery() ).toStdWString().c_str() ) ); + QString q = Tomahawk::DatabaseImpl::sortname( query->fullTextQuery() ); - Term* term = _CLNEW Term( _T( "track" ), escapedQuery.toStdWString().c_str() ); - Query* fqry = _CLNEW FuzzyQuery( term ); - qry->add( fqry, true, BooleanClause::SHOULD ); + FuzzyQueryPtr fqry = newLucene( newLucene( L"track", q.toStdWString() ) ); + qry->add( boost::dynamic_pointer_cast( fqry ), BooleanClause::SHOULD ); - term = _CLNEW Term( _T( "artist" ), escapedQuery.toStdWString().c_str() ); - fqry = _CLNEW FuzzyQuery( term ); - qry->add( fqry, true, BooleanClause::SHOULD ); + fqry = newLucene( newLucene( L"artist", q.toStdWString() ) ); + qry->add( boost::dynamic_pointer_cast( fqry ), BooleanClause::SHOULD ); - term = _CLNEW Term( _T( "fulltext" ), escapedQuery.toStdWString().c_str() ); - fqry = _CLNEW FuzzyQuery( term ); - qry->add( fqry, true, BooleanClause::SHOULD ); + fqry = newLucene( newLucene( L"fulltext", q.toStdWString() ) ); + qry->add( boost::dynamic_pointer_cast( fqry ), BooleanClause::SHOULD ); minScore = 0.00; } else { - QString track = QString::fromWCharArray( parser.escape( Tomahawk::DatabaseImpl::sortname( query->queryTrack()->track() ).toStdWString().c_str() ) ); - QString artist = QString::fromWCharArray( parser.escape( Tomahawk::DatabaseImpl::sortname( query->queryTrack()->artist() ).toStdWString().c_str() ) ); + QString track = Tomahawk::DatabaseImpl::sortname( query->queryTrack()->track() ); + QString artist = Tomahawk::DatabaseImpl::sortname( query->queryTrack()->artist() ); // QString album = QString::fromWCharArray( parser.escape( query->album().toStdWString().c_str() ) ); - Term* term = _CLNEW Term( _T( "track" ), track.toStdWString().c_str() ); - Query* fqry = _CLNEW FuzzyQuery( term ); - qry->add( fqry, true, BooleanClause::MUST ); + FuzzyQueryPtr fqry = newLucene( newLucene( L"track", track.toStdWString() ) ); + qry->add( boost::dynamic_pointer_cast( fqry ), BooleanClause::MUST ); - term = _CLNEW Term( _T( "artist" ), artist.toStdWString().c_str() ); - fqry = _CLNEW FuzzyQuery( term ); - qry->add( fqry, true, BooleanClause::MUST ); + fqry = newLucene( newLucene( L"artist", artist.toStdWString() ) ); + qry->add( boost::dynamic_pointer_cast( fqry ), BooleanClause::MUST ); minScore = 0.00; } - Hits* hits = m_luceneSearcher->search( qry ); - for ( uint i = 0; i < hits->length(); i++ ) - { - Document* d = &hits->doc( i ); + TopScoreDocCollectorPtr collector = TopScoreDocCollector::create( 99999, false ); + m_luceneSearcher->search( qry, collector ); + Collection hits = collector->topDocs()->scoreDocs; - float score = hits->score( i ); - int id = QString::fromWCharArray( d->get( _T( "trackid" ) ) ).toInt(); + for ( uint i = 0; i < collector->getTotalHits(); i++ ) + { + DocumentPtr d = m_luceneSearcher->doc( hits[i]->doc ); + float score = hits[i]->score; + int id = QString::fromStdWString( d->get( L"trackid" ) ).toInt(); if ( score > minScore ) { @@ -303,12 +285,12 @@ FuzzyIndex::search( const Tomahawk::query_ptr& query ) } } - delete hits; - delete qry; +// delete hits; +// delete qry; } - catch( CLuceneError& error ) + catch( LuceneException& error ) { - tDebug() << "Caught CLucene error:" << error.what() << query->toString(); + tDebug() << "Caught Lucene error:" << error.what() << query->toString(); QTimer::singleShot( 0, this, SLOT( wipeIndex() ) ); } @@ -329,27 +311,29 @@ FuzzyIndex::searchAlbum( const Tomahawk::query_ptr& query ) { if ( !m_luceneReader ) { - if ( !IndexReader::indexExists( m_lucenePath.toStdString().c_str() ) ) + if ( !IndexReader::indexExists( m_luceneDir ) ) { tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "index didn't exist."; return resultsmap; } m_luceneReader = IndexReader::open( m_luceneDir ); - m_luceneSearcher = _CLNEW IndexSearcher( m_luceneReader ); + m_luceneSearcher = newLucene( m_luceneReader ); } - QueryParser parser( _T( "album" ), m_analyzer ); - QString escapedName = QString::fromWCharArray( parser.escape( Tomahawk::DatabaseImpl::sortname( query->fullTextQuery() ).toStdWString().c_str() ) ); + QueryParserPtr parser = newLucene( LuceneVersion::LUCENE_CURRENT, L"album", m_analyzer ); + QString q = Tomahawk::DatabaseImpl::sortname( query->fullTextQuery() ); - Query* qry = _CLNEW FuzzyQuery( _CLNEW Term( _T( "album" ), escapedName.toStdWString().c_str() ) ); - Hits* hits = m_luceneSearcher->search( qry ); - for ( uint i = 0; i < hits->length(); i++ ) + FuzzyQueryPtr qry = newLucene( newLucene( L"album", q.toStdWString() ) ); + TopScoreDocCollectorPtr collector = TopScoreDocCollector::create( 99999, false ); + m_luceneSearcher->search( boost::dynamic_pointer_cast( qry ), collector ); + Collection hits = collector->topDocs()->scoreDocs; + + for ( uint i = 0; i < collector->getTotalHits(); i++ ) { - Document* d = &hits->doc( i ); - - float score = hits->score( i ); - int id = QString::fromWCharArray( d->get( _T( "albumid" ) ) ).toInt(); + DocumentPtr d = m_luceneSearcher->doc( hits[i]->doc ); + float score = hits[i]->score; + int id = QString::fromStdWString( d->get( L"albumid" ) ).toInt(); if ( score > 0.30 ) { @@ -358,12 +342,12 @@ FuzzyIndex::searchAlbum( const Tomahawk::query_ptr& query ) } } - delete hits; - delete qry; +// delete hits; +// delete qry; } - catch( CLuceneError& error ) + catch( LuceneException& error ) { - tDebug() << "Caught CLucene error:" << error.what(); + tDebug() << "Caught Lucene error:" << error.what(); QTimer::singleShot( 0, this, SLOT( wipeIndex() ) ); } diff --git a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.h b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.h index e01f07b8b..e09b35c1f 100644 --- a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.h +++ b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.h @@ -25,30 +25,11 @@ #include #include +#include + #include "Query.h" #include "database/DatabaseCommand_UpdateSearchIndex.h" -namespace lucene -{ - namespace analysis - { - class SimpleAnalyzer; - } - namespace store - { - class Directory; - } - namespace index - { - class IndexReader; - class IndexWriter; - } - namespace search - { - class IndexSearcher; - } -} - class FuzzyIndex : public QObject { Q_OBJECT @@ -87,11 +68,11 @@ private: QMutex m_mutex; QString m_lucenePath; - 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; + boost::shared_ptr m_analyzer; + Lucene::IndexWriterPtr m_luceneWriter; + Lucene::IndexReaderPtr m_luceneReader; + Lucene::DirectoryPtr m_luceneDir; + Lucene::IndexSearcherPtr m_luceneSearcher; }; #endif // FUZZYINDEX_H From a38bf949ddf84f808283eb15b5f6c47a62c0460c Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 16 Sep 2014 01:37:53 +0200 Subject: [PATCH 02/11] * Switch to SimpleAnalyzer and optimize index in endIndexing() again. --- .../database/fuzzyindex/FuzzyIndex.cpp | 16 ++++++++-------- src/libtomahawk/database/fuzzyindex/FuzzyIndex.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp index b389207af..14e5e6f96 100644 --- a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp +++ b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp @@ -43,7 +43,7 @@ FuzzyIndex::FuzzyIndex( QObject* parent, const QString& filename, bool wipe ) tDebug() << "Opening Lucene directory:" << m_lucenePath; try { - m_analyzer = newLucene(LuceneVersion::LUCENE_CURRENT); + m_analyzer = newLucene(); m_luceneDir = FSDirectory::open( m_lucenePath.toStdWString() ); } catch ( LuceneException& error ) @@ -127,7 +127,7 @@ void FuzzyIndex::endIndexing() { tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Finishing indexing:" << m_lucenePath; -// m_luceneWriter->optimize(); + m_luceneWriter->optimize(); m_luceneWriter->close(); m_luceneWriter.reset(); @@ -146,13 +146,13 @@ FuzzyIndex::appendFields( const Tomahawk::IndexData& data ) if ( !data.track.isEmpty() ) { doc->add(newLucene(L"fulltext", Tomahawk::DatabaseImpl::sortname( QString( "%1 %2" ).arg( data.artist ).arg( data.track ) ).toStdWString(), - Field::STORE_NO, Field::INDEX_NOT_ANALYZED ) ); + Field::STORE_NO, Field::INDEX_ANALYZED ) ); doc->add(newLucene(L"track", Tomahawk::DatabaseImpl::sortname( data.track ).toStdWString(), - Field::STORE_NO, Field::INDEX_NOT_ANALYZED ) ); + Field::STORE_NO, Field::INDEX_ANALYZED ) ); doc->add(newLucene(L"artist", Tomahawk::DatabaseImpl::sortname( data.artist ).toStdWString(), - Field::STORE_NO, Field::INDEX_NOT_ANALYZED ) ); + Field::STORE_NO, Field::INDEX_ANALYZED ) ); doc->add(newLucene(L"artistid", QString::number( data.artistId ).toStdWString(), Field::STORE_YES, Field::INDEX_NO ) ); @@ -163,7 +163,7 @@ FuzzyIndex::appendFields( const Tomahawk::IndexData& data ) else if ( !data.album.isEmpty() ) { doc->add(newLucene(L"album", Tomahawk::DatabaseImpl::sortname( data.album ).toStdWString(), - Field::STORE_NO, Field::INDEX_NOT_ANALYZED ) ); + Field::STORE_NO, Field::INDEX_ANALYZED ) ); doc->add(newLucene(L"albumid", QString::number( data.id ).toStdWString(), Field::STORE_YES, Field::INDEX_NO ) ); @@ -268,11 +268,11 @@ FuzzyIndex::search( const Tomahawk::query_ptr& query ) minScore = 0.00; } - TopScoreDocCollectorPtr collector = TopScoreDocCollector::create( 99999, false ); + TopScoreDocCollectorPtr collector = TopScoreDocCollector::create( 50, false ); m_luceneSearcher->search( qry, collector ); Collection hits = collector->topDocs()->scoreDocs; - for ( uint i = 0; i < collector->getTotalHits(); i++ ) + for ( uint i = 0; i < collector->getTotalHits() && i < 50; i++ ) { DocumentPtr d = m_luceneSearcher->doc( hits[i]->doc ); float score = hits[i]->score; diff --git a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.h b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.h index e09b35c1f..192737f9a 100644 --- a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.h +++ b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.h @@ -68,7 +68,7 @@ private: QMutex m_mutex; QString m_lucenePath; - boost::shared_ptr m_analyzer; + boost::shared_ptr m_analyzer; Lucene::IndexWriterPtr m_luceneWriter; Lucene::IndexReaderPtr m_luceneReader; Lucene::DirectoryPtr m_luceneDir; From f554ba7f17604358d98a83f3b0f3ce61c9e391bd Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 16 Sep 2014 01:49:28 +0200 Subject: [PATCH 03/11] * Removed CLucene check. --- CMakeLists.txt | 3 - CMakeModules/FindCLucene.cmake | 132 ------------------------- CMakeModules/FindCLuceneUnstable.cmake | 37 ------- 3 files changed, 172 deletions(-) delete mode 100644 CMakeModules/FindCLucene.cmake delete mode 100644 CMakeModules/FindCLuceneUnstable.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 29916f8b3..4957d5882 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,9 +247,6 @@ endif() macro_optional_find_package(Echonest 2.2.0) macro_log_feature(ECHONEST_FOUND "Echonest" "Qt library for communicating with The Echo Nest" "http://projects.kde.org/libechonest" TRUE "" "libechonest 2.2.0 is needed for dynamic playlists and the infosystem") -macro_optional_find_package(CLucene 0.9.23) -macro_log_feature(CLucene_FOUND "CLucene" "The open-source, C++ search engine" "http://clucene.sf.net" TRUE "" "CLucene is used for indexing the collection") - macro_optional_find_package(Lucene++ 3.0.0) macro_log_feature(LUCENEPP_FOUND "Lucene++" "The open-source, C++ search engine" "https://github.com/luceneplusplus/LucenePlusPlus/" TRUE "" "Lucene++ is used for indexing the collection") diff --git a/CMakeModules/FindCLucene.cmake b/CMakeModules/FindCLucene.cmake deleted file mode 100644 index 873693d8c..000000000 --- a/CMakeModules/FindCLucene.cmake +++ /dev/null @@ -1,132 +0,0 @@ -# -# This module looks for clucene (http://clucene.sf.net) support -# It will define the following values -# -# CLUCENE_INCLUDE_DIRS = CLUCENE_INCLUDE_DIR + CLUCENE_LIBRARY_DIR -# CLUCENE_INCLUDE_DIR = where CLucene/StdHeader.h can be found -# CLUCENE_LIBRARY_DIR = where CLucene/clucene-config.h can be found -# CLUCENE_LIBRARIES = the libraries to link against CLucene -# CLUCENE_VERSION = The CLucene version string -# CLucene_FOUND = set to 1 if clucene is found -# - -INCLUDE(CheckSymbolExists) -INCLUDE(FindLibraryWithDebug) - -# try to locate a patched unstable version (for comp's sake *sigh*) first -FIND_PACKAGE(CLuceneUnstable QUIET) -IF(CLUCENEUNSTABLE_FOUND) - SET(CLucene_FOUND TRUE) - SET(CLUCENE_INCLUDE_DIR ${CLUCENE_UNSTABLE_INCLUDE_DIRS}) - SET(CLUCENE_INCLUDE_DIRS ${CLUCENE_INCLUDE_DIR}) - SET(CLUCENE_LIBRARIES ${CLUCENE_UNSTABLE_LIBS}) - - #MESSAGE(FATAL_ERROR NARF) -ELSE(CLUCENEUNSTABLE_FOUND) -IF(CLucene_FIND_VERSION) - SET(CLUCENE_MIN_VERSION ${CLucene_FIND_VERSION}) -ELSEIF() - SET(CLUCENE_MIN_VERSION "0.9.23") -ENDIF(CLucene_FIND_VERSION) - -IF(EXISTS ${PROJECT_CMAKE}/CLuceneConfig.cmake) - INCLUDE(${PROJECT_CMAKE}/CLuceneConfig.cmake) -ENDIF(EXISTS ${PROJECT_CMAKE}/CLuceneConfig.cmake) - -SET(TRIAL_LIBRARY_PATHS - $ENV{CLUCENE_HOME}/lib${LIB_SUFFIX} - ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} - /usr/local/lib${LIB_SUFFIX} - /usr/lib${LIB_SUFFIX} - /sw/lib${LIB_SUFFIX} - /usr/pkg/lib${LIB_SUFFIX} - /usr/lib64 - /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} - ) -SET(TRIAL_INCLUDE_PATHS - $ENV{CLUCENE_HOME}/include - ${CMAKE_INSTALL_PREFIX}/include - /usr/local/include - /usr/include - /sw/include - /usr/pkg/include - ) -FIND_LIBRARY_WITH_DEBUG(CLUCENE_CORE_LIBRARY - WIN32_DEBUG_POSTFIX d - NAMES clucene-core - PATHS ${TRIAL_LIBRARY_PATHS}) -IF (CLUCENE_CORE_LIBRARY) - MESSAGE(STATUS "Found CLucene core library: ${CLUCENE_CORE_LIBRARY}") -ENDIF (CLUCENE_CORE_LIBRARY) -FIND_LIBRARY_WITH_DEBUG(CLUCENE_SHARED_LIBRARY - WIN32_DEBUG_POSTFIX d - NAMES clucene-shared - PATHS ${TRIAL_LIBRARY_PATHS}) -IF (CLUCENE_SHARED_LIBRARY) - MESSAGE(STATUS "Found CLucene shared library: ${CLUCENE_SHARED_LIBRARY}") -ENDIF (CLUCENE_SHARED_LIBRARY) - -IF(CLUCENE_CORE_LIBRARY AND CLUCENE_SHARED_LIBRARY) - SET(CLUCENE_LIBRARIES ${CLUCENE_CORE_LIBRARY} ${CLUCENE_SHARED_LIBRARY}) -ENDIF(CLUCENE_CORE_LIBRARY AND CLUCENE_SHARED_LIBRARY) - -FIND_PATH(CLUCENE_INCLUDE_DIR - NAMES CLucene.h - PATHS ${TRIAL_INCLUDE_PATHS}) - -IF (CLUCENE_INCLUDE_DIR) - MESSAGE(STATUS "Found CLucene include dir: ${CLUCENE_INCLUDE_DIR}") -ENDIF (CLUCENE_INCLUDE_DIR) - -IF(WIN32) - SET(TRIAL_LIBRARY_PATHS ${CLUCENE_INCLUDE_DIR}) -ENDIF(WIN32) - -SET(CLUCENE_GOOD_VERSION TRUE) - -FIND_PATH(CLUCENE_LIBRARY_DIR - NAMES CLuceneConfig.cmake/CLuceneConfig.cmake CLucene/CLuceneConfig.cmake - PATHS ${TRIAL_LIBRARY_PATHS} ${TRIAL_INCLUDE_PATHS} NO_DEFAULT_PATH) -IF (CLUCENE_LIBRARY_DIR) - MESSAGE(STATUS "Found CLucene library dir: ${CLUCENE_LIBRARY_DIR}") - # include CLuceneConfig/CLuceneConfig.cmake - IF(EXISTS ${CLUCENE_LIBRARY_DIR}/CLuceneConfig.cmake/CLuceneConfig.cmake) - INCLUDE(${CLUCENE_LIBRARY_DIR}/CLuceneConfig.cmake/CLuceneConfig.cmake) - ENDIF(EXISTS ${CLUCENE_LIBRARY_DIR}/CLuceneConfig.cmake/CLuceneConfig.cmake) - # include CLucene/CLuceneConfig.cmake - IF(EXISTS ${CLUCENE_LIBRARY_DIR}/CLucene/CLuceneConfig.cmake) - INCLUDE(${CLUCENE_LIBRARY_DIR}/CLucene/CLuceneConfig.cmake) - ENDIF(EXISTS ${CLUCENE_LIBRARY_DIR}/CLucene/CLuceneConfig.cmake) - IF (CLUCENE_VERSION STRLESS "${CLUCENE_MIN_VERSION}") - MESSAGE(ERROR " CLucene version ${CLUCENE_VERSION} is less than the required minimum ${CLUCENE_MIN_VERSION}") - SET(CLUCENE_GOOD_VERSION FALSE) - ENDIF (CLUCENE_VERSION STRLESS "${CLUCENE_MIN_VERSION}") - IF (CLUCENE_VERSION STREQUAL "0.9.17") - MESSAGE(ERROR "CLucene version 0.9.17 is not supported.") - SET(CLUCENE_GOOD_VERSION FALSE) - ENDIF (CLUCENE_VERSION STREQUAL "0.9.17") -ENDIF (CLUCENE_LIBRARY_DIR) - -IF(CLUCENE_INCLUDE_DIR AND CLUCENE_LIBRARIES AND CLUCENE_LIBRARY_DIR AND CLUCENE_GOOD_VERSION) - SET(CLucene_FOUND TRUE) - SET(CLUCENE_INCLUDE_DIRS ${CLUCENE_LIBRARY_DIR} ${CLUCENE_INCLUDE_DIR}) -ENDIF(CLUCENE_INCLUDE_DIR AND CLUCENE_LIBRARIES AND CLUCENE_LIBRARY_DIR AND CLUCENE_GOOD_VERSION) - -ENDIF(CLUCENEUNSTABLE_FOUND) - -IF(CLucene_FOUND) - IF(NOT CLucene_FIND_QUIETLY) - MESSAGE(STATUS "Found CLucene: ${CLUCENE_LIBRARIES} version ${CLUCENE_VERSION}") - ENDIF(NOT CLucene_FIND_QUIETLY) -ELSE(CLucene_FOUND) - IF(CLucene_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find CLucene.") - ENDIF(CLucene_FIND_REQUIRED) -ENDIF(CLucene_FOUND) - -MARK_AS_ADVANCED( - CLUCENE_INCLUDE_DIRS - CLUCENE_INCLUDE_DIR - CLUCENE_LIBRARY_DIR - CLUCENE_LIBRARIES - ) diff --git a/CMakeModules/FindCLuceneUnstable.cmake b/CMakeModules/FindCLuceneUnstable.cmake deleted file mode 100644 index 62643aa86..000000000 --- a/CMakeModules/FindCLuceneUnstable.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# - Try to find clucene-unstable -# This is a workaround for distros, that want to ship a recent enough clucene but don't want to replace the old version -# -# CLUCENEUNSTABLE_FOUND - system has clucene-unstable -# CLUCENE_UNSTABLE_INCLUDE_DIR - the clucene-unstable include directories -# CLUCENE_UNSTABLE_LIBS - link these to use clucene-unstable -# -# (c) Dominik Schmidt -# - -# Include dir -find_path(CLUCENE_UNSTABLE_INCLUDE_DIR - NAMES CLucene.h - PATH_SUFFIXES clucene-unstable - PATHS ${KDE4_INCLUDE_DIR} -) - -# Finally the library itself -find_library(CLUCENE_UNSTABLE_SHARED_LIB - NAMES clucene-unstable-shared - PATHS ${KDE4_LIB_DIR} -) - -find_library(CLUCENE_UNSTABLE_CORE_LIB - NAMES clucene-unstable-core - PATHS ${KDE4_LIB_DIR} -) - - -SET( CLUCENE_UNSTABLE_LIBS ${CLUCENE_UNSTABLE_SHARED_LIB} ${CLUCENE_UNSTABLE_CORE_LIB} ) -SET( CLUCENE_UNSTABLE_INCLUDE_DIRS ${CLUCENE_UNSTABLE_INCLUDE_DIR}) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(CLuceneUnstable DEFAULT_MSG CLUCENE_UNSTABLE_LIBS CLUCENE_UNSTABLE_INCLUDE_DIRS) - - -MARK_AS_ADVANCED(CLUCENE_UNSTABLE_LIBS CLUCENE_UNSTABLE_INCLUDE_DIRS) - From 995da20b5d1aec9dc5feab0e0b9296e9faccefc9 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 16 Sep 2014 05:12:51 +0200 Subject: [PATCH 04/11] * Find lucenepp lib correctly on all platforms. --- CMakeModules/FindLucene++.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeModules/FindLucene++.cmake b/CMakeModules/FindLucene++.cmake index 1d7cdeabd..e1f2f3793 100644 --- a/CMakeModules/FindLucene++.cmake +++ b/CMakeModules/FindLucene++.cmake @@ -71,7 +71,7 @@ ENDIF(WIN32) SET(LUCENEPP_GOOD_VERSION TRUE) FIND_PATH(LUCENEPP_LIBRARY_DIR - NAMES liblucene++.dylib + NAMES liblucene++.dylib liblucene++.so liblucene++.dll PATHS ${TRIAL_LIBRARY_PATHS} ${TRIAL_INCLUDE_PATHS} NO_DEFAULT_PATH) IF (LUCENEPP_LIBRARY_DIR) MESSAGE(STATUS "Found Lucene++ library dir: ${LUCENEPP_LIBRARY_DIR}") From 265b6b0fc153809a0fee57cc7582b5c1fa9fb07d Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 16 Sep 2014 05:22:17 +0200 Subject: [PATCH 05/11] * Delete index when initializing lucene should fail. --- src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp | 10 ++++------ src/libtomahawk/database/fuzzyindex/FuzzyIndex.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp index 14e5e6f96..2044102a5 100644 --- a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp +++ b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2013, Christian Muehlhaeuser + * Copyright 2010-2014, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,13 +52,11 @@ FuzzyIndex::FuzzyIndex( QObject* parent, const QString& filename, bool wipe ) failed = true; } -/* if ( failed ) + if ( failed ) { - tDebug() << "Initializing RAM directory instead."; - - m_luceneDir = _CLNEW RAMDirectory(); + deleteIndex(); wipe = true; - }*/ + } if ( wipe ) wipeIndex(); diff --git a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.h b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.h index 192737f9a..a5bae0685 100644 --- a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.h +++ b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.h @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2013, Christian Muehlhaeuser + * Copyright 2010-2014, Christian Muehlhaeuser * * Tomahawk is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From cc3ce671b93475f51b3f85f3aec8f79c534b7109 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 16 Sep 2014 05:28:11 +0200 Subject: [PATCH 06/11] * Remove old CLucene references. --- README.md | 2 +- src/libtomahawk/resolvers/JSResolverHelper.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b3f57b482..f5bdc854e 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Required dependencies: * SQLite 3.6.22 - http://www.sqlite.org/ * TagLib 1.8 - 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 +* Lucene++ 3.0.6 - https://github.com/luceneplusplus/LucenePlusPlus/ * libechonest 2.2.0 - 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/ diff --git a/src/libtomahawk/resolvers/JSResolverHelper.h b/src/libtomahawk/resolvers/JSResolverHelper.h index f547f4c3e..9d6246a7f 100644 --- a/src/libtomahawk/resolvers/JSResolverHelper.h +++ b/src/libtomahawk/resolvers/JSResolverHelper.h @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2014, Christian Muehlhaeuser * Copyright 2010-2011, Leo Franchi * Copyright 2013, Teo Mrnjavac * Copyright 2013, Uwe L. Korn @@ -95,7 +95,7 @@ public: const QVariantMap& options ); /** - * Clucene indices for JS resolvers + * Lucene++ indices for JS resolvers **/ Q_INVOKABLE bool hasFuzzyIndex(); From 997f05b9c56f6216b68a11bc3f20370382b643f7 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 16 Sep 2014 05:29:00 +0200 Subject: [PATCH 07/11] * Updated NSIS template to package Lucene++. --- CMakeModules/NSIS.template.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeModules/NSIS.template.in b/CMakeModules/NSIS.template.in index 50b4918ca..2a45477ec 100644 --- a/CMakeModules/NSIS.template.in +++ b/CMakeModules/NSIS.template.in @@ -394,8 +394,8 @@ Section "Tomahawk Player" SEC_TOMAHAWK_PLAYER File "${MING_BIN}\libssl-10.dll" File "${MING_BIN}\libcrypto-10.dll" - File "${MING_BIN}\libclucene-core.dll" - File "${MING_BIN}\libclucene-shared.dll" + File "${MING_BIN}\liblucene++.dll" + File "${MING_BIN}\liblucene++-contrib.dll" File "${MING_BIN}\libqtsparkle.dll" File "${MING_BIN}\libattica.dll" From f6a21655249d68c6a07bf4032b1d2fc406120eda Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 16 Sep 2014 05:31:56 +0200 Subject: [PATCH 08/11] * Remove commented out code. --- .../database/fuzzyindex/FuzzyIndex.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp index 2044102a5..a03581e47 100644 --- a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp +++ b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp @@ -65,10 +65,7 @@ FuzzyIndex::FuzzyIndex( QObject* parent, const QString& filename, bool wipe ) FuzzyIndex::~FuzzyIndex() { -/* delete m_luceneSearcher; - delete m_luceneReader; - delete m_analyzer; - delete m_luceneDir;*/ + tLog( LOGVERBOSE ) << Q_FUNC_INFO; } @@ -200,7 +197,7 @@ FuzzyIndex::deleteIndex() void FuzzyIndex::updateIndex() { - // NO-OP + // virtual NO-OP } @@ -232,7 +229,7 @@ FuzzyIndex::search( const Tomahawk::query_ptr& query ) } float minScore; - Collection fields;// = newCollection(); + Collection fields; // = newCollection(); MultiFieldQueryParserPtr parser = newLucene(LuceneVersion::LUCENE_CURRENT, fields, m_analyzer ); BooleanQueryPtr qry = newLucene(); @@ -255,7 +252,7 @@ FuzzyIndex::search( const Tomahawk::query_ptr& query ) { QString track = Tomahawk::DatabaseImpl::sortname( query->queryTrack()->track() ); QString artist = Tomahawk::DatabaseImpl::sortname( query->queryTrack()->artist() ); -// QString album = QString::fromWCharArray( parser.escape( query->album().toStdWString().c_str() ) ); + //QString album = Tomahawk::DatabaseImpl::sortname( query->queryTrack()->album() ); FuzzyQueryPtr fqry = newLucene( newLucene( L"track", track.toStdWString() ) ); qry->add( boost::dynamic_pointer_cast( fqry ), BooleanClause::MUST ); @@ -282,9 +279,6 @@ FuzzyIndex::search( const Tomahawk::query_ptr& query ) // tDebug() << "Index hit:" << id << score << QString::fromWCharArray( ((Query*)qry)->toString() ); } } - -// delete hits; -// delete qry; } catch( LuceneException& error ) { @@ -339,9 +333,6 @@ FuzzyIndex::searchAlbum( const Tomahawk::query_ptr& query ) // tDebug() << "Index hit:" << id << score; } } - -// delete hits; -// delete qry; } catch( LuceneException& error ) { From efae2f004adfc6fe5154edbd2e18bc4468d758e9 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 16 Sep 2014 05:32:27 +0200 Subject: [PATCH 09/11] * Fixed compiler warnings in FuzzyIndex. --- src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp index a03581e47..344b7c288 100644 --- a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp +++ b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp @@ -267,7 +267,7 @@ FuzzyIndex::search( const Tomahawk::query_ptr& query ) m_luceneSearcher->search( qry, collector ); Collection hits = collector->topDocs()->scoreDocs; - for ( uint i = 0; i < collector->getTotalHits() && i < 50; i++ ) + for ( int i = 0; i < collector->getTotalHits() && i < 50; i++ ) { DocumentPtr d = m_luceneSearcher->doc( hits[i]->doc ); float score = hits[i]->score; @@ -321,7 +321,7 @@ FuzzyIndex::searchAlbum( const Tomahawk::query_ptr& query ) m_luceneSearcher->search( boost::dynamic_pointer_cast( qry ), collector ); Collection hits = collector->topDocs()->scoreDocs; - for ( uint i = 0; i < collector->getTotalHits(); i++ ) + for ( int i = 0; i < collector->getTotalHits(); i++ ) { DocumentPtr d = m_luceneSearcher->doc( hits[i]->doc ); float score = hits[i]->score; From 8a25a551c52621b5ccb800a9fd94970b722795ff Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 16 Sep 2014 05:33:18 +0200 Subject: [PATCH 10/11] * Style fixes in FuzzyIndex. --- .../database/fuzzyindex/FuzzyIndex.cpp | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp index 344b7c288..0c8355fbb 100644 --- a/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp +++ b/src/libtomahawk/database/fuzzyindex/FuzzyIndex.cpp @@ -140,28 +140,28 @@ FuzzyIndex::appendFields( const Tomahawk::IndexData& data ) if ( !data.track.isEmpty() ) { - doc->add(newLucene(L"fulltext", Tomahawk::DatabaseImpl::sortname( QString( "%1 %2" ).arg( data.artist ).arg( data.track ) ).toStdWString(), - Field::STORE_NO, Field::INDEX_ANALYZED ) ); + doc->add(newLucene( L"fulltext", Tomahawk::DatabaseImpl::sortname( QString( "%1 %2" ).arg( data.artist ).arg( data.track ) ).toStdWString(), + Field::STORE_NO, Field::INDEX_ANALYZED ) ); - doc->add(newLucene(L"track", Tomahawk::DatabaseImpl::sortname( data.track ).toStdWString(), - Field::STORE_NO, Field::INDEX_ANALYZED ) ); + doc->add(newLucene( L"track", Tomahawk::DatabaseImpl::sortname( data.track ).toStdWString(), + Field::STORE_NO, Field::INDEX_ANALYZED ) ); - doc->add(newLucene(L"artist", Tomahawk::DatabaseImpl::sortname( data.artist ).toStdWString(), - Field::STORE_NO, Field::INDEX_ANALYZED ) ); + doc->add(newLucene( L"artist", Tomahawk::DatabaseImpl::sortname( data.artist ).toStdWString(), + Field::STORE_NO, Field::INDEX_ANALYZED ) ); - doc->add(newLucene(L"artistid", QString::number( data.artistId ).toStdWString(), - Field::STORE_YES, Field::INDEX_NO ) ); + doc->add(newLucene( L"artistid", QString::number( data.artistId ).toStdWString(), + Field::STORE_YES, Field::INDEX_NO ) ); - doc->add(newLucene(L"trackid", QString::number( data.id ).toStdWString(), - Field::STORE_YES, Field::INDEX_NO ) ); + doc->add(newLucene( L"trackid", QString::number( data.id ).toStdWString(), + Field::STORE_YES, Field::INDEX_NO ) ); } else if ( !data.album.isEmpty() ) { - doc->add(newLucene(L"album", Tomahawk::DatabaseImpl::sortname( data.album ).toStdWString(), - Field::STORE_NO, Field::INDEX_ANALYZED ) ); + doc->add(newLucene( L"album", Tomahawk::DatabaseImpl::sortname( data.album ).toStdWString(), + Field::STORE_NO, Field::INDEX_ANALYZED ) ); - doc->add(newLucene(L"albumid", QString::number( data.id ).toStdWString(), - Field::STORE_YES, Field::INDEX_NO ) ); + doc->add(newLucene( L"albumid", QString::number( data.id ).toStdWString(), + Field::STORE_YES, Field::INDEX_NO ) ); } else return; @@ -230,7 +230,7 @@ FuzzyIndex::search( const Tomahawk::query_ptr& query ) float minScore; Collection fields; // = newCollection(); - MultiFieldQueryParserPtr parser = newLucene(LuceneVersion::LUCENE_CURRENT, fields, m_analyzer ); + MultiFieldQueryParserPtr parser = newLucene( LuceneVersion::LUCENE_CURRENT, fields, m_analyzer ); BooleanQueryPtr qry = newLucene(); if ( query->isFullTextQuery() ) From 4a5612aea7f4c306cf933834bd2f389d2007d516 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 16 Sep 2014 05:49:12 +0200 Subject: [PATCH 11/11] * boost_system is not libtomahawk's direct dependency. --- CMakeModules/FindLucene++.cmake | 2 +- src/libtomahawk/CMakeLists.txt | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeModules/FindLucene++.cmake b/CMakeModules/FindLucene++.cmake index e1f2f3793..4a214b3ac 100644 --- a/CMakeModules/FindLucene++.cmake +++ b/CMakeModules/FindLucene++.cmake @@ -53,7 +53,7 @@ IF (LUCENEPP_SHARED_LIBRARY) ENDIF (LUCENEPP_SHARED_LIBRARY) IF(LUCENEPP_CORE_LIBRARY AND LUCENEPP_SHARED_LIBRARY) - SET(LUCENEPP_LIBRARIES ${LUCENEPP_CORE_LIBRARY} ${LUCENEPP_SHARED_LIBRARY}) + SET(LUCENEPP_LIBRARIES ${LUCENEPP_CORE_LIBRARY} ${LUCENEPP_SHARED_LIBRARY} boost_system) ENDIF(LUCENEPP_CORE_LIBRARY AND LUCENEPP_SHARED_LIBRARY) FIND_PATH(LUCENEPP_INCLUDE_DIR diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index d7e6dcd11..8477123c4 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -525,8 +525,6 @@ TARGET_LINK_LIBRARIES( tomahawklib ${LIBPORTFWD_LIBRARIES} ${QTKEYCHAIN_LIBRARIES} - boost_system - LINK_PUBLIC # External deps ${QJSON_LIBRARIES}