0
我有2 HashMap的,我在那裏分組成一個單一的HashMap分組到N多包含HashMap到apache的星火JavaPairRDD
Map<String, List<String>> map1 = new HashMap<>();
Map<String, List<String>> map2 = new HashMap<>();
Map<String, List<String>> result = new HashMap<>();
map1.keySet().stream().forEach(key -> {
List<String> val = result.get(key);
if (val == null) {
val = new ArrayList<String>();
result.put(key, val);
} else {
val.addAll(map1.get(key));
result.put(key, val);
}
});
map2.keySet().stream().forEach(key -> {
List<String> val = result.get(key);
if (val == null) {
val = new ArrayList<String>();
result.put(key, val);
} else {
val.addAll(map2.get(key));
result.put(key, val);
}
});
現在我想要做同樣的使用Apache的火花,創造JavaPairRDD>。如果我有N個這樣的哈希表並將它們分組到JavaPairRD>中,如何實現它?