public class ReteEngine extends java.lang.Object implements IQueryBackend
Modifier and Type | Field and Description |
---|---|
protected ReteBoundary |
boundary |
protected ReteRecipeCompiler |
compiler |
protected boolean |
deleteAndRederiveEvaluation |
protected java.util.Collection<Disconnectable> |
disconnectables |
protected java.util.Map<PQuery,RetePatternMatcher> |
matchers |
protected boolean |
parallelExecutionEnabled |
protected Network |
reteNet |
protected int |
reteThreads |
protected IQueryRuntimeContext |
runtimeContext |
protected TimelyConfiguration |
timelyConfiguration |
Constructor and Description |
---|
ReteEngine(IQueryBackendContext context,
int reteThreads) |
ReteEngine(IQueryBackendContext context,
int reteThreads,
boolean deleteAndRederiveEvaluation,
TimelyConfiguration timelyConfiguration) |
Modifier and Type | Method and Description |
---|---|
RetePatternMatcher |
accessMatcher(PQuery query)
Accesses the patternmatcher for a given pattern, constructs one if a matcher is not available yet.
|
void |
addDisconnectable(Disconnectable disc) |
void |
buildMatchersCoalesced(java.util.Collection<PQuery> specifications)
Constructs RETE pattern matchers for a collection of patterns, if they are not available yet.
|
<T> T |
constructionWrapper(java.util.concurrent.Callable<T> payload) |
void |
dispose()
Disposes the query backend.
|
void |
executeDelayedCommands() |
void |
flushUpdates()
Propagates all pending updates in this query backend.
|
IQueryBackendContext |
getBackendContext() |
ReteBoundary |
getBoundary() |
ReteRecipeCompiler |
getCompiler() |
IQueryBackendFactory |
getFactory() |
IQueryBackendHintProvider |
getHintConfiguration() |
org.apache.log4j.Logger |
getLogger() |
IQueryResultProvider |
getResultProvider(PQuery query)
Returns a result provider for a given query.
|
IQueryResultProvider |
getResultProvider(PQuery query,
QueryEvaluationHint hints)
Returns a result provider for a given query.
|
Network |
getReteNet() |
IQueryRuntimeContext |
getRuntimeContext() |
TimelyConfiguration |
getTimelyConfiguration() |
boolean |
isCaching() |
boolean |
isDeleteAndRederiveEvaluation() |
boolean |
isParallelExecutionEnabled() |
void |
killEngine()
Deconstructs the engine to get rid of it finally
|
IQueryResultProvider |
peekExistingResultProvider(PQuery query)
Returns an existing result provider for a given query, if it was previously constructed, returns null otherwise.
|
void |
reset()
Resets the engine to an after-initialization phase
|
void |
setCompiler(ReteRecipeCompiler builder) |
void |
settle()
Waits until the pattern matcher is in a steady state and output can be retrieved.
|
void |
settle(java.lang.Runnable action)
Waits until the pattern matcher is in a steady state and output can be retrieved.
|
protected Network reteNet
protected final int reteThreads
protected ReteBoundary boundary
protected final boolean deleteAndRederiveEvaluation
protected final TimelyConfiguration timelyConfiguration
protected IQueryRuntimeContext runtimeContext
protected java.util.Collection<Disconnectable> disconnectables
protected java.util.Map<PQuery,RetePatternMatcher> matchers
protected ReteRecipeCompiler compiler
protected final boolean parallelExecutionEnabled
public ReteEngine(IQueryBackendContext context, int reteThreads)
context
- the context of the pattern matcher, conveying all information from the outside world.reteThreads
- the number of threads to operate the RETE network with; 0 means single-threaded operation, 1 starts an
asynchronous thread to operate the RETE net, >1 uses multiple RETE containers.public ReteEngine(IQueryBackendContext context, int reteThreads, boolean deleteAndRederiveEvaluation, TimelyConfiguration timelyConfiguration)
public IQueryBackendContext getBackendContext()
public boolean isDeleteAndRederiveEvaluation()
public TimelyConfiguration getTimelyConfiguration()
public void flushUpdates()
IQueryBackend
flushUpdates
in interface IQueryBackend
public void killEngine()
public void reset()
public RetePatternMatcher accessMatcher(PQuery query)
query
- the pattern to be matched.ViatraQueryRuntimeException
- if construction fails.public void buildMatchersCoalesced(java.util.Collection<PQuery> specifications)
specifications
- the patterns to be matched.ViatraQueryRuntimeException
- if construction fails.public <T> T constructionWrapper(java.util.concurrent.Callable<T> payload)
public void executeDelayedCommands()
public void settle()
public void settle(java.lang.Runnable action)
action
- the action to be run when reaching the steady-state.public Network getReteNet()
public ReteBoundary getBoundary()
public void setCompiler(ReteRecipeCompiler builder)
builder
- the pattern matcher builder to setpublic void addDisconnectable(Disconnectable disc)
disc
- the new Disconnectable adapter.public boolean isParallelExecutionEnabled()
public org.apache.log4j.Logger getLogger()
public IQueryRuntimeContext getRuntimeContext()
public ReteRecipeCompiler getCompiler()
public IQueryResultProvider getResultProvider(PQuery query)
IQueryBackend
getResultProvider
in interface IQueryBackend
public IQueryResultProvider getResultProvider(PQuery query, QueryEvaluationHint hints)
IQueryBackend
getResultProvider
in interface IQueryBackend
public IQueryResultProvider peekExistingResultProvider(PQuery query)
IQueryBackend
peekExistingResultProvider
in interface IQueryBackend
public void dispose()
IQueryBackend
dispose
in interface IQueryBackend
public boolean isCaching()
isCaching
in interface IQueryBackend
public IQueryBackendHintProvider getHintConfiguration()
public IQueryBackendFactory getFactory()
getFactory
in interface IQueryBackend