The final processing results are stored in the "ttt_date_out" table and the next mapreduce is written, and the expected result is the average record generation time Map for all records:
function Map () {
var count_time = 0;
var arv_time = 0;
var times = this.value.times;
if (times) {
if (Times.length > 1) {for
(var i = 0;i < times.length;i++) {
if (i! = times.length-1) {
Co Unt_time + = Times[i]-times[i+1];}}
}
Arv_time = count_time/(times.length-1);
Emit (
' result ',
arv_time
);
}
}
Reduce:
function Reduce (key, values) {
var ret={msg:key};
var count_times = 0;
for (var i = 0;i < values.length;i++) {
count_times + = Values[i];
}
Ret.arv_time = count_times/values.length;
return ret;
}
Finalize: (not in the previous MapReduce, where the main role is to process the results again)
function Finalize (key, reduced) {
//turn to seconds
var second = parsefloat (reduced)/1000;
Turn minute
var minute = parseint (SECOND/60);
Remaining seconds
var s = second%;
Turn hours
var hour = parseint (MINUTE/60);
Remaining points
var m = minute%;
The day after
var day = parseint (hour/24);
Remaining hours
var h = hour%;
Return day + "days" + H + "hour" + M + "minute" + S + "second";
}
Configure in & Out
Final result
Summary: After a day of efforts to complete the expected goal, tomorrow continue to understand, the final operation of the actual log table to see the effect. Maprecude's programming language is JavaScript, just beginning with the command line, writing and reading too much trouble, finally although the use of Mongovue, but debugging is very difficult, no debug. Find a lot of information also no concrete good method, tragedy.