-1

I only want to partition the data where the first field of key is same as the reducer.
For example, [ 11 * * * ] data . But it seems keypartitioner does not work, I really don't know why.

Environment enter image description here

Hadoop Version enter image description here

The code run.sh is here --->

#!/usr/bin/sh


hadoop fs -rm -r /training/likang/tmp2
hadoop fs -rm /training/likang/tmp/testfile
hadoop fs -put testfile1 /training/likang/tmp/testfile


hadoop-streaming -D stream.map.output.field.separator="\t" \
                -D stream.num.map.output.key.fields=2 \
                -D map.output.key.field.separator="\t" \
                -D mapreduce.partition.keypartitioner.options=-k1,1 \
                -D mapreduce.job.maps=2 \
                -D mapreduce.job.reduces=2 \
                -D mapred.job.name="lk_filt_rid" \
                -partitioner org.apache.hadoop.mapred.lib.KeyFieldBasedPartitioner \
                -input /training/likang/tmp/testfile \
                -output /training/likang/tmp2 \
                -mapper "cat" -reducer "cat"

hadoop fs -cat /training/likang/tmp2/part-00000
echo "------------------"
hadoop fs -cat /training/likang/tmp2/part-00001

The Input File is testfile1 --->

11  5   333 111
11  5   777 000
11  3   888 999
11  9   988 888
11  7   234 2342
11  5   4   4
15  9   230 134
12  8   232 834
15  77  220 000
15  33  256 399
11  5   999 888
15  9   222 111
14  88  372 233
15  9   66  77
11  5   821 221
11  0   11  11
15  0   22  22
12  0   33  33
14  0   44  44

The result is here, that all the [ 11 * * * * ] data is not sent to the same reducer... Does anybody know why? Thank you.

enter image description here

likohank
  • 1
  • 1

1 Answers1

0

Now I konw , it's useful to delete this line

-D map.output.key.field.separator="\t" \ 

After delete this option, the result will be right, but more confused for the reason. The default value of map.output.key.field.separator seem's just a Tab,but after I write it here, It makes fault.........

likohank
  • 1
  • 1