Revision: 17265
          http://sourceforge.net/p/gate/code/17265
Author:   valyt
Date:     2014-01-30 16:10:17 +0000 (Thu, 30 Jan 2014)
Log Message:
-----------
Quick hack to get new style indexes working in mimir-web so we can see if they 
make any sense. 

Modified Paths:
--------------
    mimir/branches/5.0/mimir-cloud/.classpath
    mimir/branches/5.0/mimir-cloud/.project
    mimir/branches/5.0/mimir-web/.classpath
    mimir/branches/5.0/mimir-web/.project
    
mimir/branches/5.0/mimir-web/grails-app/controllers/gate/mimir/web/LocalIndexController.groovy
    
mimir/branches/5.0/mimir-web/grails-app/controllers/gate/mimir/web/SearchController.groovy
    
mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/FederatedIndex.groovy
    mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/Index.groovy
    
mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/LocalIndex.groovy
    
mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/RemoteIndex.groovy
    
mimir/branches/5.0/mimir-web/grails-app/services/gate/mimir/web/FederatedIndexService.groovy
    
mimir/branches/5.0/mimir-web/grails-app/services/gate/mimir/web/LocalIndexService.groovy

Modified: mimir/branches/5.0/mimir-cloud/.classpath
===================================================================
--- mimir/branches/5.0/mimir-cloud/.classpath   2014-01-30 16:08:06 UTC (rev 
17264)
+++ mimir/branches/5.0/mimir-cloud/.classpath   2014-01-30 16:10:17 UTC (rev 
17265)
@@ -2,6 +2,7 @@
 <classpath>
        <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry kind="con" 
path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
+       <classpathentry kind="con" 
path="org.grails.ide.eclipse.core.CLASSPATH_CONTAINER"/>
        <classpathentry kind="src" path="src/java"/>
        <classpathentry kind="src" path="src/groovy"/>
        <classpathentry kind="src" path="grails-app/conf"/>
@@ -162,7 +163,6 @@
                        <attribute 
name="org.grails.ide.eclipse.core.SOURCE_FOLDER" value="true"/>
                </attributes>
        </classpathentry>
-       <classpathentry kind="con" 
path="org.grails.ide.eclipse.core.CLASSPATH_CONTAINER"/>
-       <classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
+       <classpathentry kind="con" path="GROOVY_DSL_SUPPORT"/>
        <classpathentry kind="output" path="target-eclipse/classes"/>
 </classpath>

Modified: mimir/branches/5.0/mimir-cloud/.project
===================================================================
--- mimir/branches/5.0/mimir-cloud/.project     2014-01-30 16:08:06 UTC (rev 
17264)
+++ mimir/branches/5.0/mimir-cloud/.project     2014-01-30 16:10:17 UTC (rev 
17265)
@@ -32,6 +32,7 @@
                <nature>org.eclipse.jdt.core.javanature</nature>
                
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
                <nature>com.google.gwt.eclipse.core.gwtNature</nature>
+               <nature>org.apache.ivyde.eclipse.ivynature</nature>
        </natures>
        <linkedResources>
                <link>

Modified: mimir/branches/5.0/mimir-web/.classpath
===================================================================
--- mimir/branches/5.0/mimir-web/.classpath     2014-01-30 16:08:06 UTC (rev 
17264)
+++ mimir/branches/5.0/mimir-web/.classpath     2014-01-30 16:10:17 UTC (rev 
17265)
@@ -108,8 +108,6 @@
                        <attribute 
name="org.grails.ide.eclipse.core.SOURCE_FOLDER" value="true"/>
                </attributes>
        </classpathentry>
-       <classpathentry kind="src" path="src/gwt"/>
-       <classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
        <classpathentry combineaccessrules="false" kind="src" 
path="/mimir-client"/>
        <classpathentry combineaccessrules="false" kind="src" 
path="/mimir-core"/>
        <classpathentry kind="output" path="target-eclipse/classes"/>

Modified: mimir/branches/5.0/mimir-web/.project
===================================================================
--- mimir/branches/5.0/mimir-web/.project       2014-01-30 16:08:06 UTC (rev 
17264)
+++ mimir/branches/5.0/mimir-web/.project       2014-01-30 16:10:17 UTC (rev 
17265)
@@ -32,6 +32,7 @@
                <nature>org.eclipse.jdt.core.javanature</nature>
                <nature>com.google.gwt.eclipse.core.gwtNature</nature>
                
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+               <nature>org.apache.ivyde.eclipse.ivynature</nature>
        </natures>
        <linkedResources>
                <link>

