How to use .groupby with few restrictions in the Kafka Streams API. Same as Java Streams API Example below
public void twoLevelGrouping(List<Person> persons) {
final Map<String, Map<String, List<Person>>> personsByCountryAndCity = persons.stream().collect(
groupingBy(Person::getCountry,
groupingBy(Person::getCity)
)
);
System.out.println("Persons living in London: " + personsByCountryAndCity.get("UK").get("London").size());
}
source
share