summaryrefslogtreecommitdiff
path: root/hadoop/streaming/secondary_sort
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-06-14 19:03:21 +0200
committerPatrick Simianer <p@simianer.de>2014-06-14 19:03:21 +0200
commit5ddc763ab9953eebdaf78af4eb72288d7955b310 (patch)
treefffaf3d22173feae684b7c02ce86c67cf77c7fec /hadoop/streaming/secondary_sort
parent26c490f404731d053a6205719b6246502c07b449 (diff)
cleanup
Diffstat (limited to 'hadoop/streaming/secondary_sort')
-rw-r--r--hadoop/streaming/secondary_sort/input8
-rwxr-xr-xhadoop/streaming/secondary_sort/secondary_sort.sh30
2 files changed, 38 insertions, 0 deletions
diff --git a/hadoop/streaming/secondary_sort/input b/hadoop/streaming/secondary_sort/input
new file mode 100644
index 0000000..5aa7ec9
--- /dev/null
+++ b/hadoop/streaming/secondary_sort/input
@@ -0,0 +1,8 @@
+0-*-1 a:1 a:2 a:3
+0-*-2 a:1 a:2 a:3
+0-*-10 a:1 a:2 a:3
+1-*-2 a:1 a:2 a:3
+2-*-0 a:1 a:2 a:3
+2-*-2 a:1 a:2 a:3
+3-*-3 a:1 a:2 a:3
+10-*-0 a:1 a:2 a:3
diff --git a/hadoop/streaming/secondary_sort/secondary_sort.sh b/hadoop/streaming/secondary_sort/secondary_sort.sh
new file mode 100755
index 0000000..c45f381
--- /dev/null
+++ b/hadoop/streaming/secondary_sort/secondary_sort.sh
@@ -0,0 +1,30 @@
+#!/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=secondary_sort_out
+
+$HSTREAMING \
+ -input input \
+ -output $OUT \
+ -partitioner org.apache.hadoop.mapred.lib.KeyFieldBasedPartitioner \
+ -jobconf map.output.key.field.separator="-*-" \
+ -jobconf mapred.text.key.partitioner.options="-k1,1n" \
+ -mapper /bin/cat \
+ -reducer org.apache.hadoop.mapred.lib.IdentityReducer \
+ -jobconf mapred.output.key.comparator.class=org.apache.hadoop.mapred.lib.KeyFieldBasedComparator \
+ -jobconf stream.num.map.output.key.fields=2 \
+ -jobconf stream.map.output.field.separator="\t" \
+ -jobconf mapred.text.key.comparator.options="-k1,1n -k2,2nr" \
+ -jobconf mapred.reduce.tasks=3
+
+hadoop dfs -get $OUT .
+hadoop dfs -rmr $OUT
+hadoop dfs -rm input
+