public class LPBRuleEngine extends Object
Modifier and Type | Field and Description |
---|---|
static int |
CYCLES_BETWEEN_COMPLETION_CHECK
The number of generator cycles to wait before running a completion check.
|
Constructor and Description |
---|
LPBRuleEngine(BackwardRuleInfGraphI infGraph)
Constructor.
|
LPBRuleEngine(BackwardRuleInfGraphI infGraph,
LPRuleStore rules)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addRule(Rule rule)
Add a single rule to the store.
|
void |
checkForCompletions()
Check all known interpeter contexts to see if any are complete.
|
void |
checkSafeToUpdate()
Check that there are no currently processing queries.
|
void |
deleteAllRules()
Delete all the rules.
|
void |
deleteRule(Rule rule)
Remove a single rule from the store.
|
void |
detach(LPInterpreter engine)
Detach the given engine from the list of active engines for this inf graph
|
ExtendedIterator<Triple> |
find(TriplePattern goal)
Start a new interpreter running to answer a query.
|
Generator |
generatorFor(TriplePattern goal)
Return a generator for the given goal (assumes that the caller knows that
the goal should be tabled).
|
Generator |
generatorFor(TriplePattern goal,
List<RuleClauseCode> clauses)
Return a generator for the given goal (assumes that the caller knows that
the goal should be tabled).
|
List<Rule> |
getAllRules()
Return an ordered list of all registered rules.
|
boolean |
getDerivationLogging()
Return true in derivations should be logged.
|
BackwardRuleInfGraphI |
getInfGraph()
Return the parent inference graph associated with this engine
|
LPRuleStore |
getRuleStore()
Return the rule store associated with the inference graph
|
void |
halt()
Stop the current work.
|
void |
incrementProfile(RuleClauseCode clause)
Record a rule invocation in the profile count.
|
boolean |
isTraceOn()
Return true if traces of rule firings should be logged.
|
void |
printProfile()
Print a profile of rules used since the last reset.
|
void |
pump(LPInterpreterContext gen)
Run the scheduled generators until the given generator is ready to run.
|
void |
reset()
Clear all tabled results.
|
void |
resetProfile(boolean enable)
Reset the profile.
|
void |
schedule(LPAgendaEntry state)
Register that a generator or specific generator state (Consumer choice point)
is now ready to run.
|
void |
setDerivationLogging(boolean recordDerivations)
Set to true to enable derivation caching
|
void |
setTraceOn(boolean state)
Set the state of the trace flag.
|
void |
tablePredicate(Node predicate)
Register an RDF predicate as one whose presence in a goal should force
the goal to be tabled.
|
public static final int CYCLES_BETWEEN_COMPLETION_CHECK
public LPBRuleEngine(BackwardRuleInfGraphI infGraph, LPRuleStore rules)
infGraph
- the parent inference graph which is using this enginerules
- the indexed set of rules to processpublic LPBRuleEngine(BackwardRuleInfGraphI infGraph)
infGraph
- the parent inference graph which is using this enginepublic ExtendedIterator<Triple> find(TriplePattern goal)
goal
- the query to be processedpublic void reset()
public void addRule(Rule rule)
public void deleteRule(Rule rule)
public void deleteAllRules()
public void halt()
public void setTraceOn(boolean state)
public boolean isTraceOn()
public void setDerivationLogging(boolean recordDerivations)
public boolean getDerivationLogging()
public LPRuleStore getRuleStore()
public BackwardRuleInfGraphI getInfGraph()
public void detach(LPInterpreter engine)
public void checkSafeToUpdate()
Should be called from within a synchronized block.
public void tablePredicate(Node predicate)
public Generator generatorFor(TriplePattern goal, List<RuleClauseCode> clauses)
goal
exists in the
cache, it will be returned without considering the provided clauses
.goal
- the goal whose results are to be generatedclauses
- the precomputed set of code blocks used to implement the goalpublic Generator generatorFor(TriplePattern goal)
goal
- the goal whose results are to be generatedpublic void schedule(LPAgendaEntry state)
public void pump(LPInterpreterContext gen)
public void checkForCompletions()
public void incrementProfile(RuleClauseCode clause)
public void resetProfile(boolean enable)
enable
- it true then profiling will continue with a new empty profile table,
if false profiling will stop all current data lost.public void printProfile()
Licenced under the Apache License, Version 2.0