Consider a file of the following format containing n number of records & i number of columns. If data needs to be grouped by the first column, what is the efficient way to process it using Java? Let's say that n = 40 million.
The standard way could be using BufferedReader to loop through each line and organized the data in a map with Column A as the key. Is there a more efficient & optimal way?
A1~1~2
A1~2~5
A2~1~3
A1~3~4
....
....
The above file needs to be organized to Map of ColumnA & a POJO as below.
A1 [(1,2),(2,5),(3,4)]
A2 [(1,3)]