Hadoop:如何在配置中保存Map对象 [英] Hadoop: How to save Map object in configuration
问题描述
任何想法如何将Map对象设置为org.apache.hadoop.conf.Configuration?
Any idea how can I set Map object into org.apache.hadoop.conf.Configuration?
推荐答案
序列化您的地图放入JSON中,然后将其作为字符串放入配置中。
无法将整个对象放入它中,因为整个配置将被编写为XML文件。
Serialize your map into JSON and then put it as string in your configuration. There is no way to put a whole object into it, because the whole configuration will be written as a XML file.
GSON非常擅长: http://code.google.com/p/google-gson/
以下是有关如何序列化集合的教程: http://sites.google.com/site / gson / gson-user-guide#TOC-Collections-Examples
GSON is quite good at it: http://code.google.com/p/google-gson/ Here is the tutorial about how to serialize collections: http://sites.google.com/site/gson/gson-user-guide#TOC-Collections-Examples
这篇关于Hadoop:如何在配置中保存Map对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!