在新 API (apache.hadoop.mapreduce.KeyValueTextInputFormat) 中,如何指定制表符(默认)以外的分隔符(分隔符)来分隔键和值.
In new API (apache.hadoop.mapreduce.KeyValueTextInputFormat) , how to specify separator (delimiter) other than tab(which is default) to separate key and Value.
示例输入:
one,first line
two,second line
需要输出:
Key : one
Value : first line
Key : two
Value : second line
我将 KeyValueTextInputFormat 指定为:
I am specifying KeyValueTextInputFormat as :
Job job = new Job(conf, "Sample");
job.setInputFormatClass(KeyValueTextInputFormat.class);
KeyValueTextInputFormat.addInputPath(job, new Path("/home/input.txt"));
这对于作为分隔符的制表符来说效果很好.
This is working fine for tab as a separator.
在较新的 API 中,您应该使用 mapreduce.input.keyvaluelinerecordreader.key.value.separator 配置属性.
In the newer API you should use mapreduce.input.keyvaluelinerecordreader.key.value.separator configuration property.
这是一个例子:
Configuration conf = new Configuration();
conf.set("mapreduce.input.keyvaluelinerecordreader.key.value.separator", ",");
Job job = new Job(conf);
job.setInputFormatClass(KeyValueTextInputFormat.class);
// next job set-up
这篇关于如何在 Hadoop-.20 api 中指定 KeyValueTextInputFormat 分隔符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何检测 32 位 int 上的整数溢出?How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
return 语句之前的局部变量,这有关系吗?Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
如何将整数转换为整数?How to convert Integer to int?(如何将整数转换为整数?)
如何在给定范围内创建一个随机打乱数字的 intHow do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
java的行为不一致==Inconsistent behavior on java#39;s ==(java的行为不一致==)
为什么 Java 能够将 0xff000000 存储为 int?Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)