AttributeMetadata { public Integer getCountOfDistinctKeys() { QueryOptions queryOptions = openResources(); try { return index.getCountOfDistinctKeys(queryOptions); } finally { closeResources(queryOptions); } } AttributeMetadata(KeyStatisticsIndex<A, O> index, Supplier<QueryOptions> openResourcesHandler, Consumer<QueryOptions> closeResourcesHandler); Stream<KeyFrequency<A>> getFrequencyDistribution(); Stream<A> getDistinctKeys(); Integer getCountOfDistinctKeys(); Integer getCountForKey(A key); Stream<KeyValue<A, O>> getKeysAndValues();  }
@Test public void testGetCountOfDistinctKeys() { IndexedCollection<Car> cars = createIndexedCollectionOfCars(20); cars.addIndex(HashIndex.onAttribute(Car.MANUFACTURER)); MetadataEngine<Car> metadataEngine = cars.getMetadataEngine(); AttributeMetadata<String, Car> attributeMetadata = metadataEngine.getAttributeMetadata(Car.MANUFACTURER); assertEquals(Integer.valueOf(4), attributeMetadata.getCountOfDistinctKeys()); }