使用 partitioner 和 combiner
下面的程序是对 hadoop 1.0.3 自带例子(src/examples/pipes/impl/wordcount-part.cc)的一个修改版:
#include <string>
#include <vector>
using namespace std;
#include <hadoop/Pipes.hh>
#include <hadoop/StringUtils.hh>
#include <hadoop/TemplateFactory.hh>
class WordCountMapper : public HadoopPipes::Mapper {
public:
WordCountMapper(HadoopPipes::TaskContext& context) {}
void map(HadoopPipes::MapContext& context)
{
vector<string> words = HadoopUtils::splitString(context.getInputValue(), "
… 阅读全文…