내가 hadoop mapreduce 프로그래밍 패러다임을 처음 사용하는 사람은 어떻게 값을 기반으로 쉽게 정렬 할 수 있습니까? 나는 다른 비교기 클래스를 구현하려했지만 감속기의 값을 기준으로 정렬 작업을 수행하는 것과 같은 간단한 방법이 있습니다. 기본적으로 로그 파일을 읽고 있는데 오름차순으로 조회수를 계산할 URL을 주문하고 싶습니다.감속기의 값을 기준으로 오름차순 정렬
public static class TokenizerMapper extends Mapper<Object, Text, Text, IntWritable> {
private final static IntWritable ONE = new IntWritable(1);
private Text word = new Text();
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
String[] split = value.toString().split(" ");
for(int i=0; i<split.length; i++){
if (i==6)
word.set(split[i]);
context.write(word, ONE);
}
}
}
public static class IntSumReducer extends Reducer<Text,IntWritable,Text,IntWritable> {
private IntWritable result = new IntWritable();
public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
result.set(sum);
context.write(key, result);
}
}
쉽게 정렬 할 수 있습니까? MapReduce를 작성하지 마십시오. 돼지/하이브/스파크 사용 –
불행히도 맵 제한을 사용해야합니다. – cowgirl