I have 2 csv files so defined 2 objects i.e. Person and Address. Person can have multiple addresses objects. I need to join and perform aggregation on data. This is similar to having 2 separate tables in database and performing join. What would be right approach to achieve this? Any options in steaming/Lambda? If not any framework you can recommend?
Thanks, Kam
I don't think there is an equivalent of join in standard library. The closest you can do is something like
Map<String, Person> pMap = persons.stream
.collect(Collectors.groupingBy(Person::getId);
List<Pair<Person,Address>> joined = addresses.stream
.map (a -> new Pair(pMap.get(a.personId()), a));
etc.
(Note, that I made up a class Pair here, because there is (still) no such thing as a tuple in java).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With