public class ReteEngine extends java.lang.Object implements IQueryBackend
Modifier and Type | Field and Description |
---|---|
protected ReteBoundary |
boundary |
protected ReteRecipeCompiler |
compiler |
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 |
Constructor and Description |
---|
ReteEngine(IQueryBackendContext context,
int reteThreads) |
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.
|
void |
dispose()
Disposes the query backend.
|
void |
flushUpdates()
Propagates all pending updates in this query backend.
|
IQueryBackendContext |
getBackendContext() |
ReteBoundary |
getBoundary() |
ReteRecipeCompiler |
getCompiler() |
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() |
boolean |
isCaching() |
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 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 IQueryBackendContext getBackendContext()
public void flushUpdates()
IQueryBackend
flushUpdates
in interface IQueryBackend
public void killEngine()
public void reset()
public RetePatternMatcher accessMatcher(PQuery query) throws QueryProcessingException
query
- the pattern to be matched.RetePatternBuildException
- if construction fails.QueryProcessingException
public void buildMatchersCoalesced(java.util.Collection<PQuery> specifications) throws QueryProcessingException
specifications
- the patterns to be matched.RetePatternBuildException
- if construction fails.QueryProcessingException
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) throws QueryProcessingException
IQueryBackend
getResultProvider
in interface IQueryBackend
QueryProcessingException
public IQueryResultProvider getResultProvider(PQuery query, QueryEvaluationHint hints) throws QueryProcessingException
IQueryBackend
getResultProvider
in interface IQueryBackend
QueryProcessingException
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()