Interface DatalogExecutor

All Known Implementing Classes:
DatalogParallelExecutor

public interface DatalogExecutor
A interface to an ongoing Datalog evaluation that allows for callbacks to be registered that are invoked when relevant new facts are derived and for new EDB facts to be added in the midst of evaluation.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Asynchronously adds a new EDB fact to the Datalog evaluation.
    void
    initialize(Set<Clause> program, Set<PredicateSym> extendibleEdbPreds)
    Initializes the Datalog engine with a program and specifies which EDB relations can be extended (with DatalogExecutor.addFactAsynchronously()) during evaluation.
    void
    Associates a listener with a given predicate symbol, so that if any fact is derived during evaluation with that predicate symbol, the listener will be invoked with that fact.
    void
    Shuts down the executor, which cannot be reused.
    void
    Starts the Datalog evaluation.
  • Method Details

    • initialize

      void initialize(Set<Clause> program, Set<PredicateSym> extendibleEdbPreds) throws DatalogValidationException
      Initializes the Datalog engine with a program and specifies which EDB relations can be extended (with DatalogExecutor.addFactAsynchronously()) during evaluation. This should only be called once.
      Parameters:
      program - the program
      extendibleEdbPreds - the extendible EDB relations
      Throws:
      DatalogValidationException - if program is invalid
    • start

      void start()
      Starts the Datalog evaluation.
      Throws:
      IllegalStateException - if the executor has not been initialized or the evaluation has already been started
    • addFactAsynchronously

      void addFactAsynchronously(PositiveAtom edbFact)
      Asynchronously adds a new EDB fact to the Datalog evaluation. The EDB fact must be part of a relation that is specified in DatalogExecutor.initialize() as being extendible. A fact is a ground atom (i.e., an atom without any variables).
      Parameters:
      edbFact - the new EDB fact
      Throws:
      IllegalStateException - if the executor has not been initialized
      IllegalArgumentException - if the provided atom is not ground, or if it is not part of a relation specified during initialization as being extendible
    • registerListener

      void registerListener(PredicateSym p, DatalogListener listener)
      Associates a listener with a given predicate symbol, so that if any fact is derived during evaluation with that predicate symbol, the listener will be invoked with that fact. The listener can be executed in an arbitrary thread and should not block.
      Parameters:
      p - the predicate symbol
      listener - the listener
      Throws:
      IllegalStateException - if the evaluation has already been started
    • shutdown

      void shutdown()
      Shuts down the executor, which cannot be reused.