X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.indexing%2Fsrc%2Forg%2Fsimantics%2Fdb%2Findexing%2FIndexedRelationsImpl.java;h=1d027a8252c6c4894f9a3b87cc94ceb033f4a536;hb=9c1b0bdc646d2e91526e49fd9233c2eb0c243019;hp=1b4d62a1d6c6cf9c6d199b7454e713232c763526;hpb=965fa411938344172cff82a2ec0b6c50b7cb2b7c;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsImpl.java b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsImpl.java index 1b4d62a1d..1d027a825 100644 --- a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsImpl.java +++ b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsImpl.java @@ -13,6 +13,7 @@ package org.simantics.db.indexing; import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -37,6 +38,8 @@ import org.simantics.db.layer0.genericrelation.IndexedRelations; import org.simantics.db.service.QueryControl; import org.simantics.db.service.SerialisationSupport; import org.simantics.utils.datastructures.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Tuukka Lehtonen @@ -44,6 +47,8 @@ import org.simantics.utils.datastructures.Pair; */ public class IndexedRelationsImpl implements IndexedRelations { + private static final Logger LOGGER = LoggerFactory.getLogger(IndexedRelationsImpl.class); + Map indexLocks = new WeakHashMap(); static class LockHandle { @@ -370,7 +375,7 @@ public class IndexedRelationsImpl implements IndexedRelations { @Override public void insert(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation, - Resource relationResource, Resource input, Collection documents) { + Resource relationResource, Resource input, Collection documents) throws IndexException { // System.out.println("Inserting to index: " + input + " " + documents); @@ -413,7 +418,7 @@ public class IndexedRelationsImpl implements IndexedRelations { @Override public void remove(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation, - Resource relationResource, Resource input, String key, Collection keyValues) { + Resource relationResource, Resource input, String key, Collection keyValues) throws IndexException { if (relation == null) throw new IllegalArgumentException("null relation"); @@ -473,7 +478,7 @@ public class IndexedRelationsImpl implements IndexedRelations { @Override public boolean replace(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation, - Resource relationResource, Resource input, String key, Collection keyValues, Collection documents) { + Resource relationResource, Resource input, String key, Collection keyValues, Collection documents) throws IndexException { if (relation == null) throw new IllegalArgumentException("null relation"); @@ -497,7 +502,7 @@ public class IndexedRelationsImpl implements IndexedRelations { // Could not write index for some reason. Ignore and let the next index query reinitialize the index. return true; } - searcher.replaceIndex(progress.newChild(40), key, keyValues, relation, 1, documents); + didChange |= searcher.replaceIndex(progress.newChild(40), key, keyValues, relation, 1, documents); } catch (InvalidResourceReferenceException e) { throw new IndexException(e); @@ -521,16 +526,15 @@ public class IndexedRelationsImpl implements IndexedRelations { IndexedRelationsSearcherBase searcher = makeSearcher(processor, relationResource, input); LockHandle handle = lock(processor, Pair.make(relationResource, input), true); - + Path path = DatabaseIndexing.getIndexLocation(processor.getSession(), relationResource, input); try { searcher.changeState(monitor, processor.getSession(), State.NONE); if (!searcher.checkState(State.NONE)) throw new IndexException("Could not close index for input " + input + " before removing it"); - File path = DatabaseIndexing.getIndexLocation(processor.getSession(), relationResource, input); DatabaseIndexing.deleteIndex(path); - } catch (IOException e) { + LOGGER.error("Could not delete {}", path.toAbsolutePath(), e); throw new IndexException(e); } finally { handle.unlock();