public abstract class ViatraQueryEngine
extends java.lang.Object
By default, ViatraQueryEngines do not need to be separately disposed; they will be garbage collected along with the model.
Advanced users: see AdvancedViatraQueryEngine
if you want fine control over the lifecycle of an engine.
Pattern matchers within this engine may be instantiated in the following ways:
getMatcher(IQuerySpecification)
if the pattern-specific generated matcher API is not available.
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 EMFScope.EMFScope(Notifier, BaseIndexOptions)
and BaseIndexOptions.withWildcardMode(boolean)
).Constructor and Description |
---|
ViatraQueryEngine() |
Modifier and Type | Method and Description |
---|---|
abstract IBaseIndex |
getBaseIndex()
Provides access to the internal base index component of the engine, responsible for keeping track of basic
contents of the model.
|
abstract java.util.Set<? extends ViatraQueryMatcher<? extends IPatternMatch>> |
getCurrentMatchers()
Access a copy of available
ViatraQueryMatcher pattern matchers. |
abstract <Matcher extends ViatraQueryMatcher<? extends IPatternMatch>> |
getExistingMatcher(IQuerySpecification<Matcher> querySpecification)
Access an existing pattern matcher based on a
IQuerySpecification . |
abstract <Matcher extends ViatraQueryMatcher<? extends IPatternMatch>> |
getMatcher(IQuerySpecification<Matcher> querySpecification)
Access a pattern matcher based on a
IQuerySpecification . |
abstract ViatraQueryMatcher<? extends IPatternMatch> |
getMatcher(java.lang.String patternFQN)
Access a pattern matcher for the graph pattern with the given fully qualified name.
|
java.util.Set<IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> |
getRegisteredQuerySpecifications() |
abstract QueryScope |
getScope() |
static ViatraQueryEngine |
on(QueryScope scope)
Obtain a (managed)
ViatraQueryEngine to evaluate queries over a given scope specified by an QueryScope . |
static ViatraQueryEngine |
on(QueryScope scope,
ViatraQueryEngineOptions options)
Obtain a (managed)
ViatraQueryEngine to evaluate queries over a given scope specified by an QueryScope . |
public static ViatraQueryEngine on(QueryScope scope) throws ViatraQueryException
ViatraQueryEngine
to evaluate queries over a given scope specified by an QueryScope
.
For a given matcher scope, the same engine will be returned to any client. This facilitates the reuse of internal caches of the engine, greatly improving performance.
The lifecycle of this engine is centrally managed, and will not be disposed as long as the model is retained in memory. The engine will be garbage collected along with the model.
Advanced users: see AdvancedViatraQueryEngine.createUnmanagedEngine(QueryScope)
to obtain a private,
unmanaged engine that is not shared with other clients and allows tight control over its lifecycle.
scope
- the scope of query evaluation; the definition of the set of model elements that this engine is operates on.
Provide e.g. a EMFScope
for evaluating queries on an EMF model.ViatraQueryEngine
instanceViatraQueryException
- on initialization errors.public static ViatraQueryEngine on(QueryScope scope, ViatraQueryEngineOptions options) throws ViatraQueryException
ViatraQueryEngine
to evaluate queries over a given scope specified by an QueryScope
.
For a given matcher scope, the same engine will be returned to any client. This facilitates the reuse of internal caches of the engine, greatly improving performance.
The lifecycle of this engine is centrally managed, and will not be disposed as long as the model is retained in memory. The engine will be garbage collected along with the model.
Advanced users: see AdvancedViatraQueryEngine.createUnmanagedEngine(QueryScope)
to obtain a private,
unmanaged engine that is not shared with other clients and allows tight control over its lifecycle.
scope
- the scope of query evaluation; the definition of the set of model elements that this engine is operates on.
Provide e.g. a EMFScope
for evaluating queries on an EMF model.ViatraQueryEngine
instanceViatraQueryException
- on initialization errors.public abstract IBaseIndex getBaseIndex() throws ViatraQueryException
If using an EMFScope
,
consider EMFScope.extractUnderlyingEMFIndex(ViatraQueryEngine)
instead to access EMF-specific details.
ViatraQueryException
- if the base index could not be constructedpublic abstract <Matcher extends ViatraQueryMatcher<? extends IPatternMatch>> Matcher getMatcher(IQuerySpecification<Matcher> querySpecification) throws ViatraQueryException
IQuerySpecification
.
Multiple calls will return the same matcher.querySpecification
- a IQuerySpecification
that describes a VIATRA query specificationViatraQueryException
- if the matcher could not be initializedpublic abstract ViatraQueryMatcher<? extends IPatternMatch> getMatcher(java.lang.String patternFQN) throws ViatraQueryException
patternFQN
- the fully qualified name of a VIATRA query specificationViatraQueryException
- if the matcher could not be initializedpublic abstract <Matcher extends ViatraQueryMatcher<? extends IPatternMatch>> Matcher getExistingMatcher(IQuerySpecification<Matcher> querySpecification)
IQuerySpecification
.querySpecification
- a IQuerySpecification
that describes a VIATRA query specificationnull
if a matcher does not exist yet.public abstract java.util.Set<? extends ViatraQueryMatcher<? extends IPatternMatch>> getCurrentMatchers()
ViatraQueryMatcher
pattern matchers.public java.util.Set<IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> getRegisteredQuerySpecifications()
public abstract QueryScope getScope()