Commit 06142566 authored by Christian Mollekopf's avatar Christian Mollekopf
Browse files

Removed state file for the itemqueue.

Now that we requery the status on every startup anyways there is no point in keeping that potential performance hog.
parent 450a036a
......@@ -30,7 +30,6 @@
#include <KIcon>
#include <KNotification>
#include <KIconLoader>
#include <KStandardDirs>
#include <QDateTime>
......@@ -39,7 +38,7 @@
using namespace Akonadi;
FeederQueue::FeederQueue( bool persistQueue, QObject* parent )
FeederQueue::FeederQueue( QObject* parent )
: QObject( parent ),
mTotalAmount( 0 ),
mProcessedAmount( 0 ),
......@@ -50,10 +49,6 @@ FeederQueue::FeederQueue( bool persistQueue, QObject* parent )
highPrioQueue(1, 100, this),
emailItemQueue(1, 100, this)
{
if (persistQueue) {
lowPrioQueue.setSaveFile(KStandardDirs::locateLocal("data", QLatin1String("akonadi_nepomuk_feeder/lowPrioQueue"), true));
highPrioQueue.setSaveFile(KStandardDirs::locateLocal("data", QLatin1String("akonadi_nepomuk_feeder/highPrioQueue"), true));
}
mProcessItemQueueTimer.setInterval( 0 );
mProcessItemQueueTimer.setSingleShot( true );
connect( &mProcessItemQueueTimer, SIGNAL(timeout()), SLOT(processItemQueue()) );
......
......@@ -52,7 +52,7 @@ class FeederQueue: public QObject
{
Q_OBJECT
public:
explicit FeederQueue( bool persistQueue = true, QObject* parent = 0 );
explicit FeederQueue( QObject* parent = 0 );
virtual ~FeederQueue();
///add the collection to the queue, all items of it will be fetched and indexed
......
......@@ -18,7 +18,6 @@
#include "itemqueue.h"
#include "nepomukhelpers.h"
#include <QTimer>
#include <QFile>
#include <KDebug>
#include <Akonadi/ItemFetchJob>
#include <Akonadi/ItemFetchScope>
......@@ -53,63 +52,15 @@ ItemQueue::~ItemQueue()
}
void ItemQueue::setSaveFile(const QString& saveFile)
{
mSaveFile = saveFile;
loadState();
}
void ItemQueue::saveState()
{
if (mSaveFile.isEmpty())
return;
QFile file( mSaveFile );
if ( !file.open( QIODevice::WriteOnly ) ) {
qWarning() << "could not save item pipeline to file " << file.fileName();
return;
}
QDataStream stream( &file );
stream.setVersion( QDataStream::Qt_4_7 );
stream << (qulonglong)(mItemPipelineBackup.size());
for ( int i = 0; i < mItemPipelineBackup.size(); ++i ) {
stream << mItemPipelineBackup.at(i);
}
}
void ItemQueue::loadState()
{
mItemPipeline.clear();
QFile file( mSaveFile );
if ( !file.open( QIODevice::ReadOnly ) )
return;
QDataStream stream( &file );
stream.setVersion( QDataStream::Qt_4_7 );
qulonglong size;
Akonadi::Item::Id id;
stream >> size;
mItemPipeline.reserve(size);
for ( qulonglong i = 0; i < size && !stream.atEnd(); ++i ) {
stream >> id;
mItemPipelineBackup.enqueue(id);
}
mItemPipeline = mItemPipelineBackup;
}
void ItemQueue::addToQueue(Akonadi::Entity::Id id)
{
mItemPipeline.enqueue( id );
mItemPipelineBackup.enqueue( id );
}
void ItemQueue::addItem(const Akonadi::Item &item)
{
//kDebug() << "pipline size: " << mItemPipeline.size();
addToQueue(item.id());
saveState();
}
void ItemQueue::addItems(const Akonadi::Item::List &list )
......@@ -117,7 +68,6 @@ void ItemQueue::addItems(const Akonadi::Item::List &list )
foreach ( const Akonadi::Item &item, list ) {
addToQueue( item.id() );
}
saveState();
}
bool ItemQueue::processItem()
......@@ -171,9 +121,6 @@ void ItemQueue::fetchJobResult(KJob* job)
foreach(const Akonadi::Item &it, mItemFetchList) {
mTempFetchList.removeOne(it.id());
}
foreach(Akonadi::Item::Id id, mTempFetchList) {
mItemPipelineBackup.removeOne(id);
}
}
mTempFetchList.clear();
......@@ -190,7 +137,6 @@ bool ItemQueue::processBatch()
//kDebug() << item.id();
if ( !item.hasPayload() ) { //can happen due to deserialization error or with items that actually don't have a local payload
kWarning() << "failed to fetch item or item without payload: " << item.id();
mItemPipelineBackup.removeOne(item.id());
continue;
}
Q_ASSERT( item.hasPayload() );
......@@ -211,10 +157,6 @@ bool ItemQueue::processBatch()
job->setProperty("graph", QVariant::fromValue(mResourceGraph));
connect( job, SIGNAL(finished(KJob*)), this, SLOT(removeDataResult(KJob*)) );
mRunningJobs++;
foreach (Akonadi::Item::Id id, mBatch) {
mItemPipelineBackup.removeOne(id);
}
saveState();
mBatch.clear();
mResourceGraph.clear();
return false;
......@@ -276,10 +218,6 @@ void ItemQueue::continueProcessing()
}
if ( mItemPipeline.isEmpty() && mFetchedItemList.isEmpty() ) {
kDebug() << "indexing completed";
if (!mItemPipelineBackup.isEmpty()) {
kWarning() << mItemPipelineBackup;
}
Q_ASSERT(mItemPipelineBackup.isEmpty());
emit finished();
}
}
......
......@@ -48,8 +48,6 @@ public:
/** the delay between two batches */
void setProcessingDelay(int ms);
void setSaveFile(const QString &saveFile);
signals:
/** all items processed */
void finished();
......@@ -64,12 +62,8 @@ private slots:
private:
bool processBatch();
void saveState();
void loadState();
void addToQueue(Akonadi::Entity::Id);
QString mSaveFile;
QQueue<Akonadi::Item::Id> mItemPipelineBackup;
QQueue<Akonadi::Item::Id> mItemPipeline;
Nepomuk2::SimpleResourceGraph mResourceGraph;
QList<Akonadi::Item::Id> mBatch;
......
......@@ -102,7 +102,6 @@ NepomukFeederAgent::NepomukFeederAgent(const QString& id) :
mShouldRecordNotifications( true ),
mLostChanges( false ),
mInitialIndexingDisabled( false ),
mQueue( true ),
mItemBatchCounter( 0 ),
mTotalItems(0),
mIndexedItems(0)
......
......@@ -71,7 +71,7 @@ int main(int argc, char *argv[])
KJob *job = Nepomuk2::removeDataByApplication( QList<QUrl>() << Akonadi::Item( id ).url().url(), Nepomuk2::RemoveSubResoures, KGlobal::mainComponent() );
QObject::connect( job, SIGNAL(finished(KJob*)), tester, SLOT(removalComplete(KJob*)) );
} else if ( app.arguments().at( 1 ) == QString::fromLatin1( "collection" ) ) {
FeederQueue *feederq = new FeederQueue( false, &app );
FeederQueue *feederq = new FeederQueue( &app );
kDebug() << "indexing collection: " << id;
feederq->setReindexing( true );
feederq->setOnline( true );
......
......@@ -37,7 +37,7 @@
NepomukPIMindexerUtility::NepomukPIMindexerUtility()
: KXmlGuiWindow(),
mFeederQueue(new FeederQueue(false, this))
mFeederQueue(new FeederQueue(this))
{
KGlobal::locale()->insertCatalog( "akonadi_nepomuk_feeder" );
// tell the KXmlGuiWindow that this is indeed the main widget
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment