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

public class ExtensibleBottomUpEvalManager extends BottomUpEvalManager
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.
  • Constructor Details

    • ExtensibleBottomUpEvalManager

      public ExtensibleBottomUpEvalManager(Set<PredicateSym> extensiblePreds)
      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

      public void initialize(Set<Clause> program) throws DatalogValidationException
      Description copied from interface: EvalManager
      Initialize this manager with a program.
      Specified by:
      initialize in interface EvalManager
      Overrides:
      initialize in class BottomUpEvalManager
      Parameters:
      program - the program
      Throws:
      DatalogValidationException - if the program is invalid
    • eval

      public IndexableFactCollection 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 interface EvalManager
      Overrides:
      eval in class BottomUpEvalManager
      Returns:
      the facts
    • finishAsynchronousEval

      public IndexableFactCollection 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

      public void addFact(PositiveAtom fact)
      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

      protected void processNewFact(PositiveAtom newFact)
      Overrides:
      processNewFact in class BottomUpEvalManager
    • addListener

      public void addListener(PredicateSym p, DatalogListener listener)
      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 for
      listener - the listener