I am new to Java and trying to write a program..
here is the code. In the function reduce when count = 14, the program gets stuck…Plz let me know what am i doing wrong..
public static class MerkleReducer extends MapReduceBase
implements Reducer<LongWritable, Text, LongWritable, Text> {
static String[][] sarray = new String[5][14];
static int count = 0;
private void MerkleReducer() {
for (int i=0;i<5;i++)
for (int j=0; j<14;j++)
sarray[i][j] += "";
}
public void reduce(LongWritable key, Iterator<Text> values
OutputCollector<LongWritable, Text> output, Reporter reporter) throws IOException {
count++;
Text hashval = new Text();
while (values.hasNext()) {
hashval = values.next();
}
sarray[0][(int)key.get()] += hashval.toString();
if (count == 14) {
for (int i=1; i<5; i++) {
for (int j=0; j<7; j = j++) {
int k = 2 * j;
String hashv= new String();
if ("".equals(sarray[i-1][k])) {
break;
}
if ("".equals(sarray[i-1][k+1])) {
sarray[i][j] = sarray[i-1][k];
break;
}
hashv += sarray[i-1][k] + sarray[i-1][k+1];
sarray[i][j] += hashv;
}
}
output.collect(key, new Text(sarray[3][0]));
} else {
output.collect(key, new Text(hashval.toString()));
}
}
}
j = j++meansjwill never change, it will take the current value ofj, incrementj, then assign the old value back toj.