gpt4 book ai didi

hadoop - 使用 NullWritable 作为 OutputKeyClass,但我没有得到预期的结果

转载 作者:可可西里 更新时间:2023-11-01 15:29:44 26 4
gpt4 key购买 nike

我只是想输出值,所以我使用 NullWritable 作为 OutputKeyClass,像这样:

protected void reduce(Text key, Iterable<Text> values,
Reducer<Text, Text, NullWritable, Text>.Context context)
throws IOException, InterruptedException {
for(Text value : values){
context.write(NullWritable.get(), value);
}
}

我这样设置作业:

job.setNumReduceTasks(1);
job.setOutputKeyClass(NullWritable.class);
job.setOutputValueClass(Text.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(Text.class);
FileInputFormat.addInputPath(job, new Path(baseInPath));
FileSystem.get(conf).delete(new Path(baseOutPath), true);
FileOutputFormat.setOutputPath(job, new Path(baseOutPath));

System.exit(job.waitForCompletion(true) ? 0 : 1);

但是当我检查结果路径时,我得到了这个。 �LZO

`@��V��/��!��Z0|res|1*"|33260580217607|2|1|0.2|23|2016-03-28 13:57:420|支付 6-03-28 13:57:42

以0|res|1……开头的字符串是value,但是前面有些乱码。 我认为它们是 NullWritable 的指针。我怎样才能删除这些乱码?我的代码正确吗?

最佳答案

查看输出,似乎已设置 LZO 压缩。您可以尝试查看您的 mapred-site.xml 并查看是否设置了此属性

<property>
<name>mapred.map.output.compression.codec</name>
<value>com.hadoop.compression.lzo.LzoCodec</value>
</property>

更多详情:link

关于hadoop - 使用 NullWritable 作为 OutputKeyClass,但我没有得到预期的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36275902/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com