SelectResults auxIterateEvaluate(CompiledValue operand, ExecutionContext context,
      SelectResults intermediateResults) throws FunctionDomainException, TypeMismatchException,
      NameResolutionException, QueryInvocationTargetException {
    // Asif: This can be a valid value if we have an AND condition like ID=1 AND
    // true = true. In such cases , if an index is not available on ID still we
    // have at least one expression which is independent of current scope. In
    // such cases a value of null means ignore the null ( because it means all
    // the results ) thus a the result-set of current auxIterate which will be
    // the subset of total result-set , will be the right data.

    // auxIterEvalaute can be called only from an AND junction.

    // This also implies that there will be at least one operand which will be
    // evaluated using auxFilterEvaluate.Thus the result-set given to this
    // function can be empty ( obtained using auxFilterEvaluate ,meaning no need
    // to do iterations below ) but it can never be null. As null itself
    // signifies that the junction cannot be evaluated as a filter.
    if (intermediateResults == null) {
      throw new RuntimeException(
          "intermediateResults can not be null");
    }
    if (intermediateResults.isEmpty()) // short circuit
    {
      return intermediateResults;
    }
    List currentIters = context.getCurrentIterators();
    RuntimeIterator[] rIters = new RuntimeIterator[currentIters.size()];
    currentIters.toArray(rIters);
    ObjectType elementType = intermediateResults.getCollectionType().getElementType();
    SelectResults resultSet;
    if (elementType.isStructType()) {
      resultSet = QueryUtils.createStructCollection(context, (StructTypeImpl) elementType);
    } else {
      resultSet = QueryUtils.createResultCollection(context, elementType);
    }


    QueryObserver observer = QueryObserverHolder.getInstance();
    try {
      observer.startIteration(intermediateResults, operand);
      for (final Object tuple : intermediateResults) {
        if (tuple instanceof Struct) {
          Object[] values = ((Struct) tuple).getFieldValues();
          for (int i = 0; i < values.length; i++) {
            rIters[i].setCurrent(values[i]);
          }
        } else {
          rIters[0].setCurrent(tuple);
        }
        Object result = null;
        try {
          result = operand.evaluate(context);
        } finally {
          observer.afterIterationEvaluation(result);
        }
        if (result instanceof Boolean) {
          if ((Boolean) result) {
            resultSet.add(tuple);
          }
        } else if (result != null && result != QueryService.UNDEFINED) {
          throw new TypeMismatchException(
              String.format("AND/OR operands must be of type boolean, not type ' %s '",
                  result.getClass().getName()));
        }
      }
    } finally {
      observer.endIteration(resultSet);
    }
    return resultSet;
  }
invariant: the operand is known to be evaluated by iteration
geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledJunction.java