My following code just generated a RDD which contains lists, and then transform the list to items via flatMap. But I think the following kind of stupid, do I have to write the function listToItem, and do I have to write the function printStr. Any optimization on the following code please.
def listToItem(inputList):
return inputList
def printStr(tm):
print tm
if __name__ == "__main__":
sc = SparkContext(appName="Test Spark")
rdd1 = sc.parallelize([[1,2,3],['a','b','c']])
res = rdd1.flatMap(listToItem).foreach(printStr)
sc.stop()