'Connecting multimaps to each other in java
I have to count how many rental-ids each film in the sakila database has.
1 film has multiple inventory ids (copies of the same film) and those inventory ids have multiple rental ids.
I'm storing the inventory ids and rental ids in a ListMultimap.
for (Film f: filmList) {
mapOfFilms.put(f.getFilmId(), f.getTitle());
}
//for 1000 films, there are 4581 inventory ids
for (Inventory i: inventoryList) {
mapOfInventory.put(i.getFilmID(), i.getInventoryID());
}
for (Rental r: rentalList) {
mapOfRentals.put(r.getInventoryID(), r.getRentalID());
}
mapOfInventory.putAll(mapOfRentals);
This is allowing me to see for each inventory-id how many rental-ids it has. Output for example -
4579 [582, 2799, 5274, 8289, 12458]
4580 [10479, 15916]
My question is: How would I connect the film map and the inventory map to find the amount of times 1 movie has been rented?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
