MATLAB DATABASE TOOLBOX RELEASE NOTES User's Guide Page 429

  • Download
  • Add to my manuals
  • Print
  • Page
    / 684
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 428
Analyze Large Data Sets in a Database with MapReduce
6-87
% intermKey is 'PartialCountSumDelay'
count = 0;
sum = 0;
while hasnext(intermValIter)
countSum = getnext(intermValIter);
count = count + countSum(1);
sum = sum + countSum(2);
end
meanDelay = sum/count;
% The key-value pair added to outKVStore will become the output of mapreduce
add(outKVStore,'MeanArrivalDelay',meanDelay);
Run MapReduce Using the Mapper and Reducer Functions
Run MapReduce with the DatabaseDatastore object dbds, mapper function
meanArrivalDelayMapper, and reducer function meanArrivalDelayReducer to
calculate the mean arrival delay in the flight data.
outds = mapreduce(dbds,@meanArrivalDelayMapper,@meanArrivalDelayReducer);
Display the Output from MapReduce
Read the table outtab from the output datastore outds using readall.
outtab = readall(outds)
outtab =
Key Value
______ ________
'MeanArrivalDelay' [7.12]
The table has only one row containing one key-value pair.
Display the mean arrival delay meanArrDelay from the table outtab.
meanArrDelay = outtab.Value{1}
meanArrDelay =
7.12
Close the DatabaseDatastore
Close the DatabaseDatastore, cursor, and database connection.
Page view 428
1 2 ... 424 425 426 427 428 429 430 431 432 433 434 ... 683 684

Comments to this Manuals

No comments