Code Monkey home page Code Monkey logo

camelmr's Introduction

CamelMR: A MapReduce-style CSV Processor in OCaml

CamelMR is a simple MapReduce-style program written in OCaml, designed to process CSV files. It reads a given CSV file, sums up values based on a specified key (e.g., "Finding Type"), and then prints the results, sorted by the sum in descending order.

Prerequisites

  • OCaml
  • Dune build system
  • csv OCaml library
  • parmap OCaml library
  • alcotest OCaml library

Setup

  1. Clone the repository:
git clone <repository-url>
cd <repository-dir>
  1. Install the required libraries:
opam install csv parmap dune alcotest
  1. Build the project:
dune build

Usage

Run the program with the following command:

dune exec -- CamelMR <path_to_csv_file> <column_name_to_aggregate> (optional)<mode>

Replace <path_to_csv_file> with the path to your desired CSV file.

For example:

dune exec -- CamelMR data/sample.csv Name

You can also experiment with simple, parallel and mapreduce(default) runtimes that are provided.

By default the runtime is mapreduce but you can find a lot of performance boost with simple if your dataset is small.

They ultimately do the same, but with different resource usages and can affect how long the script takes to run

dune exec -- CamelMR data/sample.csv Name simple

You can also run the tests in src/test_camelmr.ml with

dune exec -- testCamelMR

How it Works

  1. Map: The program reads the CSV file line by line, extracts the key (based on the specified column name like "Finding Type"), and its associated value.
  2. Shuffle & Group: It then groups the results by key.
  3. Reduce: For each key, it sums up its values in parallel.
  4. Sort & Print: Finally, it sorts the keys based on their summed values in descending order and prints the results.

Customization

To focus on a different key or make other changes, modify the main.ml file in the src directory and recompile.

camelmr's People

Contributors

andree37 avatar

Stargazers

Rúben Ferreira 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.