private ITupleIterator computeSimpleCartesianProduct(
     ITupleIterator leftTuples, ITupleIterator rightTuples) {
   List<Tuple> result = new ArrayList<Tuple>();
   while (leftTuples.hasNext()) {
     Tuple leftTuple = leftTuples.next();
     if (logger.isDebugEnabled()) logger.debug("Left tuple in cartesian product: " + leftTuple);
     while (rightTuples.hasNext()) {
       Tuple rightTuple = rightTuples.next();
       if (logger.isDebugEnabled())
         logger.debug("Right tuple in cartesian product: " + rightTuple);
       Tuple joinedTuple = joinTuples(leftTuple, rightTuple);
       result.add(joinedTuple);
     }
     rightTuples.reset();
   }
   leftTuples.reset();
   return new ListTupleIterator(result);
 }
 private EquivalenceClassForSymmetricEGD readNextEquivalenceClass(
     ITupleIterator it,
     Dependency egd,
     IDatabase deltaDB,
     String stepId,
     IChaseState chaseState,
     Scenario scenario) {
   if (!it.hasNext() && (this.lastTupleHandled || this.lastTuple == null)) {
     return null;
   }
   EquivalenceClassForSymmetricEGD equivalenceClass = createEquivalenceClass(egd);
   if (lastTuple != null && !this.lastTupleHandled) {
     if (logger.isDebugEnabled())
       logger.debug("Reading tuple : " + this.lastTuple.toStringWithOIDAndAlias());
     addTuple(
         this.lastTuple,
         equivalenceClass,
         scenario.getCostManagerConfiguration(),
         deltaDB,
         stepId,
         scenario);
     this.lastTupleHandled = true;
   }
   if (logger.isDebugEnabled()) logger.debug("Reading next equivalence class...");
   while (it.hasNext()) {
     if (chaseState.isCancelled())
       ChaseUtility.stopChase(
           chaseState); // throw new ChaseException("Chase interrupted by user");
     Tuple tuple = it.next();
     if (logger.isDebugEnabled())
       logger.debug("Reading tuple : " + tuple.toStringWithOIDAndAlias());
     if (lastTuple == null
         || equivalenceClass.isEmpty()
         || EquivalenceClassUtility.sameEquivalenceClass(tuple, this.lastTuple, egd)) {
       addTuple(
           tuple,
           equivalenceClass,
           scenario.getCostManagerConfiguration(),
           deltaDB,
           stepId,
           scenario);
       this.lastTuple = tuple;
       this.lastTupleHandled = true;
     } else {
       if (logger.isDebugEnabled()) logger.debug("Equivalence class is finished...");
       if (equivalenceClass.isEmpty()) {
         throw new IllegalArgumentException(
             "Unable to create equivalence class for egd:\n"
                 + egd
                 + "\nLast tuple: \n"
                 + lastTuple
                 + "\nCurrent tuple: \n"
                 + tuple);
       }
       this.lastTuple = tuple;
       this.lastTupleHandled = false;
       break;
     }
   }
   if (logger.isDebugEnabled()) logger.debug("Equivalence class loaded");
   if (logger.isDebugEnabled())
     logger.debug("-------- Equivalence class:\n" + equivalenceClass + "\n---------------");
   return equivalenceClass;
 }