public class RETEEngine extends Object implements FRuleEngineI
Modifier and Type | Class and Description |
---|---|
static class |
RETEEngine.RuleStore
Structure used to wrap up processed rule indexes.
|
Constructor and Description |
---|
RETEEngine(ForwardRuleInfGraphI parent)
Constructor.
|
RETEEngine(ForwardRuleInfGraphI parent,
List<Rule> rules)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Triple t)
Add one triple to the data graph, run any rules triggered by
the new data item, recursively adding any generated triples.
|
void |
addTriple(Triple triple,
boolean deduction)
Add a new triple to the network.
|
void |
compile(List<Rule> rules,
boolean ignoreBrules)
Compile a list of rules into the internal rule store representation.
|
boolean |
delete(Triple t)
Remove one triple to the data graph.
|
void |
deleteTriple(Triple triple,
boolean deduction)
Remove a new triple from the network.
|
void |
fastInit(Finder inserts)
Process all available data.
|
long |
getNRulesFired()
Return the number of rules fired since this rule engine instance
was created and initialized
|
Object |
getRuleStore()
Access the precomputed internal rule form.
|
void |
init(boolean ignoreBrules,
Finder inserts)
Process all available data.
|
void |
requestRuleFiring(Rule rule,
BindingEnvironment env,
boolean isAdd)
Add a rule firing request to the conflict set.
|
void |
runAll()
Process the queue of pending insert/deletes until the queues are empty.
|
void |
setDerivationLogging(boolean recordDerivations)
Set to true to enable derivation caching
|
void |
setRuleStore(Object ruleStore)
Set the internal rule from a precomputed state.
|
boolean |
shouldTrace()
Return true if the internal engine state means that tracing is worthwhile.
|
void |
testTripleInsert(Triple t)
This fires a triple into the current RETE network.
|
public RETEEngine(ForwardRuleInfGraphI parent, List<Rule> rules)
parent
- the F or FB infGraph that it using this engine, the parent graph
holds the deductions graph and source data.rules
- the rule set to be processedpublic RETEEngine(ForwardRuleInfGraphI parent)
parent
- the F or FB infGraph that it using this engine, the parent graph
holds the deductions graph and source data.public void init(boolean ignoreBrules, Finder inserts)
init
in interface FRuleEngineI
ignoreBrules
- set to true if rules written in backward notation should be ignoredinserts
- the set of triples to be processed, normally this is the
raw data graph but may include additional deductions made by preprocessing hookspublic void fastInit(Finder inserts)
fastInit
in interface FRuleEngineI
inserts
- the set of triples to be processed, normally this is the
raw data graph but may include additional deductions made by preprocessing hookspublic void add(Triple t)
add
in interface FRuleEngineI
public boolean delete(Triple t)
delete
in interface FRuleEngineI
public long getNRulesFired()
getNRulesFired
in interface FRuleEngineI
public boolean shouldTrace()
shouldTrace
in interface FRuleEngineI
public void setDerivationLogging(boolean recordDerivations)
setDerivationLogging
in interface FRuleEngineI
public Object getRuleStore()
getRuleStore
in interface FRuleEngineI
public void setRuleStore(Object ruleStore)
setRuleStore
in interface FRuleEngineI
public void requestRuleFiring(Rule rule, BindingEnvironment env, boolean isAdd)
public void compile(List<Rule> rules, boolean ignoreBrules)
rules
- the list of Rule objectsignoreBrules
- set to true if rules written in backward notation should be ignoredpublic void addTriple(Triple triple, boolean deduction)
triple
- the new triplededuction
- true if the triple has been generated by the rules and so should be
added to the deductions graph.public void deleteTriple(Triple triple, boolean deduction)
triple
- the new triplededuction
- true if the remove has been generated by the rulespublic void runAll()
public void testTripleInsert(Triple t)
Licenced under the Apache License, Version 2.0