[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/runtime/nepomuk/strigibackend
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2010-03-18 11:48:04
Message-ID: 20100318114804.6EDB3AC855 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1104730 by trueg:

We now do most of the work in the strigi service directly. Thus, the index reader is \
not used at all anymore.


 M  +10 -101   nepomukindexreader.cpp  
 M  +3 -6      nepomukindexreader.h  
 M  +18 -17    nepomukindexwriter.cpp  
 M  +3 -3      nepomukindexwriter.h  


--- trunk/KDE/kdebase/runtime/nepomuk/strigibackend/nepomukindexreader.cpp \
#1104729:1104730 @@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org>
+  Copyright (C) 2007-2010 Sebastian Trueg <trueg@kde.org>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
@@ -18,27 +18,7 @@
 */
 
 #include "nepomukindexreader.h"
-#include <strigi/query.h>
-#include <strigi/queryparser.h>
-#include <strigi/fieldtypes.h>
-#include "util.h"
-#include "nie.h"
 
-#include <Soprano/Soprano>
-#include <Soprano/Vocabulary/XMLSchema>
-
-#include <map>
-#include <utility>
-#include <sstream>
-
-#include <QtCore/QThread>
-#include <QtCore/QDateTime>
-#include <QtCore/QString>
-#include <QtCore/QLatin1String>
-#include <QtCore/QFile>
-
-#include <KDebug>
-
 using namespace Soprano;
 using namespace std;
 
@@ -60,100 +40,29 @@
 
 Strigi::NepomukIndexReader::~NepomukIndexReader()
 {
-    kDebug();
     delete d;
 }
 
 
-// an empty parent url is perfectly valid as strigi stores a parent url for \
                everything
-void Strigi::NepomukIndexReader::getChildren( const std::string& parent,
-                                              std::map<std::string, time_t>& \
children ) +// not implemented
+void Strigi::NepomukIndexReader::getChildren( const std::string&,
+                                              std::map<std::string, time_t>& )
 {
-    //
-    // We are compatible with old Xesam data where the url was encoded as a string \
                instead of a url,
-    // thus the weird query
-    //
-    QString query = QString( "select distinct ?path ?mtime where { "
-                             "{ ?r <http://strigi.sf.net/ontologies/0.9#parentUrl> \
                %1 . } "
-                             "UNION "
-                             "{ ?r <http://strigi.sf.net/ontologies/0.9#parentUrl> \
                %2 . } "
-                             "UNION "
-                             "{ ?r %3 ?parent . ?parent %7 %2 . } . "
-                             "{ ?r %4 ?mtime . } UNION { ?r %5 ?mtime . } "
-                             "{ ?r %6 ?path . } UNION { ?r %7 ?path . } "
-                             "}")
-                    .arg( Node::literalToN3( QString::fromUtf8( parent.c_str() ) ),
-                          Node::resourceToN3( QUrl::fromLocalFile( \
                QFile::decodeName( parent.c_str() ) ) ),
-                          Node::resourceToN3( Nepomuk::Vocabulary::NIE::isPartOf() \
                ),
-                          Node::resourceToN3( Vocabulary::Xesam::sourceModified() ),
-                          Node::resourceToN3( \
                Nepomuk::Vocabulary::NIE::lastModified() ),
-                          Node::resourceToN3( Vocabulary::Xesam::url() ),
-                          Node::resourceToN3( Nepomuk::Vocabulary::NIE::url() ) );
-
-//    kDebug() << "running getChildren query:" << query;
-
-    QueryResultIterator result = d->repository->executeQuery( query, \
                Soprano::Query::QueryLanguageSparql );
-
-    while ( result.next() ) {
-        Node pathNode = result.binding( "path" );
-        Node mTimeNode = result.binding( "mtime" );
-
-        // be backwards compatible in case there are paths left encoded as literals
-        std::string path;
-        if ( pathNode.isLiteral() )
-            path = pathNode.toString().toUtf8().data();
-        else
-            path = QFile::encodeName( pathNode.uri().toLocalFile() ).data();
-
-        // Sadly in Xesam sourceModified is not typed as DateTime but defaults to an \
                int :( We try to be compatible
-        if ( mTimeNode.literal().isDateTime() ) {
-            children[path] = mTimeNode.literal().toDateTime().toTime_t();
-        }
-        else {
-            children[path] = mTimeNode.literal().toUnsignedInt();
-        }
-    }
+    // unused in Nepomuk
 }
 
 
+// not implemented
 int64_t Strigi::NepomukIndexReader::indexSize()
 {
-    return d->repository->statementCount();
+    return -1;
 }
 
 
-time_t Strigi::NepomukIndexReader::mTime( const std::string& path )
+// not implemented
+time_t Strigi::NepomukIndexReader::mTime( const std::string& )
 {
-    //
-    // We are compatible with old Xesam data, thus the weird query
-    //
-    QString query = QString( "select ?mtime where { "
-                             "{ ?r %1 %2 . } UNION { ?r %3 %4 . } "
-                             "{ ?r %5 ?mtime . } UNION { ?r %6 ?mtime . } }" )
-                    .arg( Node::resourceToN3( Vocabulary::Xesam::url() ),
-                          Node::literalToN3( QString::fromUtf8( path.c_str() ) ),
-                          Node::resourceToN3( Nepomuk::Vocabulary::NIE::url() ),
-                          Node::resourceToN3( QUrl::fromLocalFile( \
                QFile::decodeName( path.c_str() ) ) ),
-                          Node::resourceToN3( Vocabulary::Xesam::sourceModified() ),
-                          Node::resourceToN3( \
                Nepomuk::Vocabulary::NIE::lastModified() ) );
-
-//    kDebug() << "mTime( " << path.c_str() << ") query:" << query;
-
-    QueryResultIterator it = d->repository->executeQuery( query, \
                Soprano::Query::QueryLanguageSparql );
-
-    time_t mtime = 0;
-    if ( it.next() ) {
-        Soprano::LiteralValue val = it.binding( "mtime" ).literal();
-
-        // Sadly in Xesam sourceModified is not typed as DateTime but defaults to an \
                int :( We try to be compatible
-        if ( val.isDateTime() ) {
-            mtime = val.toDateTime().toTime_t();
-        }
-        else {
-            mtime = val.toUnsignedInt();
-        }
-    }
-    return mtime;
+    return -1;
 }
 
 
--- trunk/KDE/kdebase/runtime/nepomuk/strigibackend/nepomukindexreader.h \
#1104729:1104730 @@ -1,5 +1,5 @@
 /*
-   Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org>
+   Copyright (C) 2007-2010 Sebastian Trueg <trueg@kde.org>
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -30,6 +30,8 @@
 
     class Query;
 
+    /// The IndexReader is not used in Nepomuk and thus, this is only
+    /// a dummy implementation
     class NepomukIndexReader : public Strigi::IndexReader
     {
     public:
@@ -38,12 +40,8 @@
 
         void getChildren( const std::string& parent,
                           std::map<std::string, time_t>& children );
-
         int64_t indexSize();
         time_t mTime( const std::string& uri );
-
-        // the methods below are all unused in Nepomuk and thus, not implemented
-        // ---------------------------------------------------------------------
         int32_t countDocuments();
         int32_t countWords();
         std::vector<std::string> fieldNames();
@@ -62,7 +60,6 @@
         std::vector<std::string> keywords( const std::string& keywordmatch,
                                            const std::vector<std::string>& \
                fieldnames,
                                            uint32_t max, uint32_t offset );
-        // ---------------------------------------------------------------------
 
     private:
         class Private;
--- trunk/KDE/kdebase/runtime/nepomuk/strigibackend/nepomukindexwriter.cpp \
#1104729:1104730 @@ -25,7 +25,6 @@
 
 #include <Soprano/Soprano>
 #include <Soprano/Vocabulary/RDF>
-#include <Soprano/Vocabulary/Xesam>
 #include <Soprano/LiteralValue>
 #include <Soprano/Node>
 #include <Soprano/QueryResultIterator>
@@ -347,7 +346,7 @@
 {
     for ( unsigned int i = 0; i < entries.size(); ++i ) {
         QString path = QString::fromUtf8( entries[i].c_str() );
-        removeIndexedData( path );
+        removeIndexedData( KUrl(), path );
     }
 }
 
@@ -374,7 +373,7 @@
     FileMetaData* data = new FileMetaData( idx );
 
     // remove previously indexed data
-    removeIndexedData( data->resourceUri, true );
+    removeIndexedData( data->resourceUri, data->fileUrl );
 
     // It is important to keep the resource URI between updates (especially for \
                sharing of files)
     // However, when updating data from pre-KDE 4.4 times we want to get rid of old \
file:/ resource @@ -625,34 +624,36 @@
 }
 
 
-void Strigi::NepomukIndexWriter::removeIndexedData( const KUrl& url, bool \
isResourceUri ) +void Strigi::NepomukIndexWriter::removeIndexedData( const KUrl& uri, \
const KUrl& url )  {
 //    kDebug() << url;
 
     if ( url.isEmpty() )
         return;
 
-    //
-    // We are compatible with old Xesam data where the url was encoded as a string \
                instead of a url,
-    // thus the weird query
-    //
     QString query;
-    if ( isResourceUri ) {
+    if ( uri == url || url.isEmpty() ) {
          query = QString::fromLatin1( "select ?g where { ?g %1 %2 . }" )
                     .arg( Soprano::Node::resourceToN3( \
Strigi::Ontology::indexGraphFor() ), +                          \
Soprano::Node::resourceToN3( uri ) ); +    }
+    else if ( !uri.isEmpty() ) {
+        // makes sure we also catch data created by buggy versions of ourselves.
+        query = QString::fromLatin1( "select ?g where { { ?g %1 %2 . } UNION { ?g %1 \
%3 . } }" ) +                    .arg( Soprano::Node::resourceToN3( \
Strigi::Ontology::indexGraphFor() ), +                          \
Soprano::Node::resourceToN3( uri ),  Soprano::Node::resourceToN3( url ) );
     }
     else {
+        // The last UNION makes sure we also catch data created by buggy versions of \
ourselves.  query = QString::fromLatin1( "select ?g where { "
-                                     "{ ?r %3 %1 . } "
+                                     "{ "
+                                     "?r %2 %1 . "
+                                     "?g %3 ?r . } "
                                      "UNION "
-                                     "{ ?r %3 %2 . } "
-                                     "UNION "
-                                     "{ ?r %4 %2 . } . "
-                                     "?g %5 ?r . }" )
-                    .arg( Node::literalToN3( url.path() ),
-                          Node::resourceToN3( url ),
-                          Node::resourceToN3( Vocabulary::Xesam::url() ),
+                                     "{ ?g %3 %1 . }"
+                                     "}")
+                    .arg( Node::resourceToN3( url ),
                           Node::resourceToN3( Nepomuk::Vocabulary::NIE::url() ),
                           Node::resourceToN3( Strigi::Ontology::indexGraphFor() ) );
     }
--- trunk/KDE/kdebase/runtime/nepomuk/strigibackend/nepomukindexwriter.h \
#1104729:1104730 @@ -75,10 +75,10 @@
 
     private:
         /**
-         * \param isResourceUri if true \p url is a resource URI, otherwise it
-         * is a local file URL
+         * \param uri The resource URI. Can be empty if \p url is not.
+         * \param url The file URL. Can be empty if \p uri is not.
          */
-        void removeIndexedData( const KUrl& url, bool isResourceUri = false );
+        void removeIndexedData( const KUrl& uri, const KUrl& url );
 
         QUrl determineFolderResourceUri( const KUrl& fileUrl );
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic