Class LPInterpreter
- java.lang.Object
-
- org.apache.jena.reasoner.rulesys.impl.LPInterpreter
-
public class LPInterpreter extends java.lang.Object
Bytecode interpreter engine for the LP version of the backward chaining rule system. An instance of this is forked off for each parallel query.
-
-
Constructor Summary
Constructors Constructor Description LPInterpreter(LPBRuleEngine engine, TriplePattern goal)
Constructor used to construct top level calls.LPInterpreter(LPBRuleEngine engine, TriplePattern goal, boolean isTop)
Constructor.LPInterpreter(LPBRuleEngine engine, TriplePattern goal, java.util.List<RuleClauseCode> clauses, boolean isTop)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind(Node var, Node val)
Bind a value to a variable, recording the binding in the trail.void
close()
Stop the current work.static Node
deref(Node node)
Dereference a node, following any binding trail.static Triple
deref(TriplePattern t)
Return a dereferenced copy of a triple.static Node
derefPossFunctor(Node node)
Dereference a node which may be a functor nodeFrameObject
getChoiceFrame()
Return the current choice point frame that can be used to restart the interpter at this point.LPInterpreterContext
getContext()
Return the context in which this interpreter is running, that is either the Generator for a tabled goal or a top level iterator.LPBRuleEngine
getEngine()
Return the engine which owns this interpreter.static boolean
isGrounded(Node node)
Check if a node values is now groundedjava.lang.Object
next()
Return the next result from this engine, no further initialization.void
preserveState(ConsumerChoicePointFrame ccp)
Preserve the current interpter state in the consumer choice point at the top of the choice point tree.void
restoreState(ConsumerChoicePointFrame ccp)
Restore the interpter state according to the given consumer choice point.void
setState(LPInterpreterState state)
Start the interpreter running with the given context.void
setTopInterpreter(LPInterpreterContext context)
Called by top level interpreter to set to execution context for this interpreter to be top level instead of an internal generator.boolean
unify(Node n1, Node n2)
Unify two nodes.void
unwindTrail(int mark)
Unwind the trail to given low water mark
-
-
-
Constructor Detail
-
LPInterpreter
public LPInterpreter(LPBRuleEngine engine, TriplePattern goal)
Constructor used to construct top level calls.- Parameters:
engine
- the engine which is calling this interpretergoal
- the query to be satisfied
-
LPInterpreter
public LPInterpreter(LPBRuleEngine engine, TriplePattern goal, boolean isTop)
Constructor.- Parameters:
engine
- the engine which is calling this interpretergoal
- the query to be satisfiedisTop
- true if this is a top level call from the outside iterator, false means it is an internal generator call which means we don't need to insert an tabled call
-
LPInterpreter
public LPInterpreter(LPBRuleEngine engine, TriplePattern goal, java.util.List<RuleClauseCode> clauses, boolean isTop)
Constructor.- Parameters:
engine
- the engine which is calling this interpretergoal
- the query to be satisfiedclauses
- the set of code blocks needed to implement this goalisTop
- true if this is a top level call from the outside iterator, false means it is an internal generator call which means we don't need to insert an tabled call
-
-
Method Detail
-
setTopInterpreter
public void setTopInterpreter(LPInterpreterContext context)
Called by top level interpreter to set to execution context for this interpreter to be top level instead of an internal generator.
-
close
public void close()
Stop the current work. This is called if the top level results iterator has either finished or the calling application has had enough.
-
setState
public void setState(LPInterpreterState state)
Start the interpreter running with the given context.
-
next
public java.lang.Object next()
Return the next result from this engine, no further initialization. Should be called from within an appropriately synchronized block.
-
getEngine
public LPBRuleEngine getEngine()
Return the engine which owns this interpreter.
-
getChoiceFrame
public FrameObject getChoiceFrame()
Return the current choice point frame that can be used to restart the interpter at this point.
-
getContext
public LPInterpreterContext getContext()
Return the context in which this interpreter is running, that is either the Generator for a tabled goal or a top level iterator.
-
preserveState
public void preserveState(ConsumerChoicePointFrame ccp)
Preserve the current interpter state in the consumer choice point at the top of the choice point tree.
-
restoreState
public void restoreState(ConsumerChoicePointFrame ccp)
Restore the interpter state according to the given consumer choice point.
-
unify
public boolean unify(Node n1, Node n2)
Unify two nodes. Current implementation does not support functors.- Returns:
- true if the unification succeeds
-
bind
public void bind(Node var, Node val)
Bind a value to a variable, recording the binding in the trail.- Parameters:
var
- the dereferenced variable to be boundval
- the value to bind to it
-
unwindTrail
public void unwindTrail(int mark)
Unwind the trail to given low water mark
-
isGrounded
public static boolean isGrounded(Node node)
Check if a node values is now grounded
-
deref
public static Triple deref(TriplePattern t)
Return a dereferenced copy of a triple.
-
-