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;
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
*/
public class IndexedRelationsImpl implements IndexedRelations {
+ private static final Logger LOGGER = LoggerFactory.getLogger(IndexedRelationsImpl.class);
+
Map<Object, RWLock> indexLocks = new WeakHashMap<Object, RWLock>();
static class LockHandle {
@Override
public void insert(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation,
- Resource relationResource, Resource input, Collection<Object[]> documents) {
+ Resource relationResource, Resource input, Collection<Object[]> documents) throws IndexException {
// System.out.println("Inserting to index: " + input + " " + documents);
@Override
public void remove(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation,
- Resource relationResource, Resource input, String key, Collection<Object> keyValues) {
+ Resource relationResource, Resource input, String key, Collection<Object> keyValues) throws IndexException {
if (relation == null)
throw new IllegalArgumentException("null relation");
@Override
public boolean replace(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation,
- Resource relationResource, Resource input, String key, Collection<Object> keyValues, Collection<Object[]> documents) {
+ Resource relationResource, Resource input, String key, Collection<Object> keyValues, Collection<Object[]> documents) throws IndexException {
if (relation == null)
throw new IllegalArgumentException("null relation");
// 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);
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();