@Override
  public boolean isBetterFilter(Filter comparedTo, ExecutionContext context, final 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 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;
    }

    // There may be some hard rules that give unoptimal selections based on these switch cases.
    if (_operator == TOK_EQ || _operator == TOK_NE || _operator == TOK_NE_ALT) {
      switch (thatOperator) {
        case TOK_EQ:
        case TOK_NE:
        case TOK_NE_ALT:
          isThisBetter = thisSize <= thatSize;
          break;
        case LITERAL_and:
          // This is is possible only in case of RangeJunction.
          if (_operator == TOK_NE || _operator == 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");
      }
    } else {
      // This is a inequality. If that is true the priority goes to equality & Not Equality & Range
      switch (thatOperator) {
        case TOK_EQ:
        case TOK_NE:
        case TOK_NE_ALT:
        case LITERAL_and:
          // Asif: Give preference to range as I am assuming that raneg will fetch less data
          // as compared to NOT EQUALs
          isThisBetter = false;
          break;
        case TOK_LE:
        case TOK_LT:
        case TOK_GE:
        case TOK_GT:
          isThisBetter = thisSize <= thatSize;
          break;
        default:
          throw new IllegalArgumentException("The operator type =" + thatOperator + " is unknown");

      }
    }
    return isThisBetter;
  }
get the path to see if there's an index for, and also determine which CompiledValue is the key
while we're at it
geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledComparison.java