java.lang.Object
org.apache.jena.reasoner.rulesys.impl.Generator
All Implemented Interfaces:
LPAgendaEntry, LPInterpreterContext, LPInterpreterState

public class Generator extends Object implements LPAgendaEntry, LPInterpreterContext
A generator represents a set of memoized results for a single tabled subgoal. The generator may be complete (in which case it just contains the complete cached set of results for a goal), ready (not complete but likely to product more results if called) or blocked (not complete and awaiting results from a dependent generator).

Each generator may have multiple associated consumer choice points representing different choices in satisfying the generator's goal.

  • Constructor Details

    • Generator

      public Generator(LPInterpreter interpreter, TriplePattern goal)
      Constructor.
      Parameters:
      interpreter - an initialized interpreter instance that will answer results for this generator.
  • Method Details

    • numResults

      public int numResults()
      Return the number of results available from this context.
    • isReady

      public boolean isReady()
      Return true if the generator is ready to be scheduled (i.e. it is not known to be complete and not known to be waiting for a dependent generator).
      Specified by:
      isReady in interface LPAgendaEntry
      Specified by:
      isReady in interface LPInterpreterContext
    • setReady

      public void setReady(ConsumerChoicePointFrame ccp)
      Directly set that this generator is ready (because the generator for one of its generatingCPs has produced new results).
      Specified by:
      setReady in interface LPInterpreterContext
    • isComplete

      public boolean isComplete()
      Return true if the generator is complete.
    • setComplete

      public void setComplete()
      Signal that this generator is complete, no more results can be created.
    • addConsumer

      public void addConsumer(ConsumerChoicePointFrame ccp)
      Add a new client choince point to consume results from this generator.
    • removeConsumer

      public void removeConsumer(ConsumerChoicePointFrame ccp)
      Remove a terminated consuming choice point from the state set.
    • notifyResults

      public void notifyResults()
      Signal dependents that we have new results.
    • notifyBlockedOn

      public void notifyBlockedOn(ConsumerChoicePointFrame ccp)
      Notify that the interpreter has now blocked on the given choice point.
      Specified by:
      notifyBlockedOn in interface LPInterpreterContext
    • notifyFinished

      public void notifyFinished(ConsumerChoicePointFrame ccp)
      Notify this context that the given choice point has terminated and can be remove from the wait list.
      Specified by:
      notifyFinished in interface LPInterpreterContext
    • pump

      public void pump()
      Start this generator running for the first time. Should be called from within an appropriately synchronized block.
      Specified by:
      pump in interface LPAgendaEntry
    • pump

      public void pump(LPInterpreterState context)
      Start this generator running from the given previous blocked generating choice point. Should be called from within an appropriately synchronized block.
    • getGenerator

      public Generator getGenerator()
      Return the generator associated with this entry (might be the entry itself)
      Specified by:
      getGenerator in interface LPAgendaEntry
    • checkForCompletions

      public void checkForCompletions()
      Check for deadlocked states where none of the generators we are (indirectly) dependent on can run.
    • checkForCompletions

      public static void checkForCompletions(Collection<? extends Generator> completions)
      Check for deadlocked states across a collection of generators which have been run.