public class IncQueryEngineImpl extends AdvancedIncQueryEngine implements IQueryBackendHintProvider, IQueryCacheContext
DEFAULT| Constructor and Description | 
|---|
IncQueryEngineImpl(IncQueryEngineManager manager,
                  IncQueryScope scope)  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addLifecycleListener(IncQueryEngineLifecycleListener listener)
Add an engine lifecycle listener to this engine instance. 
 | 
<Match extends IPatternMatch> | 
addMatchUpdateListener(IncQueryMatcher<Match> matcher,
                      IMatchUpdateListener<? super Match> listener,
                      boolean fireNow)
Registers low-level callbacks for match appearance and disappearance on this pattern matcher. 
 | 
void | 
addModelUpdateListener(IncQueryModelUpdateListener listener)
Add an model update event listener to this engine instance (that fires its callbacks according to its
 notification level). 
 | 
void | 
dispose()
Completely disconnects and dismantles the engine. 
 | 
IBaseIndex | 
getBaseIndex()
Provides access to the internal base index component of the engine, responsible for keeping track of basic
 contents of the model. 
 | 
IQueryResultProvider | 
getCachingResultProvider(PQuery query)
Returns a caching result provider for the given query; it must be constructed if it does not exist yet. 
 | 
java.util.Set<? extends IncQueryMatcher<? extends IPatternMatch>> | 
getCurrentMatchers()
Access a copy of available  
IncQueryMatcher pattern matchers. | 
org.eclipse.emf.common.notify.Notifier | 
getEMFRoot()  | 
<Matcher extends IncQueryMatcher<? extends IPatternMatch>> | 
getExistingMatcher(IQuerySpecification<Matcher> querySpecification)
Access an existing pattern matcher based on a  
IQuerySpecification. | 
java.util.Map<java.lang.String,java.lang.Object> | 
getHints(PQuery query)
Suggests query evaluation hints regarding a query. 
 | 
org.apache.log4j.Logger | 
getLogger()  | 
<Matcher extends IncQueryMatcher<? extends IPatternMatch>> | 
getMatcher(IQuerySpecification<Matcher> querySpecification)
Access a pattern matcher based on a  
IQuerySpecification. | 
<Matcher extends IncQueryMatcher<? extends IPatternMatch>> | 
getMatcher(IQuerySpecification<Matcher> querySpecification,
          QueryEvaluationHint optionalEvaluationHints)
Access a pattern matcher based on a  
IQuerySpecification, overriding some of the default query evaluation hints. | 
IncQueryMatcher<? extends IPatternMatch> | 
getMatcher(java.lang.String patternFQN)
Access a pattern matcher for the graph pattern with the given fully qualified name. 
 | 
IQueryBackend | 
getQueryBackend(java.lang.Class<? extends IQueryBackend> backendClass)
Provides access to the selected query backend component of the IncQuery engine. 
 | 
IQueryResultProvider | 
getResultProvider(IQuerySpecification<?> query)
Returns an internal interface towards the query backend to feed the matcher with results. 
 | 
IncQueryScope | 
getScope()  | 
boolean | 
isManaged()
Indicates whether the engine is managed, i.e. 
 | 
boolean | 
isResultCached(PQuery query)
Checks if there already is a caching result provider for the given query. 
 | 
boolean | 
isTainted()
Indicates whether the engine is in a tainted, inconsistent state due to some internal errors. 
 | 
void | 
prepareGroup(IQueryGroup queryGroup,
            QueryEvaluationHint optionalEvaluationHints)
Initializes matchers for a group of patterns as one step (optionally overriding some of the default query evaluation hints). 
 | 
void | 
removeLifecycleListener(IncQueryEngineLifecycleListener listener)
Remove an existing lifecycle listener from this engine instance. 
 | 
<Match extends IPatternMatch> | 
removeMatchUpdateListener(IncQueryMatcher<Match> matcher,
                         IMatchUpdateListener<? super Match> listener)
Remove an existing match update event listener to this engine instance. 
 | 
void | 
removeModelUpdateListener(IncQueryModelUpdateListener listener)
Remove an existing model update event listener to this engine instance. 
 | 
void | 
reportMatcherInitialized(IQuerySpecification<?> querySpecification,
                        IncQueryMatcher<?> matcher)
Report when a pattern matcher has been completely initialized, so that it can be registered into the engine. 
 | 
void | 
wipe()
Discards any pattern matcher caches and forgets known patterns. 
 | 
