summaryrefslogtreecommitdiff
path: root/hadoop/streaming/secondary_sort/secondary_sort.sh
blob: c45f3817c93b4e66700da01bb11f20c4562bb12c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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