Class RETEClauseFilter

  • All Implemented Interfaces:
    RETENode, RETESourceNode

    public class RETEClauseFilter
    extends java.lang.Object
    implements RETESourceNode
    Checks a triple against the grounded matches and intra-triple matches for a single rule clause. If the match passes it creates a binding environment token and passes it on the RETE network itself. The checks and bindings are implemented using a simple byte-coded interpreter.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static byte ADDRFunctorNode
      Argument addressing code: triple object functor node, offset in low nibble, only usable after a successful TestFunctorName.
      static byte ADDRObject
      Argument addressing code: triple object as a whole
      static byte ADDRPredicate
      Argument addressing code: triple predicate
      static byte ADDRSubject
      Argument addressing code: triple subject
      static byte BIND
      Instruction code: Bind a node (arg1) to a place in the rules token (arg2).
      static byte CREATEToken
      Instruction code: Create a result environment of length arg1.
      static byte END
      Instruction code: Final entry - dispatch to the network.
      static byte TESTFunctorName
      Instruction code: Check literal value is a functor of name arg1
      static byte TESTIntraMatch
      Instruction code: Cross match two triple entries (arg1, arg2)
      static byte TESTValue
      Instruction code: Check triple entry (arg1) against literal value (arg2).
    • Constructor Summary

      Constructors 
      Constructor Description
      RETEClauseFilter​(byte[] instructions, java.lang.Object[] args)
      Constructor.
    • Field Detail

      • TESTValue

        public static final byte TESTValue
        Instruction code: Check triple entry (arg1) against literal value (arg2).
        See Also:
        Constant Field Values
      • TESTFunctorName

        public static final byte TESTFunctorName
        Instruction code: Check literal value is a functor of name arg1
        See Also:
        Constant Field Values
      • TESTIntraMatch

        public static final byte TESTIntraMatch
        Instruction code: Cross match two triple entries (arg1, arg2)
        See Also:
        Constant Field Values
      • CREATEToken

        public static final byte CREATEToken
        Instruction code: Create a result environment of length arg1.
        See Also:
        Constant Field Values
      • BIND

        public static final byte BIND
        Instruction code: Bind a node (arg1) to a place in the rules token (arg2).
        See Also:
        Constant Field Values
      • END

        public static final byte END
        Instruction code: Final entry - dispatch to the network.
        See Also:
        Constant Field Values
      • ADDRSubject

        public static final byte ADDRSubject
        Argument addressing code: triple subject
        See Also:
        Constant Field Values
      • ADDRPredicate

        public static final byte ADDRPredicate
        Argument addressing code: triple predicate
        See Also:
        Constant Field Values
      • ADDRObject

        public static final byte ADDRObject
        Argument addressing code: triple object as a whole
        See Also:
        Constant Field Values
      • ADDRFunctorNode

        public static final byte ADDRFunctorNode
        Argument addressing code: triple object functor node, offset in low nibble, only usable after a successful TestFunctorName.
        See Also:
        Constant Field Values
    • Constructor Detail

      • RETEClauseFilter

        public RETEClauseFilter​(byte[] instructions,
                                java.lang.Object[] args)
        Constructor.
        Parameters:
        instructions - the set of byte-coded instructions and argument pointers.
        args - the object arguments referenced from the instructions array.
    • Method Detail

      • compile

        public static RETEClauseFilter compile​(TriplePattern clause,
                                               int envLength,
                                               java.util.List<Node> varList)
        Create a filter node from a rule clause. Clause complexity is limited to less than 50 args in a Functor.
        Parameters:
        clause - the rule clause
        envLength - the size of binding environment that should be created on successful matches
        varList - a list to which all clause variables will be appended
      • fire

        public void fire​(Triple triple,
                         boolean isAdd)
        Insert or remove a triple into the network.
        Parameters:
        triple - the triple to process.
        isAdd - true if the triple is being added to the working set.
      • clone

        public RETENode clone​(java.util.Map<RETENode,​RETENode> netCopy,
                              RETERuleContext context)
        Clone this node in the network.
        Specified by:
        clone in interface RETENode
        Parameters:
        netCopy - a map from RETENode to cloned instance
        context - the new context to which the network is being ported