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 Summary
FieldsModifier and TypeFieldDescriptionprotected booleanIndicates whether the iterator is currently backtracking.protected final FOQueryEvaluator<FOFormula, QD> Query evaluator used to evaluate the sub-queriesprotected booleanIndicates whether the current solution has already been computed.Variables shared by several sub-queries and therefore used for joins.protected intCurrent level in the backtracking search tree.protected final SubstitutionPre-existing substitution that every answer must extend.protected final FOQuery<? extends FOFormulaConjunction> Query to evaluateprotected final QDThe queryableData on which to evaluate the queryprotected final SchedulerObject used to choose the next sub-query to evaluateprotected SolutionManagerObject used to handle the results to the query.protected final Collection<Variable> Variables requested in the final answer. -
Constructor Summary
ConstructorsConstructorDescriptionBacktrackIterator(FOQueryEvaluator<FOFormula, QD> evaluator, FOQuery<? extends FOFormulaConjunction> query, QD queryableData, Collection<Variable> vars, Substitution preHomomorphism) Creates a backtracking iterator for one conjunctive query evaluation. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCompute and update the next levelprotected voidCompute and update the previous levelprotected voidfail()Called when there is a failure during the backtrack algorithm.booleanhasNext()/////////////////next()protected booleanIndicates whether a full solution has been found.protected voidsuccess()Called when there is a success during the backtrack algorithm.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterator
forEachRemaining, remove
-
Field Details
-
evaluator
Query evaluator used to evaluate the sub-queries -
query
Query to evaluate -
queryableData
The queryableData on which to evaluate the query -
scheduler
Object used to choose the next sub-query to evaluate -
joinVariables
-
vars
Variables requested in the final answer. -
preHomomorphism
Pre-existing substitution that every answer must extend. -
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 hasCurrentSolutionIndicates whether the current solution has already been computed. -
level
protected int levelCurrent level in the backtracking search tree. -
backtrack
protected boolean backtrackIndicates 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-queriesquery- the query to evaluatequeryableData- the data source being queriedvars- the variables to project in the answerspreHomomorphism- the substitution that answers must extend
-
-
Method Details
-
hasNext
public boolean hasNext()/////////////////- Specified by:
hasNextin interfaceIterator<Substitution>
-
next
- Specified by:
nextin interfaceIterator<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
-