AttributeMetadata { public Stream<KeyValue<A, O>> getKeysAndValues() { QueryOptions queryOptions = openResources(); return asStream(queryOptions, index.getKeysAndValues(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 testGetKeysAndValues() { IndexedCollection<Car> cars = new ConcurrentIndexedCollection<>(); Car car1 = new Car(1, "Ford", "Taurus", Car.Color.GREEN, 4, 1000.0, emptyList(), Collections.emptyList()); Car car2 = new Car(2, "Honda", "Civic", Car.Color.BLUE, 4, 2000.0, emptyList(), Collections.emptyList()); Car car3 = new Car(3, "Honda", "Accord", Car.Color.RED, 4, 3000.0, emptyList(), Collections.emptyList()); cars.addAll(asList(car1, car2, car3)); cars.addIndex(HashIndex.onAttribute(Car.MANUFACTURER)); MetadataEngine<Car> metadataEngine = cars.getMetadataEngine(); AttributeMetadata<String, Car> attributeMetadata = metadataEngine.getAttributeMetadata(Car.MANUFACTURER); assertEquals( asSet(keyValue("Ford", car1), keyValue("Honda", car2), keyValue("Honda", car3)), attributeMetadata.getKeysAndValues().collect(toSet()) ); }