- Main Page
- Classes
- Files

- File List

# OptFrame/Parallel/MapReduce++/SeqMR/mapper.hpp

    00001 #ifndef MAPPER_HPP
    00002 #define MAPPER_HPP
    00003 #include <iterator>
    00004
    00006 template<class KeyA, class A, class KeyB, class B, class C>
    00007 class SeqMR_Mapper : public Mapper<KeyA,A,KeyB,B,C>
    00008 {
    00009 public:
    00011         SeqMR_Mapper(MapReduce<KeyA,A,KeyB,B,C> * _mapReduce):mapReduce(_mapReduce){};
    00013 #ifndef MRI_USE_MULTIMAP
    00014         virtual vector< pair<KeyB,B> > run( vector< pair<KeyA,A> > & as )
    00015         {
    00016                 vector< pair<KeyB,B> > bs;
    00017
    00018                 typename vector< pair<KeyA,A> >::iterator itAs;
    00019                 for (itAs = as.begin() ; itAs != as.end() ; ++itAs)
    00020                 {
    00021                         vector< pair<KeyB,B> > bss = map( *itAs );
    00022                         typename vector< pair<KeyB,B> >::iterator itBss;
    00023                         for (itBss = bss.begin() ; itBss != bss.end() ; ++itBss) bs.push_back( *itBss );
    00024                 }
    00025                 return bs;
    00026         };
    00027 #else
    00028         virtual multimap<KeyB,B> run( vector< pair<KeyA,A> > & as )
    00029         {
    00030                 multimap<KeyB,B> bs;
    00031
    00032                 typename vector< pair<KeyA,A> >::iterator itAs;
    00033                 for (itAs = as.begin() ; itAs != as.end() ; ++itAs)
    00034                 {
    00035                         vector< pair<KeyB,B> > bss = map( *itAs );
    00036                         typename vector< pair<KeyB,B> >::iterator itBss;
    00037                         for (itBss = bss.begin() ; itBss != bss.end() ; ++itBss) bs.insert( *itBss );
    00038                 }
    00039                 return bs;
    00040         };
    00041 #endif
    00042
    00043         virtual vector< pair<KeyB,B> > map( pair<KeyA,A> ) = 0 ;
    00044 protected:
    00045         MapReduce<KeyA,A,KeyB,B,C> * mapReduce;
    00046 };
    00047
    00049 class SeqMR_StrMapper : public SeqMR_Mapper<string,string,string,string,string>
    00050 {
    00051 public:
    00053         SeqMR_StrMapper(MapReduce<string,string,string,string,string> * _mapReduce)
    00054                 :SeqMR_Mapper<string,string,string,string,string>(_mapReduce) {};
    00055 };
    00056
    00057 #endif /* MAPPER_HPP */

All Classes Functions