@Override
  public boolean isBetterFilter(Filter comparedTo, ExecutionContext context, int thisSize)
      throws FunctionDomainException, TypeMismatchException, NameResolutionException,
      QueryInvocationTargetException {
    // If the current filter is equality & comparedTo filter is also equality based , then
    // return the one with lower size estimate is better
    boolean isThisBetter = true;
    int thisOperator = getOperator();
    int thatSize = comparedTo.getSizeEstimate(context);
    int thatOperator = comparedTo.getOperator();

    // Go with the lowest cost when hint is used.
    if (context instanceof QueryExecutionContext && ((QueryExecutionContext) context).hasHints()) {
      return thisSize <= thatSize;
    }

    switch (thatOperator) {
      case TOK_EQ:
      case TOK_NE:
      case TOK_NE_ALT:
        isThisBetter = thisSize <= thatSize;
        break;
      case LITERAL_and:
        // This is possible only in case of RangeJunction
        if (thisOperator == TOK_NE || thisOperator == TOK_NE_ALT) {
          // Asif: Give preference to range as I am assuming that range will fetch less data
          // as compared to NOT EQUALs
          isThisBetter = false;
        }
        break;
      case TOK_LE:
      case TOK_LT:
      case TOK_GE:
      case TOK_GT:
        // Give preference to this rather than that as this is more deterministic
        break;
      default:
        throw new IllegalArgumentException("The operator type =" + thatOperator + " is unknown");
    }
    return isThisBetter;
  }
evaluate as a filter, producing an intermediate result set. This may require iteration if there
is no index available. Asif :The boolean true implies that CompiledComparsion when existing on
its own always requires a Complete expansion to top level iterators. This flag can get toggled
to false only from inside a GroupJunction

<p>
param intermediateResults if this parameter is provided, and we have to iterate, then iterate
over this result set instead of the entire base collection.
geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledUndefined.java