summaryrefslogtreecommitdiff
path: root/hadoop/streaming/partitioner
diff options
context:
space:
mode:
Diffstat (limited to 'hadoop/streaming/partitioner')
-rw-r--r--hadoop/streaming/partitioner/input8
-rwxr-xr-xhadoop/streaming/partitioner/partitioner_test.sh22
-rwxr-xr-xhadoop/streaming/partitioner/partitioner_test1.sh27
3 files changed, 57 insertions, 0 deletions
diff --git a/hadoop/streaming/partitioner/input b/hadoop/streaming/partitioner/input
new file mode 100644
index 0000000..06c6a28
--- /dev/null
+++ b/hadoop/streaming/partitioner/input
@@ -0,0 +1,8 @@
+1.1 a
+2.2 b
+3.1 c
+4.2 d
+4.1 e
+1.2 x
+2.1 y
+4.3 q
diff --git a/hadoop/streaming/partitioner/partitioner_test.sh b/hadoop/streaming/partitioner/partitioner_test.sh
new file mode 100755
index 0000000..bfb2185
--- /dev/null
+++ b/hadoop/streaming/partitioner/partitioner_test.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+
+hadoop dfs -put input input
+
+HADOOP_HOME=/usr/lib/hadoop
+HADOOP_VERSION=0.20.2-cdh3u1
+JAR=contrib/streaming/hadoop-streaming-$HADOOP_VERSION.jar
+HSTREAMING="$HADOOP_HOME/bin/hadoop jar $HADOOP_HOME/$JAR"
+
+OUT=partitioner_test_out
+
+$HSTREAMING \
+ -input input \
+ -output $OUT \
+ -mapper /bin/cat \
+ -jobconf mapred.reduce.tasks=2
+
+hadoop dfs -get $OUT .
+hadoop dfs -rmr $OUT
+hadoop dfs -rm input
+
diff --git a/hadoop/streaming/partitioner/partitioner_test1.sh b/hadoop/streaming/partitioner/partitioner_test1.sh
new file mode 100755
index 0000000..759f823
--- /dev/null
+++ b/hadoop/streaming/partitioner/partitioner_test1.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+
+hadoop dfs -put input input
+
+HADOOP_HOME=/usr/lib/hadoop
+HADOOP_VERSION=0.20.2-cdh3u1
+JAR=contrib/streaming/hadoop-streaming-$HADOOP_VERSION.jar
+HSTREAMING="$HADOOP_HOME/bin/hadoop jar $HADOOP_HOME/$JAR"
+
+OUT=partitioner_test1_out
+
+$HSTREAMING \
+ -input input \
+ -output $OUT \
+ -mapper /bin/cat \
+ -jobconf mapred.reduce.tasks=2 \
+ -partitioner org.apache.hadoop.mapred.lib.KeyFieldBasedPartitioner \
+ -jobconf stream.map.output.field.separator="\t" \
+ -jobconf map.output.key.field.separator=. \
+ -jobconf stream.num.map.output.key.fields=2 \
+ -jobconf mapred.text.key.partitioner.options=-k1
+
+hadoop dfs -get $OUT .
+hadoop dfs -rmr $OUT
+hadoop dfs -rm input
+