Spark rdd write in global list
问题 How to write in global list with rdd? Li = [] Fn(list): If list.value == 4: Li.append(1) rdd.mapValues(lambda x:fn(x)) When I try to print Li the result is: [] What I'm trying to do is to transform another global liste Li1 while transforming the rdd object. However, when I do this I have always an empty list in the end. Li1 is never transformed. 回答1: The reason why you get Li value set to [] after executing mapValue s - is because Spark serializes Fn function (and all global variables that it