mercredi 17 octobre 2018

create a key value pair by map reducing by using multithreads ,stuck on creating multi threads using a mapping fuction

I have been trying to work on this project to create a key value pair by map reducing by using multithreads and I am stuck on creating multi threads using a mapping fuction.I get overloading operator error.

for (std::vector::iterator vect_it = myvector.begin(); vect_it != myvector.end(); ++vect_it) { mapping(mymap, vect_it);

    t[i] = std::thread(mapping, mymap, vect_it);

    i++;

}

std::multimap<std::string, int> reducer(std::map<std::string, int> &map_input, std::multimap<std::string, int> & map_input_reducer, std::map<std::string, int>::iterator & map_it)

{ int key_value = 0;

for (std::vector::iterator vect_it = myvector.begin(); vect_it != myvector.end(); ++vect_it) {

    if (map_it->first == *vect_it) 

{ key_value += 1;

    }
    std::vector<std::string>::iterator second_last_vect_it = vect_it;

    if (++second_last_vect_it == myvector.end()) {

        mymap_reduced.insert(std::pair<std::string, int>(map_it->first, key_value));

    }
}

return mymap_reduced;

}

Aucun commentaire:

Enregistrer un commentaire