Revision: 14605
          http://gate.svn.sourceforge.net/gate/?rev=14605&view=rev
Author:   valyt
Date:     2011-11-25 09:19:03 +0000 (Fri, 25 Nov 2011)
Log Message:
-----------
Annotation query simply returns no results when there are no mention URIs 
coming from the helpers, shortcutting the creation of the underlying OR.

Modified Paths:
--------------
    mimir/trunk/mimir-core/src/gate/mimir/search/query/AnnotationQuery.java

Modified: 
mimir/trunk/mimir-core/src/gate/mimir/search/query/AnnotationQuery.java
===================================================================
--- mimir/trunk/mimir-core/src/gate/mimir/search/query/AnnotationQuery.java     
2011-11-25 09:18:48 UTC (rev 14604)
+++ mimir/trunk/mimir-core/src/gate/mimir/search/query/AnnotationQuery.java     
2011-11-25 09:19:03 UTC (rev 14605)
@@ -89,17 +89,23 @@
         (System.currentTimeMillis() - start) + " ms");
       // now create a big OrQuery of all the possible mentions with
       // appropriate gaps
-      QueryNode[] disjuncts = new QueryNode[mentions.size()];
-      int index = 0;
-      for(Mention m : mentions) {
-        // create a term query for the mention URI
-        disjuncts[index] = new TermQuery(query.annotationType, 
-                m.getUri(), m.getLength());
-        index++;
+      if(mentions.size() > 0) {
+        QueryNode[] disjuncts = new QueryNode[mentions.size()];
+        int index = 0;
+        for(Mention m : mentions) {
+          // create a term query for the mention URI
+          disjuncts[index] = new TermQuery(query.annotationType, 
+                  m.getUri(), m.getLength());
+          index++;
+        }
+        
+        QueryNode underlyingQuery = new OrQuery(disjuncts);
+        underlyingExecutor = underlyingQuery.getQueryExecutor(engine);        
+      } else {
+        // no results from the helper => no results from us
+        latestDocument = -1;
       }
-      
-      QueryNode underlyingQuery = new OrQuery(disjuncts);
-      underlyingExecutor = underlyingQuery.getQueryExecutor(engine);
+
     }
 
     /**
@@ -143,8 +149,8 @@
      * @see gate.mimir.search.query.QueryExecutor#nextDocument(int)
      */
     public int nextDocument(int greaterThan) throws IOException {
-      if(closed) return -1;
-      return underlyingExecutor.nextDocument(greaterThan);
+      if(closed || latestDocument == -1) return -1;
+      return latestDocument = underlyingExecutor.nextDocument(greaterThan);
     }
 
     /* (non-Javadoc)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to