I have two Multimaps which have been created from two huge CSV files.
Multimap<String, SomeClassObject> mapOne = ArrayListMultimap.create();
Multimap<String, SomeClassObject> mapTwo = ArrayListMultimap.create();
I have assumed one CSV column to be as a Key and each of the Key has thousands of values associated with it. Data contained within these Multimap
s should be same. Now I want to compare the data within these Multimap
s and find if any values are different. Here are the two approaches I am thinking of:
Approach One:
Make one big list from the Multimap
. This big list will contain a few individual lists. Each of the smaller lists contains a unique value which is the "key" read from Multimap
along with its associated values, which will form the rest of that individual list.
ArrayList<Collection<SomeClassObject>> bigList = new ArrayList<Collection<SomeClassObject>>();
Within bigList
will be individual small lists A, B, C etc.
I plan on picking individual lists from each bigList
of the two files on the basis of checking that individual list from second Multimap
contains that "key" element. If it does, then compare both of these lists and find anything that could not be matched.
Approach Two:
Compare both the Multimap
s but I am not sure how will that be done.
Which approach should have smaller execution time? I need the operation to be completed in minimum amount of time.