Buggy code:
public class SSVDSolver { private double [ ] svalues ; private boolean computeU = true ; private boolean computeV = true ; private String uPath ; private String vPath ; private final Configuration conf ; private final Path [ ] inputPath ; private final Path outputPath ; private final int ablockRows ; private final int outerBlockHeight ; private final int k ; private final int p ; private int q ; private final int reduceTasks ; private int minSplitSize = - 1 ; private boolean cUHalfSigma ; private boolean cVHalfSigma ; private boolean overwrite ; public SSVDSolver ( Configuration conf , Path [ ] inputPath , Path outputPath , int ablockRows , int outerBlockHeight , int k , int p , int reduceTasks ) { } public void setcUHalfSigma ( boolean cUHat ) { } public void setcVHalfSigma ( boolean cVHat ) { } public int getQ ( ) { } public void setQ ( int q ) { } public void setComputeU ( boolean val ) { } public void setComputeV ( boolean val ) { } public void setMinSplitSize ( int size ) { } public double [ ] getSingularValues ( ) { } public String getUPath ( ) { } public String getVPath ( ) { } public boolean isOverwrite ( ) { } public void setOverwrite ( boolean overwrite ) { } public void run ( ) throws IOException { Deque < Closeable > closeables = new LinkedList < Closeable > ( ) ; try { Class < ? extends Writable > labelType = SSVDSolver . sniffInputLabelType ( inputPath , conf ) ; FileSystem fs = FileSystem . get ( conf ) ; Path qPath = new Path ( outputPath , "Q-job" ) ; Path btPath = new Path ( outputPath , "Bt-job" ) ; Path uHatPath = new Path ( outputPath , "UHat" ) ; Path svPath = new Path ( outputPath , "Sigma" ) ; Path uPath = new Path ( outputPath , "U" ) ; Path vPath = new Path ( outputPath , "V" ) ; if ( overwrite ) { fs . delete ( outputPath , true ) ; } Random rnd = RandomUtils . getRandom ( ) ; long seed = rnd . nextLong ( ) ; QJob . run ( conf , inputPath , qPath , ablockRows , minSplitSize , k , p , seed , reduceTasks ) ; BtJob . run ( conf , inputPath , qPath , btPath , minSplitSize , k , p , outerBlockHeight , ( ( reduceTasks ) > 1000 ? 1000 : reduceTasks ) , labelType , ( ( q ) <= 0 ) ) ; <START_BUG> for ( int i = 0 ; i < ( q ) ; ( q ) -- ) { <END_BUG> qPath = new Path ( outputPath , String . format ( "ABt-job-%d" , ( i + 1 ) ) ) ; ABtJob . run ( conf , inputPath , new Path ( btPath , ( ( BtJob . OUTPUT_BT ) + "-*" ) ) , qPath , ablockRows , minSplitSize , k , p , outerBlockHeight , reduceTasks ) ; btPath = new Path ( outputPath , String . format ( "Bt-job-%d" , ( i + 1 ) ) ) ; BtJob . run ( conf , inputPath , qPath , btPath , minSplitSize , k , p , outerBlockHeight , ( ( reduceTasks ) > 1000 ? 1000 : reduceTasks ) , labelType , ( i == ( ( q ) - 1 ) ) ) ; } UpperTriangular bbt = SSVDSolver . loadAndSumUpperTriangularMatrices ( fs , new Path ( btPath , ( ( BtJob . OUTPUT_BBT ) + "-*" ) ) , conf ) ; assert ( bbt . columnSize ( ) ) == ( ( k ) + ( p ) ) ; double [ ] [ ] bbtSquare = new double [ ( k ) + ( p ) ] [ ] ; for ( int i = 0 ; i < ( ( k ) + ( p ) ) ; i ++ ) { bbtSquare [ i ] = new double [ ( k ) + ( p ) ] ; } for ( int i = 0 ; i < ( ( k ) + ( p ) ) ; i ++ ) { for ( int j = i ; j < ( ( k ) + ( p ) ) ; j ++ ) { bbtSquare [ i ] [ j ] = bbtSquare [ j ] [ i ] = bbt . getQuick ( i , j ) ; } } svalues = new double [ ( k ) + ( p ) ] ; EigenSolverWrapper eigenWrapper = new EigenSolverWrapper ( bbtSquare ) ; double [ ] eigenva2 = eigenWrapper . getEigenValues ( ) ; for ( int i = 0 ; i < ( ( k ) + ( p ) ) ; i ++ ) { svalues [ i ] = Math . sqrt ( eigenva2 [ i ] ) ; } double [ ] [ ] uHat = eigenWrapper . getUHat ( ) ; fs . mkdirs ( uHatPath ) ; SequenceFile . Writer uHatWriter = SequenceFile . createWriter ( fs , conf , ( uHatPath = new Path ( uHatPath , "uhat.seq" ) ) , IntWritable . class , VectorWritable . class , BLOCK ) ; closeables . addFirst ( uHatWriter ) ; int m = uHat . length ; IntWritable iw = new IntWritable ( ) ; VectorWritable vw = new VectorWritable ( ) ; for ( int i = 0 ; i < m ; i ++ ) { vw . set ( new DenseVector ( uHat [ i ] , true ) ) ; iw . set ( i ) ; uHatWriter . append ( iw , vw ) ; } closeables . remove ( uHatWriter ) ; Closeables . closeQuietly ( uHatWriter ) ;

Fix:
for ( int i = 0 ; i < ( q ) ; i ++ ) {