Class ExtensibleBottomUpEvalManager
java.lang.Object
edu.harvard.seas.pl.abcdatalog.engine.bottomup.concurrent.BottomUpEvalManager
edu.harvard.seas.pl.abcdatalog.engine.bottomup.concurrent.ExtensibleBottomUpEvalManager
- All Implemented Interfaces:
EvalManager
An evaluation manager for a concurrent semi-naive engine that runs asynchronously in the
background. Facts can be added to the evaluation after the engine has started. Clients can also
register listeners with the manager, which are invoked when meaningful facts are derived.
-
Field Summary
Fields inherited from class edu.harvard.seas.pl.abcdatalog.engine.bottomup.concurrent.BottomUpEvalManager
exec, facts, initialFacts, predToEvalMap, trie
-
Constructor Summary
ConstructorDescriptionExtensibleBottomUpEvalManager
(Set<PredicateSym> extensiblePreds) Constructs a concurrent semi-naive evaluation manager that supports the explicit addition of facts during evaluation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFact
(PositiveAtom fact) Add a fact to this evaluation manager.void
addListener
(PredicateSym p, DatalogListener listener) Registers a listener with this manager.eval()
Starts this manager running in the background.Blocks until the evaluation is complete and returns the set of facts derived during evaluation.void
initialize
(Set<Clause> program) Initialize this manager with a program.protected void
processNewFact
(PositiveAtom newFact) Methods inherited from class edu.harvard.seas.pl.abcdatalog.engine.bottomup.concurrent.BottomUpEvalManager
getFacts, newFact, processInitialFacts
-
Constructor Details
-
ExtensibleBottomUpEvalManager
Constructs a concurrent semi-naive evaluation manager that supports the explicit addition of facts during evaluation. The argument marks the predicates of the relations that are allowed to receive new facts.- Parameters:
extensiblePreds
- the predicates of the relations that can be extended by new facts
-
-
Method Details
-
initialize
Description copied from interface:EvalManager
Initialize this manager with a program.- Specified by:
initialize
in interfaceEvalManager
- Overrides:
initialize
in classBottomUpEvalManager
- Parameters:
program
- the program- Throws:
DatalogValidationException
- if the program is invalid
-
eval
Starts this manager running in the background. Returns a view into the facts derived during evaluation. Note, however, that this view might have inconsistent state while the evaluation is ongoing.- Specified by:
eval
in interfaceEvalManager
- Overrides:
eval
in classBottomUpEvalManager
- Returns:
- the facts
-
finishAsynchronousEval
Blocks until the evaluation is complete and returns the set of facts derived during evaluation. Once this method has been called, the evaluation manager cannot be reused.- Returns:
- the facts
- Throws:
IllegalStateException
- if the evaluation was never started, or if it has already been finished (or is in the process of finishing).
-
addFact
Add a fact to this evaluation manager. If the evaluation manager has not yet started evaluation, then this fact will be added to the evaluation once it begins. If the evaluation has already been finished with this.finishAsynchrousEval, the fact is ignored.- Parameters:
fact
- the fact- Throws:
IllegalArgumentException
- if the given fact does not have a predicate that was specified as "extensible" during construction.IllegalStateException
- if evaluation has already finished.
-
processNewFact
- Overrides:
processNewFact
in classBottomUpEvalManager
-
addListener
Registers a listener with this manager. When a fact with predicate p is derived during evaluation, the manager invokes the listener with that fact. The listener can be called from an arbitrary thread. If the listener is registered after evaluation is started, it will not be invoked on any facts that have already been derived.- Parameters:
p
- the predicate to listen forlistener
- the listener
-