From 26c490f404731d053a6205719b6246502c07b449 Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Sat, 14 Jun 2014 16:46:27 +0200
Subject: init
---
hadoop/wordcount/pipes/wordcount.cc | 38 +++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 hadoop/wordcount/pipes/wordcount.cc
(limited to 'hadoop/wordcount/pipes/wordcount.cc')
diff --git a/hadoop/wordcount/pipes/wordcount.cc b/hadoop/wordcount/pipes/wordcount.cc
new file mode 100644
index 0000000..c9394d5
--- /dev/null
+++ b/hadoop/wordcount/pipes/wordcount.cc
@@ -0,0 +1,38 @@
+#include "wordcount.hh"
+
+
+void
+WordcountMapper::map(HadoopPipes::MapContext &context)
+{
+ typedef boost::tokenizer<> tokenizer_t;
+ tokenizer_t tokenizer(context.getInputValue());
+
+ for(tokenizer_t::const_iterator i = tokenizer.begin();
+ tokenizer.end() != i; ++i) {
+ context.emit(boost::to_lower_copy(*i), "1");
+ }
+}
+
+void
+WordcountReducer::reduce(HadoopPipes::ReduceContext &context)
+{
+ uint32_t count(0);
+
+ do {
+ ++count;
+ } while(context.nextValue());
+
+ //std::cout << context.getInputKey() << endl;
+ context.emit(context.getInputKey(),
+ boost::lexical_cast