X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.indexing%2Fsrc%2Forg%2Fsimantics%2Fdb%2Findexing%2FIndexedRelationsSearcher.java;h=2e714b09a9c1d9cded563c6279011de70175c1c4;hb=b14aabb9b1160cbbadef994db5778a45a13f5533;hp=115e54595585bafe2b3b5ca88a9e0c2f2bee4c03;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcher.java b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcher.java index 115e54595..2e714b09a 100644 --- a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcher.java +++ b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcher.java @@ -25,15 +25,20 @@ import org.simantics.db.RequestProcessor; import org.simantics.db.Resource; import org.simantics.db.Session; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.indexing.exception.IndexingException; import org.simantics.db.layer0.adapter.GenericRelation; import org.simantics.utils.datastructures.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Tuukka Lehtonen * @author Antti Villberg */ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase { - + + private static final Logger LOGGER = LoggerFactory.getLogger(IndexedRelationsSearcher.class); + IndexedRelationsMemorySearcher cache; IndexedRelationsSearcher(RequestProcessor session, Resource relation, Resource input, GenericRelation r) throws DatabaseException { @@ -98,7 +103,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase { } else if ("String".equals(fieldClass) || "Text".equals(fieldClass)) { data[index++] = ""; } else { - throw new DatabaseException("Can only index Long and String fields, encountered class " + fieldClass); + throw new IndexingException("Can only index Long and String fields, encountered class " + fieldClass); } } } @@ -122,11 +127,11 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase { } List> persistentCachedSearch(IProgressMonitor monitor, RequestProcessor processor, String search, - int maxResultCount) throws ParseException, IOException, DatabaseException { + int maxResultCount) throws ParseException, IOException, IndexingException { MemoryIndexing mem = MemoryIndexing.getInstance(session.getSession()); - String key = indexPath.getAbsolutePath(); + String key = indexPath.toAbsolutePath().toString(); Map>> cache = mem.persistentCache.get(key); if(cache != null) { @@ -150,11 +155,11 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase { } List persistentCachedSearchResources(IProgressMonitor monitor, RequestProcessor processor, String search, - int maxResultCount) throws ParseException, IOException, DatabaseException { + int maxResultCount) throws ParseException, IOException, IndexingException { MemoryIndexing mem = MemoryIndexing.getInstance(session.getSession()); - String key = indexPath.getAbsolutePath(); + String key = indexPath.toAbsolutePath().toString(); Map> cache = mem.persistentCacheResources.get(key); if(cache != null) { @@ -177,7 +182,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase { } - List persistentCachedList(IProgressMonitor monitor, RequestProcessor processor) throws ParseException, IOException, DatabaseException { + List persistentCachedList(IProgressMonitor monitor, RequestProcessor processor) throws ParseException, IOException, IndexingException { startAccess(monitor, processor.getSession(), false); @@ -189,7 +194,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase { @Override List> doSearch(IProgressMonitor monitor, RequestProcessor processor, String search, - int maxResultCount) throws ParseException, IOException, DatabaseException { + int maxResultCount) throws ParseException, IOException, IndexingException { List> persistent = persistentCachedSearch(monitor, processor, search, maxResultCount); List> cached = cache.doSearch(monitor, processor, search, maxResultCount); @@ -209,7 +214,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase { @Override List doSearchResources(IProgressMonitor monitor, RequestProcessor processor, String search, - int maxResultCount) throws ParseException, IOException, DatabaseException { + int maxResultCount) throws ParseException, IOException, IndexingException { List persistent = persistentCachedSearchResources(monitor, processor, search, maxResultCount); List cached = cache.doSearchResources(monitor, processor, search, maxResultCount); @@ -225,7 +230,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase { } - List doList(IProgressMonitor monitor, RequestProcessor processor) throws ParseException, IOException, DatabaseException { + List doList(IProgressMonitor monitor, RequestProcessor processor) throws ParseException, IOException, IndexingException { List persistent = persistentCachedList(monitor, processor); @@ -280,7 +285,7 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase { t = cache.bestEffortClear(monitor, session); if(t != null) return t; - String key = indexPath.getAbsolutePath(); + String key = indexPath.toAbsolutePath().toString(); MemoryIndexing mem = MemoryIndexing.getInstance(session); mem.persistentCache.remove(key); mem.persistentCacheResources.remove(key); @@ -288,5 +293,10 @@ public class IndexedRelationsSearcher extends IndexedRelationsSearcherBase { return null; } + + @Override + protected Logger getLogger() { + return LOGGER; + } }