- requirements, MySQL table in a log table, require the average record period of statistical data, learning in practice, with MySQL may be more troublesome, then use the newly-contacted MongoDB bar, but also with the Hadoop research last year to touch the edge, and MongoDB support MapReduce, Last year has been want to know more, but too busy, no time, just now look at the study.
- Using the command line is tiring, so using the Mongovue, this tool.
- Started:
- Parse table structure, useful field one is the record ID (repeatable), one is the time the record is generated;
- Import the required fields and data into MongoDB;
- Write the first mapreduce, merging the time that is generated by the record, as follows:
{"ID": "1001", "DATES": [' 2014/2/10 ', ' 2014/2/9 ', ' 2014/2/6 ']}
- Write the second mapreduce, averaging the time for each record, as above:
((February 10-February 9) + (February 9-February 6)) divided by 2
- Finally, all records are again calculated
- The first step is to import the data step (the borrowed image found on the Web):
- Select MySQL Database
- Establishing a database connection
MongoDB MapReduce Combat <1>