import org.simantics.db.service.QueryControl;
import org.simantics.db.service.SerialisationSupport;
import org.simantics.utils.datastructures.Pair;
import org.simantics.db.service.QueryControl;
import org.simantics.db.service.SerialisationSupport;
import org.simantics.utils.datastructures.Pair;
Map<Object, RWLock> indexLocks = new WeakHashMap<Object, RWLock>();
static class LockHandle {
Map<Object, RWLock> indexLocks = new WeakHashMap<Object, RWLock>();
static class LockHandle {
@Override
public void insert(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation,
@Override
public void insert(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation,
if(!searcher.startAccess(null, processor.getSession(), true)) {
// Could not write index for some reason. Ignore and let the next index query reinitialize the index.
return;
}
searcher.insertIndex(progress.newChild(40), relation, 1, documents);
if(!searcher.startAccess(null, processor.getSession(), true)) {
// Could not write index for some reason. Ignore and let the next index query reinitialize the index.
return;
}
searcher.insertIndex(progress.newChild(40), relation, 1, documents);
@Override
public void remove(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation,
@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 {
LockHandle handle = lock(processor, Pair.make(relationResource, input), true);
try {
LockHandle handle = lock(processor, Pair.make(relationResource, input), true);
try {
if(!searcher.startAccess(null, processor.getSession(), true)) {
// Could not write index for some reason. Ignore and let the next index query reinitialize the index.
return;
}
searcher.removeIndex(progress.newChild(40), relation, processor, key, keyValues);
if(!searcher.startAccess(null, processor.getSession(), true)) {
// Could not write index for some reason. Ignore and let the next index query reinitialize the index.
return;
}
searcher.removeIndex(progress.newChild(40), relation, processor, key, keyValues);
@Override
public boolean replace(IProgressMonitor monitor, RequestProcessor processor, GenericRelation 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(!searcher.startAccess(null, processor.getSession(), true)) {
// Could not write index for some reason. Ignore and let the next index query reinitialize the index.
return true;
}
if(!searcher.startAccess(null, processor.getSession(), true)) {
// Could not write index for some reason. Ignore and let the next index query reinitialize the index.
return true;
}
- didChange = searcher.replaceIndex(progress.newChild(40), key, keyValues, relation, 1, documents);
- if(didChange)
- DatabaseIndexing.markIndexChanged(searcher.getIndexPath());
+ didChange |= searcher.replaceIndex(progress.newChild(40), key, keyValues, relation, 1, documents);
IndexedRelationsSearcherBase searcher = makeSearcher(processor, relationResource, input);
LockHandle handle = lock(processor, Pair.make(relationResource, input), true);
IndexedRelationsSearcherBase searcher = makeSearcher(processor, relationResource, input);
LockHandle handle = lock(processor, Pair.make(relationResource, input), true);
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");
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");