@Override
  public SelectResults auxFilterEvaluate(ExecutionContext context,
      SelectResults intermediateResults) throws FunctionDomainException, TypeMismatchException,
      NameResolutionException, QueryInvocationTargetException {
    // evaluate the result set from the indexed values
    // using the intermediate results so far (passed in)
    // put results into new intermediate results

    List sortedConditionsList =
        getCondtionsSortedOnIncreasingEstimatedIndexResultSize(context);

    Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX);

    boolean modifiedApplyLimits = false;
    if (applyLimit != null && applyLimit && sortedConditionsList.size() > 1
        && _operator == LITERAL_and) {
      context.cachePut(CAN_APPLY_LIMIT_AT_INDEX, Boolean.FALSE);
      modifiedApplyLimits = true;
    }

    // Sort the operands in increasing order of resultset size
    Iterator i = sortedConditionsList.iterator();
    // SortedSet intersectionSet = new TreeSet(new SelectResultsComparator());
    while (i.hasNext()) {
      // Asif:TODO The intermediate ResultSet should be passed as null when
      // invoking filterEvaluate. Just because filterEvaluate is being called,
      // itself guarantees that there will be at least on auxFilterEvalaute call.
      // The filterEvalaute will return after invoking auxIterEvaluate.
      // The auxIterEvaluate cannot get invoked for an OR junction.
      // The approach of calculation of resultset should be Bubble UP
      // ( i.e bottom to Top of the tree. This implies that for
      // filterEvaluate, we should not be passing IntermediateResultSet.
      // Each invocation of filterEvaluate will be complete in itself
      // with the recursion being ended by evaluating auxIterEvaluate
      // if any. The passing of IntermediateResult in filterEvalaute
      // causes AND junction evaluation to be corrupted ,
      // if the intermediateResultset contains some value.
      // If the parent object is a GroupJunction then the filter may be a
      // RangeJunction or a CompiledComparison. But if the parent Object is a
      // RangeJunction then the Filter is a RangeJunctionEvaluator
      SelectResults filterResults = null;

      if (modifiedApplyLimits && sortedConditionsList.size() == 1) {
        context.cachePut(CAN_APPLY_LIMIT_AT_INDEX, Boolean.TRUE);
        modifiedApplyLimits = false;
      }

      Filter filter = (Filter) i.next();
      boolean isConditioningNeeded = filter.isConditioningNeededForIndex(
          indpndntItr.length == 1 ? indpndntItr[0] : null, context,
          completeExpansion);

      // TODO:Asif: For RangeJunction I am right now returning true as
      // isConditioningNeeded because there is no provision right now to pass
      // intermediate results from RangeJunction & also no code to utilize the
      // intermediate results in the evaluator created out of RangeJunction.
      filterResults = filter.filterEvaluate(context,
          !isConditioningNeeded ? intermediateResults : null, completeExpansion,
          null/*
               * Asif * Asif :The iter operands passed are null, as a not null value can exists only
               * if there exists a single Filter operand in original GroupJunction
               */, indpndntItr, _operator == LITERAL_and, isConditioningNeeded,
          false /* do not evaluate projection */);
      if (_operator == LITERAL_and) {
        if (filterResults != null && filterResults.isEmpty()) {
          return filterResults;
        } else if (filterResults != null) {
          intermediateResults =
              (intermediateResults == null || !isConditioningNeeded) ? filterResults
                  : QueryUtils.intersection(intermediateResults, filterResults, context);
          i.remove();
          if (intermediateResults.size() <= indexThresholdSize) {
            // Abort further intersection , the residual filter operands will be transferred for
            // iter evaluation
            break;
          }
        }
      } else {
        // Asif : In case of OR clause, the filterEvaluate cannot return a
        // null value ,as a null value implies Cartesian of Iterators
        // in current scope which can happen only if the operand of OR
        // clause evaluates to true (& which we are not allowing).
        // Though if the operand evaluates to false,it is permissible case
        // for filterEvaluation.
        Assert.assertTrue(filterResults != null);
        boolean isDistinct =
            context.getQuery() != null && ((DefaultQuery) context.getQuery()).getSelect()
                .isDistinct();
        /*
         * Shobhit: Only for distinct query union can be avoided. For non-distinct queries
         * filterResults and intermediateResults are different for OR conditions and final result
         * can contain duplicate objects based on occurrences.
         */
        if (intermediateResults == null) {
          intermediateResults = filterResults;
        } else if (isDistinct && !isConditioningNeeded) {
          intermediateResults.addAll(filterResults);
        } else {
          intermediateResults = QueryUtils.union(intermediateResults, filterResults, context);
        }
      }
    }
    if (_operator == LITERAL_and && !sortedConditionsList.isEmpty()) {
      addUnevaluatedFilterOperands(sortedConditionsList);
    }
    return intermediateResults;
  }
Asif : This function is always invoked on a DummyGroupJunction object formed as a part of
organization of operands of a GroupJunction . This also guranatees that the operands are all of
type CompiledComparison or CompiledUndefined
geode-core/src/main/java/org/apache/geode/cache/query/internal/AbstractGroupOrRangeJunction.java