OK, continue to complete the second demand, to find the number of records in a day statistics, directly run the "Combat 4" prepared MapReduce, the exception is not a number Nan, through the analysis of the results, found the reason, the reason appears in the first MapReduce, the evidence:
As can be seen in the above image, the times are nested, which leads to an exception in the operation of the problem, need to modify the first mapreduce in the reduce, increase the judgment of the nesting
function Reduce (key, values) {
var ret={rfid:key};
var times = new Array ();
for (var i = 0;i < values.length;i++) {
if (values[i].times) {Times
= Times.concat (values[i].times);
} else{
Times.push (Values[i]);
}
}
Ret.times = times;
return ret;
}
Rerun the first MapReduce, then run the second requirement MapReduce, without any modification, to produce the result
From the results, the record in 1 days is 41 times, 42 times in 2 days ...