如何在 Hadoop-.20 api 中指定 KeyValueTextInputFormat 分隔符?

How to specify KeyValueTextInputFormat Separator in Hadoop-.20 api?(如何在 Hadoop-.20 api 中指定 KeyValueTextInputFormat 分隔符?)
本文介绍了如何在 Hadoop-.20 api 中指定 KeyValueTextInputFormat 分隔符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

在新 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 分隔符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)