I'm trying to make a function call through the map
function available in spark.
I did what was given in the spark tutorial page (https://spark.apache.org/docs/1.2.0/programming-guide.html). But the function myFunc
never gets called. At least that's what I think. I don't know if I'm doing something wrong or missing out something.
This is the following code:
from pyspark import SparkContext
if __name__ == "__main__":
def myFunc(s):
print("@@")
words = s.split("\n")
print("##")
return len(words)
sc = SparkContext("local","test")
sc.textFile("C:\\TestLogs\\sample.log").map(myFunc)
print("**")
Output:
**
In fact, this is the same example from the spark doc except for the file location.