Revision: 15963
          http://gate.svn.sourceforge.net/gate/?rev=15963&view=rev
Author:   valyt
Date:     2012-07-20 11:22:42 +0000 (Fri, 20 Jul 2012)
Log Message:
-----------
Throw an exception explaining that a direct index was required but not found 
(rather then a NPE later on).

Modified Paths:
--------------
    
mimir/trunk/mimir-core/src/gate/mimir/search/terms/AbstractIndexTermsQuery.java

Modified: 
mimir/trunk/mimir-core/src/gate/mimir/search/terms/AbstractIndexTermsQuery.java
===================================================================
--- 
mimir/trunk/mimir-core/src/gate/mimir/search/terms/AbstractIndexTermsQuery.java 
    2012-07-20 01:19:36 UTC (rev 15962)
+++ 
mimir/trunk/mimir-core/src/gate/mimir/search/terms/AbstractIndexTermsQuery.java 
    2012-07-20 11:22:42 UTC (rev 15963)
@@ -28,7 +28,7 @@
 import java.io.IOException;
 
 /**
- * Base class for terms queries that use an MG4J index for their search.
+ * Base class for terms queries that use an MG4J direct index for their search.
  */
 public abstract class AbstractIndexTermsQuery extends AbstractTermsQuery {
   
@@ -69,7 +69,16 @@
     this.indexType = indexType;
   }
 
-  
+  /**
+   * Populates the internal state by obtaining references to the direct and
+   * indirect indexes from the {@link QueryEngine}.
+   *   
+   * @param engine the {@link QueryEngine} used to execute this query.
+   * 
+   * @throws IllegalArgumentException if the index represented by the provided
+   * query engine does not have a direct index for the given sub-index (as 
+   * specified by {@link #indexType} and {@link #indexName}).
+   */
   protected void prepare(QueryEngine engine) {
     this.engine = engine;
     switch(indexType){
@@ -85,6 +94,12 @@
         throw new IllegalArgumentException("Invalid index type: " + 
             indexType.toString());
     }
+    if(directIndexPool == null) {
+      throw new IllegalArgumentException("This type of query requires a " +
+               "direct index, but one was not found for (" + 
+          indexType.toString().toLowerCase() + ") sub-index \"" + 
+               indexName + "\"");
+    }
   }
   
   protected TermsResultSet buildResultSet(DocumentIterator documentIterator) 

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


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to