AttributeMetadata { public Stream<KeyFrequency<A>> getFrequencyDistribution() { QueryOptions queryOptions = openResources(); return asKeyFrequencyStream(queryOptions, index.getStatisticsForDistinctKeys(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 testGetFrequencyDistribution() { IndexedCollection<Car> cars = createIndexedCollectionOfCars(20); cars.addIndex(HashIndex.onAttribute(Car.MANUFACTURER)); MetadataEngine<Car> metadataEngine = cars.getMetadataEngine(); AttributeMetadata<String, Car> sortedAttributeMetadata = metadataEngine.getAttributeMetadata(Car.MANUFACTURER); assertEquals( asSet(frequency("Ford", 6), frequency("BMW", 2), frequency("Toyota", 6), frequency("Honda", 6)), sortedAttributeMetadata.getFrequencyDistribution().collect(toSet()) ); }