{"id":25608135,"url":"https://github.com/robertpaulp/map-reduce-inverted-index","last_synced_at":"2026-06-18T06:31:36.540Z","repository":{"id":276993359,"uuid":"894070724","full_name":"robertpaulp/map-reduce-inverted-index","owner":"robertpaulp","description":"Multithread Google Map-Reduce Inverted Index","archived":false,"fork":false,"pushed_at":"2025-02-11T15:05:31.000Z","size":3451,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-21T20:18:53.030Z","etag":null,"topics":["cpp","google-mapreduce","inverted-index","mapreduce-cpp","multithreading","pthreads"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertpaulp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-25T17:42:23.000Z","updated_at":"2025-02-11T15:05:35.000Z","dependencies_parsed_at":"2025-02-11T15:42:42.451Z","dependency_job_id":null,"html_url":"https://github.com/robertpaulp/map-reduce-inverted-index","commit_stats":null,"previous_names":["robertpaulp/map-reduce-inverted-index"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/robertpaulp/map-reduce-inverted-index","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertpaulp%2Fmap-reduce-inverted-index","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertpaulp%2Fmap-reduce-inverted-index/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertpaulp%2Fmap-reduce-inverted-index/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertpaulp%2Fmap-reduce-inverted-index/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertpaulp","download_url":"https://codeload.github.com/robertpaulp/map-reduce-inverted-index/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertpaulp%2Fmap-reduce-inverted-index/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34479552,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","google-mapreduce","inverted-index","mapreduce-cpp","multithreading","pthreads"],"created_at":"2025-02-21T20:18:55.319Z","updated_at":"2026-06-18T06:31:36.522Z","avatar_url":"https://github.com/robertpaulp.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multithread Map-Reduce Inverted Index\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"readme_imgs/google_map_reduce.png\" alt=\"Google MapReduce Framework\"\u003e\n\u003c/p\u003e\n\n## Overview\n\nThis project implements a *parallel inverted index* using the **Map-Reduce** paradigm inspired by Google's MapReduce framework, implemented with **Pthreads**. Given a set of input text files, the program extracts unique words, determines which files contain them, and outputs a structured index for efficient word lookups.\n\n## Performance\n\nRunning with 4 Mapper threads (M=4) and 4 Reducer threads (R=4):\n- Execution time: 0.39 seconds\n- Speedup: 3.03x\n\n## Features\n\n- Implements **Map-Reduce** for parallel word indexing\n\n- Uses **Pthreads** for parallelization\n\n- Outputs results in *sorted files* categorized alphabetically\n\n- Supports *dynamic workload distribution* for efficiency\n\n- Compatible with **Docker** for easy testing and deployment\n\n## How it works\n\n![Inverted Index Results](readme_imgs/inverted_index_result.png)\n\n1. **Mapper Phase**:\n\n    - Reads assigned files\n\n    - Extracts words and converts them to lowercase\n\n    - Outputs *{word, file_ID}* pairs\n\n2. **Reducer Phase**:\n\n    - Aggregates *{word, {file_IDs}}* entries\n\n    - Groups words by their starting letter\n\n    - Sorts words by frequency across files\n\n3. **Output**:\n\n    - Generates one file per alphabet letter (a.txt, b.txt, etc.)\n\n    - Words inside each file are sorted by *frequency* (descending)\n\n    - If multiple words have the same frequency, they are sorted *alphabetically*\n\n## Usage\n\n1. Compile using Makefile:\n\n    ```bash\n    make\n    ```\n\n2. Run the program:\n\n    ```bash\n    ./map_reduce \u003cMap_num_threads\u003e \u003cReduce_num_threads\u003e \u003cinput_file\u003e\n    ```\n\n    - `Map_num_threads`: Number of threads for the **Mapper** phase\n    - `Reduce_num_threads`: Number of threads for the **Reducer** phase\n    - `input_file`: Path to the input file containing the list of text files to index\n\n## Example\n\n- To run the program with 2 **Mapper** threads, 3 **Reducer** threads, and the input file `input.txt`:\n    ```bash\n    ./map_reduce 2 3 input.txt\n    ```\n\n- Where `input.txt` contains the following:\n\n    ```text\n    3\n    file1.txt\n    file2.txt\n    file3.txt\n    ```\n\n- The program will output the inverted index in the following format:\n\n    - `a.txt`\n        ```text\n        and:[2]\n        are:[1]\n        as:[1]\n        ```\n\n    - `b.txt`\n        ```text\n        blue:[1 2]\n        birds:[1]\n        bright:[1]\n        brightly:[3]\n        by:[2]\n        ```\n\n## References\n\n- [Google MapReduce: Simplified Data Processing on Large Clusters](https://static.googleusercontent.com/media/research.google.com/en//archive/mapreduce-osdi04.pdf)\n- [Pthreads](https://computing.llnl.gov/tutorials/pthreads/)\n- [Assigment 1: Map-Reduce Inverted Index](./README_assignment.pdf)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertpaulp%2Fmap-reduce-inverted-index","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertpaulp%2Fmap-reduce-inverted-index","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertpaulp%2Fmap-reduce-inverted-index/lists"}