Revision: 14606
http://gate.svn.sourceforge.net/gate/?rev=14606&view=rev
Author: valyt
Date: 2011-11-25 10:33:59 +0000 (Fri, 25 Nov 2011)
Log Message:
-----------
Copied bugfixes from trunk (empty OR used to produce exceptions).
Modified Paths:
--------------
mimir/branches/3.4/mimir-core/src/gate/mimir/search/query/AnnotationQuery.java
mimir/branches/3.4/mimir-core/src/gate/mimir/search/query/OrQuery.java
Modified:
mimir/branches/3.4/mimir-core/src/gate/mimir/search/query/AnnotationQuery.java
===================================================================
---
mimir/branches/3.4/mimir-core/src/gate/mimir/search/query/AnnotationQuery.java
2011-11-25 09:19:03 UTC (rev 14605)
+++
mimir/branches/3.4/mimir-core/src/gate/mimir/search/query/AnnotationQuery.java
2011-11-25 10:33:59 UTC (rev 14606)
@@ -89,17 +89,22 @@
(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 +148,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)
Modified: mimir/branches/3.4/mimir-core/src/gate/mimir/search/query/OrQuery.java
===================================================================
--- mimir/branches/3.4/mimir-core/src/gate/mimir/search/query/OrQuery.java
2011-11-25 09:19:03 UTC (rev 14605)
+++ mimir/branches/3.4/mimir-core/src/gate/mimir/search/query/OrQuery.java
2011-11-25 10:33:59 UTC (rev 14606)
@@ -49,22 +49,28 @@
/**
* @param engine
* @param query
- * @throws IOException
+ * @throws IOException
*/
- public OrQueryExecutor(OrQuery query, QueryEngine engine) throws
IOException {
+ public OrQueryExecutor(OrQuery query, QueryEngine engine)
+ throws IOException {
super(engine);
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);
+ }
}
}
}
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