question: public static void compareDMLMatrixWithJavaMatrixRowsOutOfOrder ( String expectedFile , String actualDir , double epsilon ) { try { FileSystem fs = FileSystem . get ( conf ) ; Path outDirectory = new Path ( actualDir ) ; Path compareFile = new Path ( expectedFile ) ; FSDataInputStream fsin = fs . open ( compareFile ) ; BufferedReader compareIn = new BufferedReader ( new InputStreamReader ( fsin ) ) ; HashMap < CellIndex , Double > expectedValues = new HashMap < CellIndex , Double > ( ) ; String line ; while ( ( line = compareIn . readLine ( ) ) != null ) { StringTokenizer st = new StringTokenizer ( line , " " ) ; int i = Integer . parseInt ( st . nextToken ( ) ) ; int j = Integer . parseInt ( st . nextToken ( ) ) ; double v = Double . parseDouble ( st . nextToken ( ) ) ; expectedValues . put ( new CellIndex ( i , j ) , v ) ; } compareIn . close ( ) ; HashMap < CellIndex , Double > actualValues = new HashMap < CellIndex , Double > ( ) ; FileStatus [ ] outFiles = fs . listStatus ( outDirectory ) ; for ( FileStatus file : outFiles ) { FSDataInputStream fsout = fs . open ( file . getPath ( ) ) ; BufferedReader outIn = new BufferedReader ( new InputStreamReader ( fsout ) ) ; while ( ( line = outIn . readLine ( ) ) != null ) { StringTokenizer st = new StringTokenizer ( line , " " ) ; int i = Integer . parseInt ( st . nextToken ( ) ) ; int j = Integer . parseInt ( st . nextToken ( ) ) ; double v = Double . parseDouble ( st . nextToken ( ) ) ; actualValues . put ( new CellIndex ( i , j ) , v ) ; } outIn . close ( ) ; } ArrayList < Double > e_list = new ArrayList < Double > ( ) ; for ( CellIndex index : expectedValues . keySet ( ) ) { Double expectedValue = expectedValues . get ( index ) ; if ( expectedValue != 0.0 ) e_list . add ( expectedValue ) ; } ArrayList < Double > a_list = new ArrayList < Double > ( ) ; for ( CellIndex index : actualValues . keySet ( ) ) { Double actualValue = actualValues . get ( index ) ; if ( actualValue != 0.0 ) a_list . add ( actualValue ) ; } Collections . sort ( e_list ) ; Collections . sort ( a_list ) ; assertTrue ( "Matrix nzs not equal" , e_list . size ( ) == a_list . size ( ) ) ; for ( int i = 0 ; i < e_list . size ( ) ; i ++ ) { assertTrue ( "Matrix values not equals" , Math . abs ( e_list . get ( i ) - a_list . get ( i ) ) <= epsilon ) ; } } catch ( IOException e ) { fail ( "unable to read file: " + e . getMessage ( ) ) ; } }
target:  Compares contents of an expected file with the actual file, where rows may be permuted