Class 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 Detail

      • LPInterpreter

        public LPInterpreter​(LPBRuleEngine engine,
                             TriplePattern goal)
        Constructor used to construct top level calls.
        Parameters:
        engine - the engine which is calling this interpreter
        goal - the query to be satisfied
      • LPInterpreter

        public LPInterpreter​(LPBRuleEngine engine,
                             TriplePattern goal,
                             boolean isTop)
        Constructor.
        Parameters:
        engine - the engine which is calling this interpreter
        goal - the query to be satisfied
        isTop - 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 interpreter
        goal - the query to be satisfied
        clauses - the set of code blocks needed to implement this goal
        isTop - 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 bound
        val - the value to bind to it
      • unwindTrail

        public void unwindTrail​(int mark)
        Unwind the trail to given low water mark
      • deref

        public static Node deref​(Node node)
        Dereference a node, following any binding trail.
      • 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.
      • derefPossFunctor

        public static Node derefPossFunctor​(Node node)
        Dereference a node which may be a functor node