Revision: 14604
          http://gate.svn.sourceforge.net/gate/?rev=14604&view=rev
Author:   valyt
Date:     2011-11-25 09:18:48 +0000 (Fri, 25 Nov 2011)
Log Message:
-----------
OR query returns no results when the supplied disjunction is empty (as opposed 
to throwing an exception).

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

Modified: mimir/trunk/mimir-core/src/gate/mimir/search/query/OrQuery.java
===================================================================
--- mimir/trunk/mimir-core/src/gate/mimir/search/query/OrQuery.java     
2011-11-25 02:18:13 UTC (rev 14603)
+++ mimir/trunk/mimir-core/src/gate/mimir/search/query/OrQuery.java     
2011-11-25 09:18:48 UTC (rev 14604)
@@ -54,21 +54,25 @@
     public OrQueryExecutor(OrQuery query, QueryEngine engine) throws 
IOException {
       super(engine, query);
       this.query = query;
-      //prepare all the executors
-      this.executors = new ExecutorsList(engine, query.getNodes());
-      currentDoc = new int[executors.size()];
-      front = new int[executors.size()];
-      this.hitsOnCurrentDocument = new ObjectArrayList<Binding>();
-      queue = new IntHeapSemiIndirectPriorityQueue(currentDoc);
-      for(int i = 0; i < executors.size(); i++){
-        int doc = executors.nextDocument(i, -1);
-        if (doc >= 0) {
-          currentDoc[i] = doc;
-          queue.enqueue(i);
-        }
+      if(query.getNodes() == null || query.getNodes().length == 0) {
+        // empty OR: we're already exhausted
+        latestDocument = -1;
+      } else {
+        //prepare all the executors
+        this.executors = new ExecutorsList(engine, query.getNodes());
+        currentDoc = new int[executors.size()];
+        front = new int[executors.size()];
+        this.hitsOnCurrentDocument = new ObjectArrayList<Binding>();
+        queue = new IntHeapSemiIndirectPriorityQueue(currentDoc);
+        for(int i = 0; i < executors.size(); i++){
+          int doc = executors.nextDocument(i, -1);
+          if (doc >= 0) {
+            currentDoc[i] = doc;
+            queue.enqueue(i);
+          }
+        }        
       }
     }
-
     
     /**
      * The query being executed.

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