gpt4 book ai didi

hadoop 对键进行排序并更改键值

转载 作者:行者123 更新时间:2023-12-02 21:53:21 24 4
gpt4 key购买 nike

在 hadoop 中,映射器将 key 作为文件中的位置接收,例如“0、23、45、76、123”,我认为这是字节偏移量。

我有两个大型输入文件,我需要以文件的相同区域(就行数而言,例如 400 行)获得相同 key 的方式进行拆分。字节偏移显然不是最好的选择。

我想知道是否有一种方法或选项可以将键更改为整数,因此输出键将是:“1、2、3、4、5”而不是“0、23、45、76、123”?

谢谢!

最佳答案

In hadoop, the mapper receives the key as the position in the file like "0, 23, 45, 76, 123", which I think are byte offsets.



是的。但不总是。如果您使用的是 TextInputFormat,则为真。 (如你的情况)。键和值取决于您使用的 InputFormat 类型并相应地更改。

I was wondering if there is a way or option to change the keys to an integer so the output keys will be: "1, 2, 3, 4, 5" instead of "0, 23, 45, 76, 123"?



您可以通过继承 FileInputFormat 来编写自己的自定义 InputFormat 来实现这一点。

关于hadoop 对键进行排序并更改键值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17835954/

24 4 0
文章推荐: hadoop - 如何在Redhat上安装Hive?
文章推荐: sas - 根据现有 id 变量创建唯一的 id 变量
文章推荐: c# - Asp.NET 返回空 List C#