Solved

Consider the Following Mapper Code: 1 #!/Usr/bin/env Python3

Question 57

Multiple Choice

Consider the following mapper code: 1 #!/usr/bin/env python3
2 # length_mapper.py
3 """Maps lines of text to key-value pairs of word lengths and 1."""
4 import sys
5
6 def tokenize_input() :
7 """Split each line of standard input into a list of strings."""
8 for line in sys.stdin:
9 yield line.split()
10
11 # read each line in the the standard input and for every word
12 # produce a key-value pair containing the word, a tab and 1
13 for line in tokenize_input() :
14 for word in line:
15 print(str(len(word) ) + '\t1')
Which of the following statements a) , b) or c) is false.


A) Generator function tokenize_input reads lines of text from the standard input stream and for each returns a list of strings.
B) When Hadoop executes the script, lines 13-15 iterate through the lists of strings from tokenize_input. For each list (line) and for every string (word) in that list, the script outputs a key-value pair with the word's length as the key, a tab (\t) and the value 1, indicating that there is one word (so far) of that length. Of course, there probably are many words of that length.
C) The MapReduce algorithm's reduction step will summarize these key-value pairs.
D) All of the above statements are true.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents