Question: / * Given a filename, figure out if it's a directory or text file. * If text file ( base case ) , scan it
Given a filename, figure out if it's a directory or text file.
If text file base case scan it incrementing word counts as you go
If directory, recurse.
Otherwise, ignore
void processfilechar name amapt m
YOUR CODE HERE
What kind of file is it
Hint: use checktype
if FTYPEREG: use countwords Note arg types expected by it
Hint: fdopen
Hint: account for what checktype does with a regular file.
if FTYPEDIR: use opendir and readdir t get entries,
and recursively process each.
if anything else, ignore it
Driver for the scanning process.
Process the files under the given name processfile recursively,
incrementing count in the map for each word found in a text file.
Then write the contents of the map to each reducer pipe, according to
the first letter of the word using the writepipes map
Then close all the write ends of the reducer pipes.
Parameters:
nprocs # of scannersreducerspipes
map sorted map of words to counts
startname filedir to process
reducepipes array of pipe fds to get counts to reducers
THIS FUNCTION DOES NOT RETURN
void scannerint nprocs, amapt map char startname pipet reducepipes
YOUR CODE HERE
first call processfile on the startname.
Then write each stringcount pair in the map to the appropriate
reducer.
Hint: use amapgetnext
Hint: whichpipe maps character #s ab etc. to reduce pipe #s
the first letter of the word using the writepipes map
Parameters:
nprocs # of scannersreducerspipes
map sorted map of words to counts
startname filedir to process
reducepipes array of pipe fds to get counts to reducers
THIS FUNCTION DOES NOT RETURN
void scannerint nprocs, amapt map char startname pipet reducepipes
YOUR CODE HERE
first call processfile on the startname.
Then write each stringcount pair in the map to the appropriate
reducer.
Hint: use amapgetnext
Hint: whichpipe maps character #s ab etc. to reduce pipe #s
Then close my write end of each reduce pipe.
Then close my write end of each reduce pipe.
exit; all done!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
