InterviewSolution
Saved Bookmarks
| 1. |
Write a spark program to check if a given keyword exists in a huge text file or not? |
|
Answer» def keywordExists(line): if (line.find(“my_keyword”) > -1): RETURN 1 return 0lines = sparkContext.textFile(“test_file.txt”);isExist = lines.map(keywordExists);sum = isExist.reduce(sum);print(“Found” if sum>0 ELSE “Not Found”) |
|