- Main Page
- Classes
- Files

- File List

# OptFrame/Parallel/MapReduce++/MapMP/mapreduce.hpp

    00001 #ifndef MAPREDUCE_HPP
    00002 #define MAPREDUCE_HPP
    00003
    00004 #include <omp.h>
    00005
    00007 template<class KeyA, class A, class KeyB, class B, class C>
    00008 class MapMP_MapReduce : public MapReduce<KeyA,A,KeyB,B,C>
    00009 {
    00010 public:
    00011         MapMP_MapReduce():numThreads(1){};
    00012
    00014         virtual vector< pair<KeyB,C> > run( Mapper<KeyA,A,KeyB,B,C> & mapper, Reducer<KeyA,A,KeyB,B,C> & reducer, vector< pair<KeyA,A> > & as)
    00015         {
    00016                 //cout << "Input  :\t" << as << endl;
    00017                 omp_set_num_threads(getNumThreads());
    00018 #ifndef MRI_USE_MULTIMAP
    00019                 vector< pair<KeyB,B> > bs = mapper.run( as );
    00020 #else
    00021                 multimap<KeyB,B> bs = mapper.run( as );
    00022 #endif
    00023                 //cout << "Mapped :\t" << bs << endl;
    00024                 omp_set_num_threads(getNumThreads());
    00025                 vector< pair<KeyB,C> > cs = reducer.run( bs );
    00026                 //cout << "Reduced:\t" << cs << endl;
    00027                 return cs;
    00028         };
    00029
    00030         void setNumThreads(int n) { numThreads = n; };
    00031         int  getNumThreads()  { return numThreads; };
    00032 private:
    00033         int numThreads;
    00034 };
    00035
    00037 class MapMP_StrMapReduce : public MapMP_MapReduce<string,string,string,string,string> {};
    00038
    00039 #endif /* MAPREDUCE_HPP */

All Classes Functions