Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var map = function (key, value, context){ | ||
var flightData = value.split(/,/); | ||
var destAirport = flightData[4]; | ||
var arrivalDelay = flightData[0]; | ||
context.write(destAirport, arrivalDelay); | ||
}; | ||
|
||
var reduce = function (key, values, context) { | ||
var flightCount = 0; | ||
var delaySum = 0; | ||
while (values.hasNext()) { | ||
flightCount++; | ||
delaySum += parseInt(values.next()); | ||
} | ||
context.write(key, flightCount + "\t" + (delaySum*1.0)/(flightCount*1.0)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Using JavaScript for MapReduce Jobs | ||
============================ | ||
This shows a way to write MapReduce jobs using a JavaScript API | ||
|
||
Setup | ||
============================ | ||
Within the JavaScirpt console | ||
|
||
#mkdir js | ||
fs.put() // put the file into the .js folder | ||
runJs("js/countAndAverageDelayedFlights.js", "asv://airlinedata/", "jsFlightMR2"); |