@Test
  public void testCacheEvalCollnWithIn() throws Exception {
    Cache cache = CacheUtils.getCache();
    AttributesFactory attributesFactory = new AttributesFactory();
    RegionAttributes regionAttributes = attributesFactory.create();
    QueryService qs = cache.getQueryService();
    Region customersRegion = cache.createRegionFactory(regionAttributes).create("customers");
    Region receiptsRegion = cache.createRegionFactory(regionAttributes).create("receipts");

    qs.createIndex("receiptsByProduct", "i.productId", SEPARATOR + "receipts r, r.items i");
    qs.createIndex("receiptsByCustomer", "r.productId", SEPARATOR + "receipts r");
    qs.createIndex("customersByProfile", "c.profile", SEPARATOR + "customers c");

    int numReceiptsPerCustomer = 10;
    for (int i = 0; i < 1000; i++) {
      customersRegion.put(i, new Customer(i, i % 2 == 0 ? "PremiumIndividual" : "AverageJoe"));
      for (int j = 0; j < numReceiptsPerCustomer; j++) {
        int receiptId = i * numReceiptsPerCustomer + j;
        receiptsRegion.put(receiptId, new Receipt(receiptId, i));
      }
    }

    Query q = qs.newQuery(
        "<trace>select r from " + SEPARATOR
            + "receipts r, r.items i where i.productId = 8 and r.customerId in (select c.id from "
            + SEPARATOR + "customers c where c.profile = 'PremiumIndividual')");
    SelectResults results = (SelectResults) q.execute();
    assertThat(results).hasSize(500);

    for (int i = 1000; i < 1100; i++) {
      customersRegion.put(i, new Customer(i, i % 2 == 0 ? "PremiumIndividual" : "AverageJoe"));
      for (int j = 0; j < numReceiptsPerCustomer; j++) {
        int receiptId = i * numReceiptsPerCustomer + j;
        receiptsRegion.put(receiptId, new Receipt(receiptId, i));
      }
    }
    results = (SelectResults) q.execute();
    assertThat(results).hasSize(550);
  }
Tests optimization of compiled in where we no longer evaluate on every iteration The set is
saved off into the query context and reused Each query should have it's own query context
geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/INOperatorJUnitTest.java