createUnmanagedEngine, createUnmanagedEngine, createUnmanagedEngine, createUnmanagedEngine, createUnmanagedEngine, fromgetRegisteredQuerySpecifications, on, onpublic IncQueryEngineImpl(IncQueryEngineManager manager, IncQueryScope scope) throws IncQueryException
manager - null if unmanagedscope - IncQueryException - if the emf root is invalidpublic org.eclipse.emf.common.notify.Notifier getEMFRoot()
getEMFRoot in class IncQueryEnginepublic java.util.Set<? extends IncQueryMatcher<? extends IPatternMatch>> getCurrentMatchers()
IncQueryEngineIncQueryMatcher pattern matchers.getCurrentMatchers in class IncQueryEnginepublic <Matcher extends IncQueryMatcher<? extends IPatternMatch>> Matcher getMatcher(IQuerySpecification<Matcher> querySpecification) throws IncQueryException
IncQueryEngineIQuerySpecification. 
 Multiple calls will return the same matcher.getMatcher in class IncQueryEnginequerySpecification - a IQuerySpecification that describes an IncQuery queryIncQueryException - if the matcher could not be initializedpublic <Matcher extends IncQueryMatcher<? extends IPatternMatch>> Matcher getMatcher(IQuerySpecification<Matcher> querySpecification, QueryEvaluationHint optionalEvaluationHints) throws IncQueryException
AdvancedIncQueryEngineIQuerySpecification, overriding some of the default query evaluation hints. 
 Multiple calls will return the same matcher.
 Hints are only effective the first time a matcher is created.
getMatcher in class AdvancedIncQueryEnginequerySpecification - a IQuerySpecification that describes an IncQuery queryoptionalEvaluationHints - additional / overriding options on query evaluation; passing null means default options associated with the queryIncQueryException - if the matcher could not be initializedpublic <Matcher extends IncQueryMatcher<? extends IPatternMatch>> Matcher getExistingMatcher(IQuerySpecification<Matcher> querySpecification)
IncQueryEngineIQuerySpecification.getExistingMatcher in class IncQueryEnginequerySpecification - a IQuerySpecification that describes an IncQuery querynull if a matcher does not exist yet.public IncQueryMatcher<? extends IPatternMatch> getMatcher(java.lang.String patternFQN) throws IncQueryException
IncQueryEnginegetMatcher in class IncQueryEnginepatternFQN - the fully qualified name of an IncQuery graph patternIncQueryException - if the matcher could not be initializedpublic IBaseIndex getBaseIndex() throws IncQueryException
IncQueryEngineIf using an EMFScope, 
  consider EMFScope.extractUnderlyingEMFIndex(IncQueryEngine) instead to access EMF-specific details.
getBaseIndex in class IncQueryEngineIncQueryException - if the base index could not be constructedpublic final org.apache.log4j.Logger getLogger()
public void reportMatcherInitialized(IQuerySpecification<?> querySpecification, IncQueryMatcher<?> matcher)
querySpecification - the IQuerySpecification that corresponds to the matchermatcher - the IncQueryMatcher that has finished its initialization process
 
 TODO make it package-only visible when implementation class is moved to impl packagepublic IQueryBackend getQueryBackend(java.lang.Class<? extends IQueryBackend> backendClass) throws IncQueryException
getQueryBackend in class AdvancedIncQueryEngineIncQueryExceptionpublic void dispose()
AdvancedIncQueryEngineMatcher objects will continue to return stale results. If no references are retained to the matchers or the engine, they can eventually be GC'ed, and they won't block the EMF model from being GC'ed anymore.
 The base indexer (see IncQueryEngine.getBaseIndex()) built on the model will be disposed alongside the engine, unless
 the user has manually added listeners on the base index that were not removed yet.
 
 Disallowed if the engine is managed (see AdvancedIncQueryEngine.isManaged()), as there may be other clients using it.
 
 If you explicitly share a private, unmanaged engine between multiple sites, register a callback using
 AdvancedIncQueryEngine.addLifecycleListener(IncQueryEngineLifecycleListener) to learn when another client has called this
 destructive method.
dispose in class AdvancedIncQueryEnginepublic void wipe()
AdvancedIncQueryEngineMatcher objects will continue to return stale results. If no references are retained to the matchers, they can eventually be GC'ed.
 Disallowed if the engine is managed (see AdvancedIncQueryEngine.isManaged()), as there may be other clients using it.
 
 If you explicitly share a private, unmanaged engine between multiple sites, register a callback using
 AdvancedIncQueryEngine.addLifecycleListener(IncQueryEngineLifecycleListener) to learn when another client has called this
 destructive method.
wipe in class AdvancedIncQueryEnginepublic boolean isTainted()
AdvancedIncQueryEngine
 The engine is in a tainted state if any of its internal processes report back a fatal error. The
 IncQueryEngineLifecycleListener interface provides a callback method for entering the tainted state.
isTainted in class AdvancedIncQueryEnginepublic boolean isManaged()
AdvancedIncQueryEngineIncQueryEngine.on(IncQueryScope).
 
 
 If the engine is managed, there may be other clients using it, as all calls to
 IncQueryEngine.on(IncQueryScope) return the same managed engine instance for a given scope root. Therefore the
 destructive methods AdvancedIncQueryEngine.wipe() and AdvancedIncQueryEngine.dispose() are not allowed.
 
 
 On the other hand, if the engine is unmanaged (i.e. a private instance created using
 AdvancedIncQueryEngine.createUnmanagedEngine(IncQueryScope)), then AdvancedIncQueryEngine.wipe() and AdvancedIncQueryEngine.dispose() can be called. If you
 explicitly share a private, unmanaged engine between multiple sites, register a callback using
 AdvancedIncQueryEngine.addLifecycleListener(IncQueryEngineLifecycleListener) to learn when another client has called these
 destructive methods.
