public static HashMap<CellIndex,Double> readDMLMatrixFromHDFS(String filePath){
  HashMap<CellIndex,Double> expectedValues=new HashMap<CellIndex,Double>();
  try {
    FileSystem fs=FileSystem.get(conf);
    Path outDirectory=new Path(filePath);
    String line;
    FileStatus[] outFiles=fs.listStatus(outDirectory);
    for (    FileStatus file : outFiles) {
      FSDataInputStream outIn=fs.open(file.getPath());
      BufferedReader reader=new BufferedReader(new InputStreamReader(outIn));
      while ((line=reader.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);
      }
      outIn.close();
    }
  }
 catch (  IOException e) {
    assertTrue("could not read from file " + filePath,false);
  }
  return expectedValues;
}

public static HashMap < CellIndex , Double > readDMLMatrixFromHDFS ( String filePath ) { HashMap < CellIndex , Double > expectedValues = new HashMap < CellIndex , Double > ( ) ; try { FileSystem fs = FileSystem . get ( conf ) ; Path outDirectory = new Path ( filePath ) ; String line ; FileStatus [ ] outFiles = fs . listStatus ( outDirectory ) ; for ( FileStatus file : outFiles ) { FSDataInputStream outIn = fs . open ( file . getPath ( ) ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( outIn ) ) ; while ( ( line = reader . 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 ) ; } outIn . close ( ) ; } } catch ( IOException e ) { assertTrue ( "could not read from file " + filePath , false ) ; } return expectedValues ; }
reads values from a matrix file in hdfs in dml format
