Package tools.refinery.interpreter.api
Class InterpreterEngine
java.lang.Object
tools.refinery.interpreter.api.InterpreterEngine
- Direct Known Subclasses:
AdvancedInterpreterEngine
A Viatra Query (incremental) evaluation engine, attached to a model such as an EMF resource. The engine hosts pattern matchers, and
will listen on model update notifications stemming from the given model in order to maintain live results.
and
).
By default, ViatraQueryEngines do not need to be separately disposed; they will be garbage collected along with the model.
Advanced users: see AdvancedInterpreterEngine
if you want fine control over the lifecycle of an engine.
Pattern matchers within this engine may be instantiated in the following ways:
- Recommended: instantiate the specific matcher class generated for the pattern by e.g. MyPatternMatcher.on(engine).
- Use
getMatcher(IQuerySpecification)
if the pattern-specific generated matcher API is not available. - Advanced: use the query specification associated with the generated matcher class to achieve the same.
IQueryGroup
) can be initialized together before usage; this may improve
the performance of pattern matcher construction by trying to gather all necessary information from the model in one go.
Note that no such improvement is to be expected if the engine is specifically constructed in wildcard mode,
an option available in some scope implementations
(see
invalid reference
EMFScope#EMFScope(Notifier, BaseIndexOptions)
invalid reference
BaseIndexOptions#withWildcardMode(boolean)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
abstract IBaseIndex
Provides access to the internal base index component of the engine, responsible for keeping track of basic contents of the model.abstract Set
<? extends InterpreterMatcher<? extends IPatternMatch>> Access a copy of availableInterpreterMatcher
pattern matchers.abstract <Matcher extends InterpreterMatcher<? extends IPatternMatch>>
MatchergetExistingMatcher
(IQuerySpecification<Matcher> querySpecification) Access an existing pattern matcher based on aIQuerySpecification
.abstract InterpreterMatcher
<? extends IPatternMatch> getMatcher
(String patternFQN) Access a pattern matcher for the graph pattern with the given fully qualified name.abstract <Matcher extends InterpreterMatcher<? extends IPatternMatch>>
MatchergetMatcher
(IQuerySpecification<Matcher> querySpecification) Access a pattern matcher based on aIQuerySpecification
.Set
<IQuerySpecification<? extends InterpreterMatcher<? extends IPatternMatch>>> abstract QueryScope
getScope()
abstract <T> T
withFlushingChanges
(Supplier<T> supplier)
-
Constructor Details
-
InterpreterEngine
public InterpreterEngine()
-
-
Method Details
-
getBaseIndex
Provides access to the internal base index component of the engine, responsible for keeping track of basic contents of the model.If using an
invalid reference
EMFScope
invalid reference
EMFScope#extractUnderlyingEMFIndex(InterpreterEngine)
- Returns:
- the baseIndex the NavigationHelper maintaining the base index
- Throws:
InterpreterRuntimeException
- if the base index could not be constructed
-
getMatcher
public abstract <Matcher extends InterpreterMatcher<? extends IPatternMatch>> Matcher getMatcher(IQuerySpecification<Matcher> querySpecification) Access a pattern matcher based on aIQuerySpecification
. Multiple calls will return the same matcher.- Parameters:
querySpecification
- aIQuerySpecification
that describes a Refinery Interpreter query specification- Returns:
- a pattern matcher corresponding to the specification
- Throws:
InterpreterRuntimeException
- if the matcher could not be initialized
-
getMatcher
Access a pattern matcher for the graph pattern with the given fully qualified name. Will succeed only if a query specification for this fully qualified name has been generated and registered. Multiple calls will return the same matcher unless the registered specification changes.- Parameters:
patternFQN
- the fully qualified name of a Refinery Interpreter query specification- Returns:
- a pattern matcher corresponding to the specification
- Throws:
InterpreterRuntimeException
- if the matcher could not be initialized
-
getExistingMatcher
public abstract <Matcher extends InterpreterMatcher<? extends IPatternMatch>> Matcher getExistingMatcher(IQuerySpecification<Matcher> querySpecification) Access an existing pattern matcher based on aIQuerySpecification
.- Parameters:
querySpecification
- aIQuerySpecification
that describes a Refinery Interpreter query specification- Returns:
- a pattern matcher corresponding to the specification,
null
if a matcher does not exist yet.
-
getCurrentMatchers
Access a copy of availableInterpreterMatcher
pattern matchers.- Returns:
- a copy of the set of currently available pattern matchers registered on this engine instance
-
getRegisteredQuerySpecifications
public Set<IQuerySpecification<? extends InterpreterMatcher<? extends IPatternMatch>>> getRegisteredQuerySpecifications() -
getScope
- Returns:
- the scope of query evaluation; the definition of the set of model elements that this engine is operates on.
-
flushChanges
public abstract void flushChanges() -
withFlushingChanges
-