java.lang.Object
org.apache.jena.reasoner.rulesys.impl.Generator
- All Implemented Interfaces:
LPAgendaEntry
,LPInterpreterContext
,LPInterpreterState
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a new client choince point to consume results from this generator.void
Check for deadlocked states where none of the generators we are (indirectly) dependent on can run.static void
checkForCompletions
(Collection<? extends Generator> completions) Check for deadlocked states across a collection of generators which have been run.Return the generator associated with this entry (might be the entry itself)boolean
Return true if the generator is complete.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).void
Notify that the interpreter has now blocked on the given choice point.void
Notify this context that the given choice point has terminated and can be remove from the wait list.void
Signal dependents that we have new results.int
Return the number of results available from this context.void
pump()
Start this generator running for the first time.void
pump
(LPInterpreterState context) Start this generator running from the given previous blocked generating choice point.void
Remove a terminated consuming choice point from the state set.void
Signal that this generator is complete, no more results can be created.void
Directly set that this generator is ready (because the generator for one of its generatingCPs has produced new results).
-
Constructor Details
-
Generator
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 interfaceLPAgendaEntry
- Specified by:
isReady
in interfaceLPInterpreterContext
-
setReady
Directly set that this generator is ready (because the generator for one of its generatingCPs has produced new results).- Specified by:
setReady
in interfaceLPInterpreterContext
-
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
Add a new client choince point to consume results from this generator. -
removeConsumer
Remove a terminated consuming choice point from the state set. -
notifyResults
public void notifyResults()Signal dependents that we have new results. -
notifyBlockedOn
Notify that the interpreter has now blocked on the given choice point.- Specified by:
notifyBlockedOn
in interfaceLPInterpreterContext
-
notifyFinished
Notify this context that the given choice point has terminated and can be remove from the wait list.- Specified by:
notifyFinished
in interfaceLPInterpreterContext
-
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 interfaceLPAgendaEntry
-
pump
Start this generator running from the given previous blocked generating choice point. Should be called from within an appropriately synchronized block. -
getGenerator
Return the generator associated with this entry (might be the entry itself)- Specified by:
getGenerator
in interfaceLPAgendaEntry
-
checkForCompletions
public void checkForCompletions()Check for deadlocked states where none of the generators we are (indirectly) dependent on can run. -
checkForCompletions
Check for deadlocked states across a collection of generators which have been run.
-