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

List:       kde-commits
Subject:    KDE/kdebase/runtime/nepomuk/services/queryservice
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2010-03-25 9:21:59
Message-ID: 20100325092159.A6ACDAC87D () svn ! kde ! org
[Download RAW message or body]

SVN commit 1107299 by trueg:

Do not perform the second query if the first one yielded less than 10 results.

 M  +8 -2      searchthread.cpp  
 M  +1 -0      searchthread.h  


--- trunk/KDE/kdebase/runtime/nepomuk/services/queryservice/searchthread.cpp #1107298:1107299
@@ -54,7 +54,8 @@
 using namespace Soprano;
 
 Nepomuk::Query::SearchThread::SearchThread( QObject* parent )
-    : QThread( parent )
+    : QThread( parent ),
+      m_resultCnt( 0 )
 {
 }
 
@@ -93,6 +94,8 @@
     QTime time;
     time.start();
 
+    m_resultCnt = 0;
+
     //
     // To speed up the user experience and since in most cases users would only
     // look at the first few results anyway, we run the query twice: once with a
@@ -103,7 +106,8 @@
     //
     if ( m_sparqlQuery.endsWith( QLatin1String( "}" ) ) ) {
         sparqlQuery( m_sparqlQuery + QLatin1String( " LIMIT 10" ), 1.0 );
-        sparqlQuery( m_sparqlQuery + QLatin1String( " OFFSET 10" ), 1.0 );
+        if ( !m_canceled && m_resultCnt >= 10 )
+            sparqlQuery( m_sparqlQuery + QLatin1String( " OFFSET 10" ), 1.0 );
     }
     else {
         sparqlQuery( m_sparqlQuery, 1.0 );
@@ -121,6 +125,8 @@
     while ( hits.next() ) {
         if ( m_canceled ) break;
 
+        ++m_resultCnt;
+
         Result result = extractResult( hits );
         result.setScore( baseScore );
 
--- trunk/KDE/kdebase/runtime/nepomuk/services/queryservice/searchthread.h #1107298:1107299
@@ -69,6 +69,7 @@
 
             // status
             bool m_canceled;
+            int m_resultCnt;
         };
     }
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

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