gpt4 book ai didi

hadoop - hadoop 中的 KeyValueTextInputFormat 和 TextInputFormat 之间的主要区别是什么?

转载 作者:可可西里 更新时间:2023-11-01 15:00:59 25 4
gpt4 key购买 nike

谁能给我一个我们必须使用 KeyValueTextInputFormatTextInputFormat 的实际场景??

最佳答案

TextInputFormat 类将源文件的每一行转换为键/值类型,其中 BytesWritable 键表示记录的偏移量,Text 值表示整个记录本身。

KeyValueTextInputFormat 是 TextInputFormat 的扩展版本,当我们必须将每个源记录作为文本/文本对获取时,这很有用,其中键/值是通过拆分记录从记录中填充的一个固定的分隔符。

考虑以下文件内容,

AL#Alabama
AR#Arkansas
FL#Florida

如果配置了 TextInputFormat,您可能会看到键/值对,

0    AL#Alabama
14 AR#Arkansas
23 FL#Florida

如果 KeyvalueTextInputFormat 配置了 conf.set("mapreduce.input.keyvaluelinerecordreader.key.value.separator", "#") ,您可能会看到结果作为,

AL    Alabama
AR Arkansas
FL Florida

关于hadoop - hadoop 中的 KeyValueTextInputFormat 和 TextInputFormat 之间的主要区别是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29903987/

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