gpt4 book ai didi

java - 将 hadoop 的 Configuration 转换为 Map

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

如何转换 hadoop 的 Configuration confMap<String, String>

我有一个将 Map 作为参数的方法,我想将 Configuration conf 传递给它,那么如何在两者之间转换?

最佳答案

您可以使用 Configuration 提供的迭代器并构建 map 。

Configuration configuration = new Configuration();
Map<String, String> map = new HashMap<>();
Iterator<Map.Entry<String,String>> iterator = configuration.iterator();
while (iterator.hasNext()) {
Map.Entry<String, String> entry = iterator.next();
map.put(entry.getKey(), entry.getValue());
}

你也可以看看this方法,它采用正则表达式并返回配置的 Map<>。

关于java - 将 hadoop 的 Configuration 转换为 Map<String, String>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34627044/

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