Class LegacyBacktrackEvaluator.BacktrackIterator

java.lang.Object
fr.inria.rules.integraal.query_evaluation.conjunction.backtrack.legacy.LegacyBacktrackEvaluator.BacktrackIterator
All Implemented Interfaces:
Iterator<Substitution>
Enclosing class:
LegacyBacktrackEvaluator<QD extends QueryableData>

protected class LegacyBacktrackEvaluator.BacktrackIterator extends Object implements Iterator<Substitution>
The BacktrackIterator is used to redefine the iterator return as an answer to the query. It computes results only when needed. Calling hasNext() effectively computes the next answer.
  • Field Details

    • evaluator

      protected final FOQueryEvaluator<FOFormula, QD extends QueryableData> evaluator
      Query evaluator used to evaluate the sub-queries
    • query

      protected final FOQuery<? extends FOFormulaConjunction> query
      Query to evaluate
    • queryableData

      protected final QD extends QueryableData queryableData
      The queryableData on which to evaluate the query
    • scheduler

      protected final Scheduler scheduler
      Object used to choose the next sub-query to evaluate
    • joinVariables

      protected final Set<Variable> joinVariables
      Variables shared by several sub-queries and therefore used for joins.
    • vars

      protected final Collection<Variable> vars
      Variables requested in the final answer.
    • preHomomorphism

      protected final Substitution preHomomorphism
      Pre-existing substitution that every answer must extend.
    • solutionManager

      protected SolutionManager solutionManager
      Object used to handle the results to the query. It is used as a sort of cache during the query evaluation
    • hasCurrentSolution

      protected boolean hasCurrentSolution
      Indicates whether the current solution has already been computed.
    • level

      protected int level
      Current level in the backtracking search tree.
    • backtrack

      protected boolean backtrack
      Indicates whether the iterator is currently backtracking.
  • Constructor Details

    • BacktrackIterator

      public BacktrackIterator(FOQueryEvaluator<FOFormula, QD> evaluator, FOQuery<? extends FOFormulaConjunction> query, QD queryableData, Collection<Variable> vars, Substitution preHomomorphism)
      Creates a backtracking iterator for one conjunctive query evaluation.
      Parameters:
      evaluator - the evaluator used for sub-queries
      query - the query to evaluate
      queryableData - the data source being queried
      vars - the variables to project in the answers
      preHomomorphism - the substitution that answers must extend
  • Method Details

    • hasNext

      public boolean hasNext()
      /////////////////
      Specified by:
      hasNext in interface Iterator<Substitution>
    • next

      public Substitution next()
      Specified by:
      next in interface Iterator<Substitution>
    • success

      protected void success()
      Called when there is a success during the backtrack algorithm. A success is when a sub-query is evaluated and correct in regard to the previously computed answer.
    • fail

      protected void fail()
      Called when there is a failure during the backtrack algorithm. A failure is when a sub-query is evaluated and is incorrect in regard to the previously computed answer. A failure is also considered if the answer is found to be able to go to the next result if we want all the result of the query
    • computePreviousLevel

      protected void computePreviousLevel()
      Compute and update the previous level
    • computeNextLevel

      protected void computeNextLevel()
      Compute and update the next level
    • solutionFound

      protected boolean solutionFound()
      Indicates whether a full solution has been found.
      Returns:
      true iff a solution is found