AttributeMetadata { public Stream<A> getDistinctKeys() { QueryOptions queryOptions = openResources(); return asStream(queryOptions, index.getDistinctKeys(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 testGetDistinctKeys() { IndexedCollection<Car> cars = createIndexedCollectionOfCars(20); cars.addIndex(HashIndex.onAttribute(Car.MODEL)); MetadataEngine<Car> metadataEngine = cars.getMetadataEngine(); AttributeMetadata<String, Car> attributeMetadata = metadataEngine.getAttributeMetadata(Car.MODEL); assertEquals( asSet("Accord", "Avensis", "Civic", "Focus", "Fusion", "Hilux", "Insight", "M6", "Prius", "Taurus"), attributeMetadata.getDistinctKeys().collect(toSet()) ); }