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

List:       kde-commits
Subject:    playground/base/nepomuk-kde/backupsync/lib
From:       Vishesh Handa <handa.vish () gmail ! com>
Date:       2010-07-26 10:26:22
Message-ID: 20100726102622.1587AAC867 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1154814 by vhanda:

IdentificationFile optimization. Reduced the number of queries by half


 M  +8 -18     identificationfile.cpp  


--- trunk/playground/base/nepomuk-kde/backupsync/lib/identificationfile.cpp \
#1154813:1154814 @@ -19,6 +19,7 @@
 
 #include "identificationfile.h"
 #include "logfile.h"
+#include "backupsync.h"
 
 #include <QtCore/QList>
 #include <QtCore/QFile>
@@ -82,30 +83,19 @@
     // Query each uri for rdf:type and nao:identifyingProperty
     //
     foreach( const QUrl & uri, uniqueUri ) {
-        //Get rdf:type
-        QString query = QString("select distinct ?t where { %1 %2 ?t . }")
+        //Get nao:identifyingProperty, and rdf:type
+        QString query = QString::fromLatin1("select distinct ?p ?o where { "
+                                    "%1 ?p ?o. "
+                                    "{ ?p %2 %3 . }"
+                                    "UNION { ?p %2 %4. } } ")
         .arg( Soprano::Node(uri).toN3() )
+                .arg( Soprano::Node::resourceToN3( \
Soprano::Vocabulary::RDFS::subPropertyOf() ) ) +                .arg( \
Soprano::Node::resourceToN3( Nepomuk::Vocabulary::backupsync::identifyingProperty() \
                ))
         .arg( Soprano::Node::resourceToN3( Soprano::Vocabulary::RDF::type() ) );
         
         Soprano::QueryResultIterator it = model->executeQuery( query, \
                Soprano::Query::QueryLanguageSparql );
-        while ( it.next() ) {
             Soprano::Node sub( uri );
-            Soprano::Node pred( Soprano::Vocabulary::RDF::type() );
-            Soprano::Node obj = it["t"];
-            
-            m_statements.push_back( Soprano::Statement( sub, pred, obj ) );
-        }
-        it.close();
-        
-        //Get nao:identifyingProperty
-        //TODO: Use a proper vocabulary
-        query = QString("select distinct ?p ?o where { %1 ?p ?o. ?p %2 \
                nao:identifyingProperty . } ")
-        .arg( Soprano::Node(uri).toN3() )
-        .arg( Soprano::Node::resourceToN3( \
                Soprano::Vocabulary::RDFS::subPropertyOf() ) );
-        
-        it = model->executeQuery( query, Soprano::Query::QueryLanguageSparql );
         while( it.next() ) {
-            Soprano::Node sub( uri );
             Soprano::Node pred = it["p"];
             Soprano::Node obj = it["o"];
             


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

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