Modified: 
mimir/branches/5.0/mimir-web/grails-app/controllers/gate/mimir/web/LocalIndexController.groovy
===================================================================
--- 
mimir/branches/5.0/mimir-web/grails-app/controllers/gate/mimir/web/LocalIndexController.groovy
      2014-01-30 16:08:06 UTC (rev 17264)
+++ 
mimir/branches/5.0/mimir-web/grails-app/controllers/gate/mimir/web/LocalIndexController.groovy
      2014-01-30 16:10:17 UTC (rev 17265)
@@ -242,8 +242,7 @@
       localIndexInstance.errors.rejectValue('indexDirectory', 
'gate.mimir.web.LocalIndex.indexDirectory.notexist')
       render(view:'importIndex', model:[localIndexInstance:localIndexInstance])
     }
-    else if(!new File(indexDir, 'config.xml').isFile() ||
-    !new File(indexDir, 'mg4j').isDirectory()) {
+    else if(!new File(indexDir, 'config.xml').isFile()) {
       localIndexInstance.errors.rejectValue('indexDirectory', 
'gate.mimir.web.LocalIndex.indexDirectory.notindex')
       render(view:'importIndex', model:[localIndexInstance:localIndexInstance])
     }

Modified: 
mimir/branches/5.0/mimir-web/grails-app/controllers/gate/mimir/web/SearchController.groovy
===================================================================
--- 
mimir/branches/5.0/mimir-web/grails-app/controllers/gate/mimir/web/SearchController.groovy
  2014-01-30 16:08:06 UTC (rev 17264)
+++ 
mimir/branches/5.0/mimir-web/grails-app/controllers/gate/mimir/web/SearchController.groovy
  2014-01-30 16:10:17 UTC (rev 17265)
@@ -18,7 +18,7 @@
 import gate.mimir.web.Index;
 import gate.mimir.web.SearchService;
 import groovy.xml.StreamingMarkupBuilder;
-import gate.mimir.index.mg4j.zipcollection.DocumentData;
+import gate.mimir.index.DocumentData;
 import gate.mimir.search.query.Binding;
 import gate.mimir.search.query.QueryNode;
 import gate.mimir.search.query.parser.ParseException;
@@ -458,6 +458,7 @@
           try{
             documentRank = documentRankParam as long
             documentId = runner.getDocumentID(documentRank)
+println("Doc ID $documentId")            
           } catch (Exception e) {
             response.sendError(HttpServletResponse.SC_BAD_REQUEST,
               "Invalid value provided for parameter rank (not an integer)!")
@@ -491,6 +492,7 @@
     }
     // at this point we have the documentId
     Index theIndex = (Index)request.theIndex
+println("Doc ID2 $documentId")
     DocumentData docData = theIndex.getDocumentData(documentId)
     //a closure representing the return message
     def message;

Modified: 
mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/FederatedIndex.groovy
===================================================================
--- 
mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/FederatedIndex.groovy
 2014-01-30 16:08:06 UTC (rev 17264)
+++ 
mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/FederatedIndex.groovy
 2014-01-30 16:10:17 UTC (rev 17265)
@@ -14,7 +14,7 @@
 
 import org.hibernate.proxy.HibernateProxy;
 
-import gate.mimir.index.mg4j.zipcollection.DocumentData
+import gate.mimir.index.DocumentData
 import gate.mimir.search.QueryRunner
 import gate.mimir.search.FederatedQueryRunner
 import gate.mimir.search.query.QueryNode;

Modified: 
mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/Index.groovy
===================================================================
--- mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/Index.groovy  
2014-01-30 16:08:06 UTC (rev 17264)
+++ mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/Index.groovy  
2014-01-30 16:10:17 UTC (rev 17265)
@@ -17,7 +17,7 @@
 import gate.mimir.search.query.parser.ParseException
 import gate.mimir.search.terms.TermsQuery;
 import gate.mimir.search.terms.TermsResultSet;
-import gate.mimir.index.mg4j.zipcollection.DocumentData
+import gate.mimir.index.DocumentData
 
 /**
  * Top level class representing a single index (local or remote) in mimir.

Modified: 
mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/LocalIndex.groovy
===================================================================
--- 
mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/LocalIndex.groovy 
    2014-01-30 16:08:06 UTC (rev 17264)
+++ 
mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/LocalIndex.groovy 
    2014-01-30 16:10:17 UTC (rev 17265)
@@ -15,7 +15,7 @@
 
 import java.io.Writer;
 
-import gate.mimir.index.mg4j.zipcollection.DocumentData
+import gate.mimir.index.DocumentData
 import gate.mimir.search.QueryRunner
 import gate.mimir.search.query.QueryNode;
 import gate.mimir.search.query.parser.ParseException
@@ -123,6 +123,7 @@
   * @return
   */
   DocumentData getDocumentData(long documentID) {
+println("Doc ID3 $documentID")
     return localIndexService.getDocumentData(this, documentID)
   }
 

Modified: 
mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/RemoteIndex.groovy
===================================================================
--- 
mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/RemoteIndex.groovy
    2014-01-30 16:08:06 UTC (rev 17264)
+++ 
mimir/branches/5.0/mimir-web/grails-app/domain/gate/mimir/web/RemoteIndex.groovy
    2014-01-30 16:10:17 UTC (rev 17265)
@@ -14,7 +14,7 @@
  */
 package gate.mimir.web;
 
-import gate.mimir.index.mg4j.zipcollection.DocumentData
+import gate.mimir.index.DocumentData
 import gate.mimir.search.QueryRunner
 import gate.mimir.search.RemoteQueryRunner
 import gate.mimir.search.query.QueryNode;

Modified: 
mimir/branches/5.0/mimir-web/grails-app/services/gate/mimir/web/FederatedIndexService.groovy
===================================================================
--- 
mimir/branches/5.0/mimir-web/grails-app/services/gate/mimir/web/FederatedIndexService.groovy
        2014-01-30 16:08:06 UTC (rev 17264)
+++ 
mimir/branches/5.0/mimir-web/grails-app/services/gate/mimir/web/FederatedIndexService.groovy
        2014-01-30 16:10:17 UTC (rev 17265)
@@ -14,7 +14,7 @@
  */
 package gate.mimir.web
 
-import gate.mimir.index.mg4j.zipcollection.DocumentData
+import gate.mimir.index.DocumentData
 import gate.mimir.search.QueryRunner
 import gate.mimir.search.FederatedQueryRunner
 import gate.mimir.search.query.QueryNode;

Modified: 
mimir/branches/5.0/mimir-web/grails-app/services/gate/mimir/web/LocalIndexService.groovy
===================================================================
--- 
mimir/branches/5.0/mimir-web/grails-app/services/gate/mimir/web/LocalIndexService.groovy
    2014-01-30 16:08:06 UTC (rev 17264)
+++ 
mimir/branches/5.0/mimir-web/grails-app/services/gate/mimir/web/LocalIndexService.groovy
    2014-01-30 16:10:17 UTC (rev 17265)
@@ -27,9 +27,9 @@
 import gate.mimir.search.QueryRunner;
 import gate.mimir.AbstractSemanticAnnotationHelper;
 import gate.mimir.IndexConfig
+import gate.mimir.MimirIndex;
 import gate.mimir.index.IndexException;
-import gate.mimir.index.Indexer
-import gate.mimir.index.mg4j.zipcollection.DocumentData;
+import gate.mimir.index.DocumentData;
 import gate.mimir.SemanticAnnotationHelper;
 import gate.mimir.IndexConfig.SemanticIndexerConfig;
 import gate.mimir.search.query.parser.ParseException;
@@ -64,11 +64,8 @@
    */
   def searchThreadPool
     
-  private Map indexers = [:]
+  private Map<Long, MimirIndex> indexes = [:]
 
-
-  private Map queryEngines = [:]
-
   /**
    * At startup, any indexes that are listed in the DB as being in any state
    * other than searching are now invalid, so need to be marked as failed.
@@ -83,8 +80,8 @@
     }
   }
                           
-  public synchronized Indexer findIndexer(LocalIndex index) {
-    def indexer = indexers[index.id]
+  public synchronized MimirIndex findIndexer(LocalIndex index) {
+    def indexer = indexes[index.id]
     if(!indexer) {
       if(index.state != Index.INDEXING) {
         throw new IllegalStateException(
@@ -99,11 +96,11 @@
    * specified by the given LocalIndex, and store the corresponding Indexer for
    * future use.
    */
-  public synchronized Indexer createIndex(LocalIndex index, IndexTemplate 
templ) {
+  public synchronized MimirIndex createIndex(LocalIndex index, IndexTemplate 
templ) {
     def indexConfig = GroovyIndexConfigParser.createIndexConfig(
         templ.configuration, new File(index.indexDirectory))
-    Indexer indexer = new Indexer(indexConfig)
-    indexers[index.id] = indexer
+    MimirIndex indexer = new MimirIndex(indexConfig)
+    indexes[index.id] = indexer
     return indexer
   }
 
@@ -114,7 +111,7 @@
       def indexId = index.id
       Thread.start {
         try {
-          indexers.remove(indexId)?.close()
+          indexes.remove(indexId)?.close()
           LocalIndex.withTransaction { status ->
             def theIndex = LocalIndex.get(indexId)
             theIndex.state = Index.SEARCHING
@@ -131,10 +128,8 @@
         }
       }
     } else if(index.state == Index.SEARCHING) {
-      QueryEngine engine = queryEngines.remove(index.id)
-      if(engine) {
-        engine.close()
-      }
+      indexes.remove(index.id)?.close()
+      
     }
   }
   
@@ -152,7 +147,8 @@
   }
   
   public synchronized DocumentData getDocumentData(LocalIndex index, long 
documentId) {
-    return getQueryEngine(index).getDocumentData(documentId)
+println("Doc ID4 $documentId")
+    return getQueryEngine(index).getIndex().getDocumentData(documentId)
   }
   
   public synchronized void renderDocument(LocalIndex index, long documentId, 
Appendable out) {
@@ -161,33 +157,35 @@
   
   
   public synchronized void deleteDocuments(LocalIndex index, Collection<Long> 
documentIds) {
-    getQueryEngine(index).deleteDocuments(documentIds)
+    getQueryEngine(index).getIndex().deleteDocuments(documentIds)
   }
 
   public synchronized void undeleteDocuments(LocalIndex index, 
Collection<Long> documentIds) {
-    getQueryEngine(index).undeleteDocuments(documentIds)
+    getQueryEngine(index).getIndex().undeleteDocuments(documentIds)
   }
     
   
   public synchronized QueryEngine getQueryEngine (LocalIndex index){
-    QueryEngine engine = queryEngines[index.id]
-    if(!engine) {
-      if(index.state != Index.SEARCHING) {
-        throw new IllegalStateException(
-        "Index ${index.indexId} is not open for searching")
-      }
+    MimirIndex mIndex = indexes[index.id]
+    QueryEngine engine = null
+    if(mIndex) {
+      engine = mIndex.getQueryEngine()
+    } else{
+      // index not yet open
       try {
-        engine = new QueryEngine(new File(index.indexDirectory))
+        mIndex = new MimirIndex(new File(index.indexDirectory))
+        indexes[index.id] = mIndex
+        engine = mIndex.getQueryEngine()
         engine.queryTokeniser = queryTokeniser
         engine.executor = searchThreadPool
-        engine.setSubBindingsEnabled(index.subBindingsEnabled?:false) 
-        queryEngines[index.id] = engine
+        engine.setSubBindingsEnabled(index.subBindingsEnabled?:false)
       } catch (Exception e) {
         log.error("Cannot open local index at ${index?.indexDirectory}", e)
         index.state = Index.FAILED
         return null
       }
     }
+ 
     // the scorer may have changed, so we update it every time
     if(index.scorer) {
       
engine.setScorerSource(grailsApplication.config.gate.mimir.scorers[index.scorer]
 as Callable<MimirScorer>)
@@ -249,10 +247,7 @@
     String indexDirectory = index.indexDirectory
     // stop the index
     try{
-      QueryEngine engine = queryEngines.remove(index.id)
-      if (engine) {
-        engine.close()
-      }
+      indexes.remove(index.id)?.close()
     } catch(Exception e) {
       log.warn("Exception while trying to close index, prior to deletion", e)
     }

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


------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to