Skip to content

Implementation of MapReduce using TTG - #221

Draft
pnookala wants to merge 2 commits into
TESSEorg:masterfrom
pnookala:mapreduce-example
Draft

Implementation of MapReduce using TTG#221
pnookala wants to merge 2 commits into
TESSEorg:masterfrom
pnookala:mapreduce-example

Conversation

@pnookala

@pnookala pnookala commented Mar 4, 2022

Copy link
Copy Markdown
Collaborator

This example counts the words in given files and prints the output to screen. Reduction is inefficient since it happens in a single process. This example works with the parsec backend, but there is an issue with the madness backend where it complains about unprocessed tasks, but the tasks actually get executed. This could be a problem with hashing std::string and needs to be fixed.

using namespace ttg;

template<typename T>
using Key = std::pair<std::pair<std::string, T>, T>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to send the filename as part of the key? Is it used after reading from the file?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example counts words from multiple files. In order to keep the keys unique, I included filename in the key. We can probably come up with a different way of having unique keys as well without using the filename like a file ID for example.

{
std::transform(word.begin(), word.end(), word.begin(), ::tolower);
//std::cout << "Mapped " << word << std::endl;
resultMap.insert(std::make_pair(word, 1));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the chunk contains the same word twice? And why use a multimap in the first place?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used multimap to be able to hold duplicate keys and have them sorted which makes counting easier in this example.

@therault
therault marked this pull request as draft April 25, 2022 15:44
@evaleev
evaleev force-pushed the master branch 4 times, most recently from a2878ce to a49eb91 Compare November 24, 2025 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants