Coder Social home page Coder Social logo

producer-consumer-using-system-calls's Introduction

producer-consumer-using-fork

Mapper program gets the input from a file that contains tuples in the form (userID, action, topic). userID is a 4-digit identification for the users of a social media site. Action can be one of the following letters: P for posting, L for liking, D for disliking, C for commenting, and S for sharing. Topic is a string of exactly 15 characters (shorter names will be padded with space). The mapper program processes these tuples to generate a weighted profile in the form (userID, topic, score) based on a set of rules, which are defined as P=50, L=20, D=-10, C=30, S=40. You can assume that the tuples are sorted according to userID field but tuples that belong to the same userID may not be sorted according to the topic. As an example, the input may look like (1111,P,history), (1111,S,entertainment), (1111,L,history), (1111,L,cosmetics), (2222,L,sports), (2222,S,sports), (3333,S,photography), (3333,L,art), (3333,P,art) (note the omitted white space in topic names) and the correct output (on the standard output) would be (1111,history,50), (1111,entertainment,40), (1111,history,20),(1111,cosmetics,20), (2222,sports,20), (2222,sports,40), (3333,photography,40), (3333,art,20), (3333,art,50)

Note that the Mapper program should output each tuple (userID, topic, score) as soon as it processes the corresponding (userID, action, topic) tuple. Also, each tuple should be output on a separate line (although shown in a condensed form above.)

Reducer program gets the tuples of the form (userID, topic, score) from the standard input and generates tuples of the form (userID, topic, total score) on the standard output as follows: (1111,history,70) (1111,entertainment,40) (1111,cosmetics,20) (2222,sports,60) (3333,photography,40) (3333,art,70)

Like Mapper’s input, tuples are sorted according to userID field but tuples that belong to the same userID may not be sorted according to the topic. Note that the Reducer outputs the tuple as soon as it realizes that there won’t be any more tuples that belong to the same user. You can assume that the Reducer’s input has a single tuple per line.

Make sure that Reducer detects the end of file character while reading from the standard input.

Combiner program gets its input from a file that contains tuples in the form (userID, action, topic) and generates tuples of the form (userID, topic, total score). Each tuple is output on a separate line. You should use fork, exec, pipe, and dup2 system calls in the Combiner and reuse the Mapper and Reducer programs. Important Note: Implementations of Combiner programs that do not make effective use of these system calls will not get any credit.

producer-consumer-using-system-calls's People

Contributors

saibhargav1508 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.