Programming  >  Research Paper  >  mapreduce University of Illinois, Urbana Champaign - CS 241.c (All)

mapreduce University of Illinois, Urbana Champaign - CS 241.c

Document Content and Description Below

/** * mapreduce Lab * CS 241 - Spring 2019 */ #include "utils.h" #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/wait.h> int main(int argc, ch ... ar **argv) { // Create an input pipe for each mapper. char*input_file=argv[1]; char* output_file=argv[2]; char* mapper_executable=argv[3]; char* reducer_executable=argv[4]; int mapper_count=atoi(argv[5]); int** mapper_pipefds=malloc(mapper_count*sizeof(int*)); // int** splitter_pipefds=malloc(mapper_count*sizeof(int*)); int i =0; for(i=0;i<mapper_count;i++) { mapper_pipefds[i]=malloc(2*sizeof(int)); pipe(mapper_pipefds[i]); } // Create one input pipe for the reducer. int reducer_pipe[2]; pipe(reducer_pipe); // Open the output file. FILE* output_file_wrapper=fopen(output_file,"w"); int output_file_fd=fileno(output_file_wrapper); pid_t *splitter_pids=malloc(sizeof(pid_t)*mapper_count); pid_t *mapper_pids=malloc(sizeof(pid_t)*mapper_count); pid_t pid; i=0; // int ifchild=1; // Start a splitter process for each mapper. int j=0; char mystring[2]="0"; while(i<mapper_count) { // printf("%s %d\n",mystring,i); pid=fork(); splitter_pids[i]=pid; if(pid==0) { dup2(mapper_pipefds[i][1],1); close(reducer_pipe[0]); close(reducer_pipe[1]); fclose(output_file_wrapper); for(j=0;j<mapper_count;j++) { close(mapper_pipefds[j][1]); close(mapper_pipefds[j][0]); } execl("./splitter","./splitter",input_file,argv[5],mystring, (char*)NULL); perror("something is wrong,i'm at 42\n"); return 0; } [Show More]

Last updated: 3 years ago

Preview 1 out of 3 pages

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)
Preview image of mapreduce  University of Illinois, Urbana Champaign - CS 241.c document

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Reviews( 0 )

$6.00

Buy Now

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Instant download

Can't find what you want? Try our AI powered Search

78
0

Document information


Connected school, study & course


About the document


Uploaded On

Apr 02, 2021

Number of pages

3

Written in

All

Seller


Profile illustration for Muchiri
Muchiri

Member since 4 years

209 Documents Sold

Reviews Received
19
5
1
1
6
Additional information

This document has been written for:

Uploaded

Apr 02, 2021

Downloads

 0

Views

 78

Document Keyword Tags

Recommended For You

Get more on Research Paper »

$6.00
What is Scholarfriends

Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·