我是Java的新手并且正在尝试编写程序。 这是代码。在count = 14时函数reduce,程序卡住了...... Plz让我知道我做错了什么..
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()));
}
} }
答案 0 :(得分:3)
j = j++
表示j
永远不会更改,它将取j
的当前值,增加j
,然后将旧值重新分配回j
答案 1 :(得分:2)
for (int j=0; j<7; j = j++) {
j = j++
闻起来像无限。