isManaged in class AdvancedIncQueryEnginepublic <Match extends IPatternMatch> void addMatchUpdateListener(IncQueryMatcher<Match> matcher, IMatchUpdateListener<? super Match> listener, boolean fireNow)
AdvancedIncQueryEngineCaution: This is a low-level callback that is invoked when the pattern matcher is not necessarily in a consistent state yet. Importantly, no model modification permitted during the callback. Most users should use the databinding support (org.eclipse.incquery.databinding.runtime.api.IncQueryObservables) or the event-driven API (org.eclipse.incquery.runtime.evm.api.EventDrivenVM) instead.
 Performance note: expected to be much more efficient than polling at #addCallbackAfterUpdates(Runnable),
 but prone to "signal hazards", e.g. spurious match appearances that will disappear immediately afterwards.
 
 
 The callback can be unregistered via #removeCallbackOnMatchUpdate(IMatchUpdateListener).
addMatchUpdateListener in class AdvancedIncQueryEnginematcher - the IncQueryMatcher for which this listener should be activelistener - the listener that will be notified of each new match that appears or disappears, starting from now.fireNow - if true, appearCallback will be immediately invoked on all current matches as a one-time effect. See
            also IncQueryMatcher.forEachMatch(IMatchProcessor).public <Match extends IPatternMatch> void removeMatchUpdateListener(IncQueryMatcher<Match> matcher, IMatchUpdateListener<? super Match> listener)
AdvancedIncQueryEngineremoveMatchUpdateListener in class AdvancedIncQueryEnginematcher - the IncQueryMatcher for which this listener should not be active anymorelistener - the IMatchUpdateListener that should not receive the callbacks anymorepublic void addModelUpdateListener(IncQueryModelUpdateListener listener)
AdvancedIncQueryEngineaddModelUpdateListener in class AdvancedIncQueryEnginelistener - the IncQueryModelUpdateListener that should listen to model update events from this engine.public void removeModelUpdateListener(IncQueryModelUpdateListener listener)
AdvancedIncQueryEngineremoveModelUpdateListener in class AdvancedIncQueryEnginelistener - the IncQueryModelUpdateListener that should not listen to model update events from this engine
            anymorepublic void addLifecycleListener(IncQueryEngineLifecycleListener listener)
AdvancedIncQueryEngineaddLifecycleListener in class AdvancedIncQueryEnginelistener - the IncQueryEngineLifecycleListener that should listen to lifecycle events from this enginepublic void removeLifecycleListener(IncQueryEngineLifecycleListener listener)
AdvancedIncQueryEngineremoveLifecycleListener in class AdvancedIncQueryEnginelistener - the IncQueryEngineLifecycleListener that should not listen to lifecycle events from this
            engine anymorepublic IQueryResultProvider getResultProvider(IQuerySpecification<?> query) throws QueryProcessingException, IncQueryException
query - the pattern for which the result provider should be deliveredQueryProcessingExceptionIncQueryExceptionpublic boolean isResultCached(PQuery query)
IQueryCacheContextReturns false if called while the caching result provider of the given query is being constructed in the first place.
isResultCached in interface IQueryCacheContextpublic IQueryResultProvider getCachingResultProvider(PQuery query) throws QueryProcessingException
IQueryCacheContextCaution: behavior undefined if called while the caching result provider of the given query is being constructed. Beware of infinite loops.
 Postcondition: IQueryBackend.isCaching() returns true for the #getQueryBackend() of the returned provider
getCachingResultProvider in interface IQueryCacheContextQueryProcessingExceptionpublic java.util.Map<java.lang.String,java.lang.Object> getHints(PQuery query)
IQueryBackendHintProvidergetHints in interface IQueryBackendHintProviderpublic void prepareGroup(IQueryGroup queryGroup, QueryEvaluationHint optionalEvaluationHints) throws IncQueryException
AdvancedIncQueryEngineThis preparation step has the advantage that it prepares pattern matchers for an arbitrary number of patterns in a single-pass traversal of the model. This is typically more efficient than traversing the model each time an individual pattern matcher is initialized on demand. The performance benefit only manifests itself if the engine is not in wildcard mode.
prepareGroup in class AdvancedIncQueryEnginequeryGroup - a IQueryGroup identifying a set of IncQuery queriesoptionalEvaluationHints - additional / overriding options on query evaluation; passing null means default options associated with each queryIncQueryException - if there was an error in preparing the enginepublic IncQueryScope getScope()
getScope in class IncQueryEngine