X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.indexing%2Fsrc%2Forg%2Fsimantics%2Fdb%2Findexing%2FIndexedRelationsMemorySearcher.java;h=d1282c766f968db9cb6539071666659f8c877042;hb=3d96e3fa94898d90d6892c081ebed7cb9e773a4a;hp=ac0918ea52e9eb9e33bc4c0c6a27a3becbfd7d79;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsMemorySearcher.java b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsMemorySearcher.java index ac0918ea5..d1282c766 100644 --- a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsMemorySearcher.java +++ b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsMemorySearcher.java @@ -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; @@ -36,6 +32,11 @@ import org.simantics.db.Session; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.adapter.GenericRelation; 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 @@ -43,6 +44,8 @@ import org.simantics.utils.datastructures.Pair; */ public class IndexedRelationsMemorySearcher extends IndexedRelationsSearcherBase { + private static final Logger LOGGER = LoggerFactory.getLogger(IndexedRelationsMemorySearcher.class); + final IndexedRelationsSearcher backend; final GenericRelation r; @@ -90,8 +93,7 @@ public class IndexedRelationsMemorySearcher extends IndexedRelationsSearcherBase super.removeIndex(monitor, r, processor, key, keyValues); } - public List allDocs(IProgressMonitor monitor, Session session) throws ParseException, IOException, - DatabaseException { + public List allDocs(IProgressMonitor monitor, Session session) throws IOException { Query query = new MatchAllDocsQuery(); @@ -108,28 +110,19 @@ public class IndexedRelationsMemorySearcher extends IndexedRelationsSearcherBase } for(ScoreDoc scoreDoc:scoreDocs) { - - try { - - Document doc = reader.document(scoreDoc.doc); - List 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 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); @@ -173,19 +166,16 @@ public class IndexedRelationsMemorySearcher extends IndexedRelationsSearcherBase @Override Directory getDirectory(Session session) throws IOException { MemoryIndexing mem = MemoryIndexing.getInstance(session); - String path = indexPath.getAbsolutePath(); + String path = indexPath.toAbsolutePath().toString(); return mem.getDirectory(path, Queries.getAnalyzer()); } @Override Throwable bestEffortClear(IProgressMonitor monitor, Session session) { - - setProblem(null); - MemoryIndexing mem = MemoryIndexing.getInstance(session); changed.clear(); - String path = indexPath.getAbsolutePath(); + String path = indexPath.toAbsolutePath().toString(); mem.remove(path); return null; @@ -196,5 +186,10 @@ public class IndexedRelationsMemorySearcher extends IndexedRelationsSearcherBase protected boolean requireChangeInfoOnReplace() { return false; } + + @Override + protected Logger getLogger() { + return LOGGER; + } }