human
I am working on the file "2016/lecture_7_spark.ipynb".
The first task is:
Be careful, though: if the function that you pass as argument to an RDD operation 
* is an object method, or
* references an object field,
then Spark will ship the entire object to the cluster nodes along with the function.
This is demonstrated in the piece of code below.
Can you write Python code for it?

Write me a the Python code you requested?
assistant
#Here is the Python code you requested.

class SearchFunctions(object):
    def __init__(self, query):
        self.query
        
    def is_match(self, s):
        return self.query in s
    
    def get_matches_in_rdd_v1(self, rdd):
        return rdd.filter(self.is_match) # the function is an object method
    
    def get_matches_in_rdd_v2(self, rdd):
        return rdd.filter(lambda x: self.query in x) # the function references an object field