Class Generator
- java.lang.Object
-
- org.apache.jena.reasoner.rulesys.impl.Generator
-
- All Implemented Interfaces:
LPAgendaEntry
,LPInterpreterContext
,LPInterpreterState
public class Generator extends java.lang.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 Summary
Constructors Constructor Description Generator(LPInterpreter interpreter, TriplePattern goal)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConsumer(ConsumerChoicePointFrame ccp)
Add a new client choince point to consume results from this generator.void
checkForCompletions()
Check for deadlocked states where none of the generators we are (indirectly) dependent on can run.static void
checkForCompletions(java.util.Collection<? extends Generator> completions)
Check for deadlocked states across a collection of generators which have been run.Generator
getGenerator()
Return the generator associated with this entry (might be the entry itself)boolean
isComplete()
Return true if the generator is complete.boolean
isReady()
Return true if the generator is ready to be scheduled (i.e.void
notifyBlockedOn(ConsumerChoicePointFrame ccp)
Notify that the interpreter has now blocked on the given choice point.void
notifyFinished(ConsumerChoicePointFrame ccp)
Notify this context that the given choice point has terminated and can be remove from the wait list.void
notifyResults()
Signal dependents that we have new results.int
numResults()
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
removeConsumer(ConsumerChoicePointFrame ccp)
Remove a terminated consuming choice point from the state set.void
setComplete()
Signal that this generator is complete, no more results can be created.void
setReady(ConsumerChoicePointFrame ccp)
Directly set that this generator is ready (because the generator for one of its generatingCPs has produced new results).
-
-
-
Constructor Detail
-
Generator
public Generator(LPInterpreter interpreter, TriplePattern goal)
Constructor.- Parameters:
interpreter
- an initialized interpreter instance that will answer results for this generator.
-
-
Method Detail
-
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
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 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
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 interfaceLPInterpreterContext
-
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 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
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 interfaceLPAgendaEntry
-
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(java.util.Collection<? extends Generator> completions)
Check for deadlocked states across a collection of generators which have been run.
-
-