| java.lang.Object com.hp.hpl.jena.reasoner.rulesys.impl.RETEEngine
RETEEngine | public class RETEEngine implements FRuleEngineI(Code) | | A RETE version of the the forward rule system engine. It neeeds to reference
an enclosing ForwardInfGraphI which holds the raw data and deductions.
author: Dave Reynolds version: $Revision: 1.30 $ on $Date: 2008/01/02 12:06:16 $ |
Inner Class :protected static class ClausePointer | |
Inner Class :public static class RuleStore | |
Method Summary | |
public synchronized 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. | public synchronized void | addTriple(Triple triple, boolean deduction) Add a new triple to the network. | public void | compile(List rules, boolean ignoreBrules) Compile a list of rules into the internal rule store representation. | protected RETETerminal | createTerminal(Rule rule) Create a terminal node for the RETE network. | public synchronized boolean | delete(Triple t) Remove one triple to the data graph. | public synchronized void | deleteTriple(Triple triple, boolean deduction) Remove a new triple from the network. | public void | fastInit(Finder inserts) Process all available data. | protected void | findAndProcessActions() | protected void | findAndProcessAxioms() | public long | getNRulesFired() | public Object | getRuleStore() Access the precomputed internal rule form. | protected void | incRuleCount() Increment the rule firing count, called by the terminal nodes in the
network. | public void | init(boolean ignoreBrules, Finder inserts) Process all available data. | protected synchronized Triple | nextAddTriple() Find the next pending add triple. | protected synchronized Triple | nextDeleteTriple() Find the next pending add triple. | public void | requestRuleFiring(Rule rule, BindingEnvironment env, boolean isAdd) Add a rule firing request to the conflict set. | public void | runAll() Process the queue of pending insert/deletes until the queues are empty. | public void | setDerivationLogging(boolean recordDerivations) | public void | setRuleStore(Object ruleStore) Set the internal rule from from a precomputed state. | public boolean | shouldTrace() Return true if the internal engine state means that tracing is worthwhile. | public void | testTripleInsert(Triple t) This fires a triple into the current RETE network. |
addsPending | protected List addsPending(Code) | | Queue of newly added triples waiting to be processed
|
clauseIndex | protected OneToManyMap clauseIndex(Code) | | Map from predicate node to clause processor, Node_ANY is used for wildcard predicates
|
deletesPending | protected List deletesPending(Code) | | Queue of newly deleted triples waiting to be processed
|
isMonotonic | boolean isMonotonic(Code) | | True if all the rules are monotonic, so we short circuit the conflict set processing
|
logger | protected static Log logger(Code) | | |
nRulesFired | long nRulesFired(Code) | | performance stats - number of rules fired
|
predicatesUsed | protected HashSet predicatesUsed(Code) | | List of predicates used in rules to assist in fast data loading
|
processedAxioms | boolean processedAxioms(Code) | | True if we have processed the axioms in the rule set
|
recordDerivations | protected boolean recordDerivations(Code) | | Set to true to flag that derivations should be logged
|
rules | protected List rules(Code) | | Set of rules being used
|
wildcardRule | protected boolean wildcardRule(Code) | | Flag, if true then there is a wildcard predicate in the rule set so that selective insert is not useful
|
RETEEngine | public RETEEngine(ForwardRuleInfGraphI parent, List rules)(Code) | | Constructor.
Parameters: parent - the F or FB infGraph that it using this engine, the parent graphholds the deductions graph and source data. Parameters: rules - the rule set to be processed |
RETEEngine | public RETEEngine(ForwardRuleInfGraphI parent)(Code) | | Constructor. Build an empty engine to which rules must be added
using setRuleStore().
Parameters: parent - the F or FB infGraph that it using this engine, the parent graphholds the deductions graph and source data. |
add | public synchronized void add(Triple t)(Code) | | Add one triple to the data graph, run any rules triggered by
the new data item, recursively adding any generated triples.
|
addTriple | public synchronized void addTriple(Triple triple, boolean deduction)(Code) | | Add a new triple to the network.
Parameters: triple - the new triple Parameters: deduction - true if the triple has been generated by the rules and so should be added to the deductions graph. |
compile | public void compile(List rules, boolean ignoreBrules)(Code) | | Compile a list of rules into the internal rule store representation.
Parameters: rules - the list of Rule objects Parameters: ignoreBrules - set to true if rules written in backward notation should be ignored |
createTerminal | protected RETETerminal createTerminal(Rule rule)(Code) | | Create a terminal node for the RETE network. Normally this is RETETerminal
but some people have experimented with alternative delete handling by
creating RETETerminal subclasses so this hook simplifies use of that
approach.
|
delete | public synchronized boolean delete(Triple t)(Code) | | Remove one triple to the data graph.
true if the effects could be correctly propagated orfalse if not (in which case the entire engine should be restarted). |
deleteTriple | public synchronized void deleteTriple(Triple triple, boolean deduction)(Code) | | Remove a new triple from the network.
Parameters: triple - the new triple Parameters: deduction - true if the remove has been generated by the rules |
fastInit | public void fastInit(Finder inserts)(Code) | | Process all available data. This version expects that all the axioms
have already be preprocessed and the clause index already exists.
Parameters: inserts - the set of triples to be processed, normally this is theraw data graph but may include additional deductions made by preprocessing hooks |
findAndProcessActions | protected void findAndProcessActions()(Code) | | Scan the rules for any run actions and run those
|
findAndProcessAxioms | protected void findAndProcessAxioms()(Code) | | Scan the rules for any axioms and insert those
|
getNRulesFired | public long getNRulesFired()(Code) | | Return the number of rules fired since this rule engine instance
was created and initialized
|
getRuleStore | public Object getRuleStore()(Code) | | Access the precomputed internal rule form. Used when precomputing the
internal axiom closures.
|
incRuleCount | protected void incRuleCount()(Code) | | Increment the rule firing count, called by the terminal nodes in the
network.
|
init | public void init(boolean ignoreBrules, Finder inserts)(Code) | | Process all available data. This should be called once a deductions graph
has be prepared and loaded with any precomputed deductions. It will process
the rule axioms and all relevant existing exiting data entries.
Parameters: ignoreBrules - set to true if rules written in backward notation should be ignored Parameters: inserts - the set of triples to be processed, normally this is theraw data graph but may include additional deductions made by preprocessing hooks |
nextAddTriple | protected synchronized Triple nextAddTriple()(Code) | | Find the next pending add triple.
the triple or null if there are none left. |
nextDeleteTriple | protected synchronized Triple nextDeleteTriple()(Code) | | Find the next pending add triple.
the triple or null if there are none left. |
requestRuleFiring | public void requestRuleFiring(Rule rule, BindingEnvironment env, boolean isAdd)(Code) | | Add a rule firing request to the conflict set.
|
runAll | public void runAll()(Code) | | Process the queue of pending insert/deletes until the queues are empty.
Public to simplify unit tests - not normally called directly.
|
setDerivationLogging | public void setDerivationLogging(boolean recordDerivations)(Code) | | Set to true to enable derivation caching
|
setRuleStore | public void setRuleStore(Object ruleStore)(Code) | | Set the internal rule from from a precomputed state.
|
shouldTrace | public boolean shouldTrace()(Code) | | Return true if the internal engine state means that tracing is worthwhile.
It will return false during the axiom bootstrap phase.
|
testTripleInsert | public void testTripleInsert(Triple t)(Code) | | This fires a triple into the current RETE network.
This format of call is used in the unit testing but needs to be public
because the tester is in another package.
|
|
|