blob: 133c4c722acc8beb84201537bc8248fa615687e8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package tools.refinery.store.query.viatra.internal;
import org.apache.log4j.Logger;
import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
import org.eclipse.viatra.query.runtime.api.scope.IEngineContext;
import org.eclipse.viatra.query.runtime.api.scope.IIndexingErrorListener;
import org.eclipse.viatra.query.runtime.api.scope.QueryScope;
import tools.refinery.store.model.Model;
import tools.refinery.store.model.representation.Relation;
import tools.refinery.store.query.viatra.internal.context.RelationalEngineContext;
import tools.refinery.store.query.viatra.internal.viewupdate.ModelUpdateListener;
import tools.refinery.store.query.view.AnyRelationView;
import tools.refinery.store.tuple.Tuple;
import java.util.Set;
public class RelationalScope extends QueryScope {
private final Model model;
private final ModelUpdateListener updateListener;
public RelationalScope(Model model, Set<AnyRelationView> relationViews) {
this.model = model;
this.updateListener = new ModelUpdateListener(relationViews);
}
public <D> void processUpdate(Relation<D> relation, Tuple key, D oldValue, D newValue) {
updateListener.addUpdate(relation, key, oldValue, newValue);
}
public boolean hasChanges() {
return updateListener.hasChanges();
}
public void flush() {
updateListener.flush();
}
@Override
protected IEngineContext createEngineContext(ViatraQueryEngine engine, IIndexingErrorListener errorListener,
Logger logger) {
return new RelationalEngineContext(model, updateListener);
}
}
|