私はHadoopストリーミングを実行するとき。マッパー(Key、Value)の出力があります。 キーは空白で区切られた単語シーケンスです。キーの最初の2つの単語のためのHadoopのパーティショナー
最初の2つの単語のハッシュ値を返すパーティショナーを使用したいと思います。だから、
、
public static class CounterPartitioner extends Partitioner<Text, IntWritable> {
@Override
public int getPartition(Text key, IntWritable value, int numPartitions) {
String[] line = key.toString().split(" ");
String prefix = (line.length > 1) ? (line[0] + line[1]) : line[0];
return (prefix.hashCode() & Integer.MAX_VALUE) % numPartitions;
}
}
私の質問が あるとして実装は、事前にHadoopのライブラリーを内蔵し、このような
mapred.output.key.comparator.class
stream.map.output.field.separator
stream.num.map.output.key.fields
map.output.key.field.separator
mapred.text.key.comparator.options
...
よう設定を変更する感謝を使用して、方法があります。