@Test
  public void testStatsForMapRangeIndexBeforeRegionCreation() throws Exception {
    // Destroy region
    IndexManager.TEST_RANGEINDEX_ONLY = true;
    region.clear();
    assertEquals(0, region.size());
    Position.cnt = 0;

    keyIndex3 = (IndexProtocol) qs.createIndex("multiKeyIndex6", IndexType.FUNCTIONAL,
        "positions['DELL', 'YHOO']", SEPARATOR + "portfolio");
    Object[] indexes =
        ((MapRangeIndex) keyIndex3).getRangeIndexHolderForTesting().values().toArray();
    assertEquals(indexes.length, 0);

    // Recreate all entries in the region
    Position.cnt = 0;
    for (int i = 0; i < 100; i++) {
      region.put(Integer.toString(i), new Portfolio(i, i));
    }
    assertTrue(keyIndex3 instanceof MapRangeIndex);
    indexes = ((MapRangeIndex) keyIndex3).getRangeIndexHolderForTesting().values().toArray();
    assertTrue(indexes[0] instanceof RangeIndex);
    assertTrue(indexes[1] instanceof RangeIndex);

    IndexStatistics keyIndex1Stats = ((RangeIndex) indexes[0]).getStatistics();
    IndexStatistics keyIndex2Stats = ((RangeIndex) indexes[1]).getStatistics();
    IndexStatistics mapIndexStats = keyIndex3.getStatistics();

    assertEquals(100, mapIndexStats.getNumberOfKeys());
    assertEquals(200, mapIndexStats.getNumberOfValues());
    assertEquals(200, mapIndexStats.getNumUpdates());


    Position.cnt = 0;
    for (int i = 0; i < 100; i++) {
      region.put(Integer.toString(i), new Portfolio(i, i));
    }

    assertEquals(100, mapIndexStats.getNumberOfKeys());
    assertEquals(200, mapIndexStats.getNumberOfValues());
    assertEquals(400, mapIndexStats.getNumUpdates());

    String queryStr =
        "select * from " + SEPARATOR
            + "portfolio where positions['DELL'] != NULL OR positions['YHOO'] != NULL";
    Query query = qs.newQuery(queryStr);

    for (int i = 0; i < 50; i++) {
      query.execute();
    }

    assertEquals(100, mapIndexStats.getTotalUses());

    for (int i = 0; i < 50; i++) {
      region.invalidate(Integer.toString(i));
    }

    assertEquals(50, mapIndexStats.getNumberOfKeys());
    assertEquals(100, mapIndexStats.getNumberOfValues());
    assertEquals(600, mapIndexStats.getNumUpdates());


    for (int i = 0; i < 50; i++) {
      region.destroy(Integer.toString(i));
    }

    assertEquals(50, mapIndexStats.getNumberOfKeys());
    assertEquals(100, mapIndexStats.getNumberOfValues());
    assertEquals(600, mapIndexStats.getNumUpdates());

    for (int i = 50; i < 100; i++) {
      region.destroy(Integer.toString(i));
    }

    assertEquals(800, mapIndexStats.getNumUpdates());

    assertEquals(0, mapIndexStats.getNumberOfKeys());

    qs.removeIndex(keyIndex3);
  }
Test MapRenageIndex IndexStatistics for keys, values, updates and uses.
geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/IndexStatisticsJUnitTest.java