How can I convert hadoop's Configuration conf to Map<String, String>?
I have a method that takes Map as an argument and I want to pass Configuration conf to it, so how to convert between the two ?
You can use the Iterator provided by the Configuration and build the 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());
}
You can also take a look this method, which take a regex and returns a Map<> of configuration.
for (Map.Entry<String, String> entry : configuration) { map.put(entry.getKey(), entry.getValue()); }