Improve startup time for fresh or rollback'd session in index writing
[simantics/platform.git] / bundles / org.simantics.db.indexing / src / org / simantics / db / indexing / IndexedRelationsMemorySearcher.java
index 8fc0ce911b32fe5f012463a8f7796fc80d0dee45..d1282c766f968db9cb6539071666659f8c877042 100644 (file)
@@ -11,9 +11,6 @@
  *******************************************************************************/
 package org.simantics.db.indexing;
 
-import gnu.trove.map.hash.THashMap;
-import gnu.trove.set.hash.TLongHashSet;
-
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -23,7 +20,6 @@ import java.util.Map;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexableField;
-import org.apache.lucene.queryparser.classic.ParseException;
 import org.apache.lucene.search.MatchAllDocsQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
@@ -39,6 +35,9 @@ import org.simantics.utils.datastructures.Pair;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import gnu.trove.map.hash.THashMap;
+import gnu.trove.set.hash.TLongHashSet;
+
 /**
  * @author Tuukka Lehtonen
  * @author Antti Villberg
@@ -94,8 +93,7 @@ public class IndexedRelationsMemorySearcher extends IndexedRelationsSearcherBase
         super.removeIndex(monitor, r, processor, key, keyValues);
     }
     
-    public List<Object[]> allDocs(IProgressMonitor monitor, Session session) throws ParseException, IOException,
-    DatabaseException {
+    public List<Object[]> allDocs(IProgressMonitor monitor, Session session) throws IOException {
         
         Query query = new MatchAllDocsQuery(); 
 
@@ -112,28 +110,19 @@ public class IndexedRelationsMemorySearcher extends IndexedRelationsSearcherBase
         }
 
         for(ScoreDoc scoreDoc:scoreDocs) {
-
-            try {
-
-                Document doc = reader.document(scoreDoc.doc);
-                List<IndexableField> fs = doc.getFields();
-                Object[] o = new Object[fs.size()];
-                int index = 0; 
-                for (IndexableField f : fs) {
-                    String clazz = classMap.get(f.name());
-                    if ("Long".equals(clazz)) {
-                        o[index++] = Long.parseLong(f.stringValue());
-                    } else {
-                        o[index++] = f.stringValue();
-                    }
+            Document doc = reader.document(scoreDoc.doc);
+            List<IndexableField> fs = doc.getFields();
+            Object[] o = new Object[fs.size()];
+            int index = 0; 
+            for (IndexableField f : fs) {
+                String clazz = classMap.get(f.name());
+                if ("Long".equals(clazz)) {
+                    o[index++] = Long.parseLong(f.stringValue());
+                } else {
+                    o[index++] = f.stringValue();
                 }
-                result.add(o);
-            } catch (CorruptIndexException e) {
-                throw new DatabaseException(e);
-            } catch (IOException e) {
-                throw new DatabaseException(e);
             }
-
+            result.add(o);
         }
 
         changeState(monitor, session, State.READY);