@Override
  public Object evaluate(ExecutionContext context) throws FunctionDomainException,
      TypeMismatchException, NameResolutionException, QueryInvocationTargetException {
    Object evalElm = elm.evaluate(context);

    Object evalColln = evaluateColln(context);

    if (evalColln == null || evalColln == QueryService.UNDEFINED) {
      return QueryService.UNDEFINED;
    }

    // handle each type of collection that we support
    if (evalColln instanceof Map) {
      evalColln = ((Map) evalColln).entrySet();
    }

    if (evalColln instanceof Collection) {
      for (final Object o : (Iterable) evalColln) {
        Object evalObj = evalElm;
        Object collnObj = o;
        if (evalElm instanceof PdxString && collnObj instanceof String) {
          evalObj = evalElm.toString();
        } else if (collnObj instanceof PdxString && evalElm instanceof String) {
          collnObj = collnObj.toString();
        }
        if (TypeUtils.compare(evalObj, collnObj, OQLLexerTokenTypes.TOK_EQ).equals(Boolean.TRUE)) {
          return Boolean.TRUE;
        }
      }
      return Boolean.FALSE;
    }

    if (!evalColln.getClass().isArray()) {
      throw new TypeMismatchException(
          String.format("Operand of IN cannot be interpreted as a Collection. Is instance of %s",
              evalColln.getClass().getName()));
    }
    if (evalColln.getClass().getComponentType().isPrimitive()) {
      if (evalElm == null) {
        throw new TypeMismatchException(
            "IN operator, check for null IN primitive array");
      }
    }

    int numElements = Array.getLength(evalColln);
    for (int i = 0; i < numElements; i++) {
      Object o = Array.get(evalColln, i);
      if (TypeUtils.compare(evalElm, o, TOK_EQ).equals(Boolean.TRUE)) {
        return Boolean.TRUE;
      }
    }

    return Boolean.FALSE;
  }
We retrieve the collection from the context cache if it exists This allows us to not have to
reevaluate the sub query on every iteration. This improves performance for queries such as
"select * from /receipts r where r.type = 'large' and r.id in (select c.id from /customers c
where c.status = 'preferred') The sub query would create a set that would not change and store
it into the context if it does not yet exist
geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIn.java