MATLAB DATABASE TOOLBOX RELEASE NOTES Guide de l'utilisateur Page 429

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 684
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 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.
Vue de la page 428
1 2 ... 424 425 426 427 428 429 430 431 432 433 434 ... 683 684

Commentaires sur ces manuels

Pas de commentaire