Question

gender) in HDFS, write a MapReduce Given a 10TB table Student (name, year, program to compute the following query. gpa, SELEC

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution :

map (k, student) {
// here we can add the where clause condition
if (student.gender == 'male') {
// here we can get the data in map
stud1 = <student.year, student.gpa>
// here we can collect all the data
collect (student.year , stud1)
}
}
// Here each yr that reduce gets corresponds to a unique value in student.year field.
// Group by is implicitly done using the shuffling phase between map and reduce functions.

reduce(yr, studentList<stud1>) {
avg := 0
// for loop iterate upto the length of studentList
for each student in studentList {
// sum the gpa of all student
avg += student.gpa
}
// calculate the gpa avg of all students
avg := avg / size(studentList)
// assign map to stud2 variable
stud2 = <student.year, avg>
// store the data
store (yr, stud2)
}

1 map (k, student) // here we can add the where clause condition if (student.gendermale) // here we can get the data in map

Add a comment
Know the answer?
Add Answer to:
gender) in HDFS, write a MapReduce Given a 10TB table Student (name, year, program to compute the following query. gpa, SELECTyear, AVG (gpa) FROM WHERE GROUP BY year Student gender'Male' Ans...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT