.collect() action

We have also cautioned you about using this action; collect() returns all of the elements from the workers to the driver. Thus, look at the following code:

# Return all airports elements
# filtered by WA state
airports.filter(lambda c: c[1] == "WA").collect()

This will generate the following output:

# Output
[[u'Bellingham', u'WA', u'USA', u'BLI'], [u'Moses Lake', u'WA', u'USA', u'MWH'], [u'Pasco', u'WA', u'USA', u'PSC'], [u'Pullman', u'WA', u'USA', u'PUW'], [u'Seattle', u'WA', u'USA', u'SEA'], [u'Spokane', u'WA', u'USA', u'GEG'], [u'Walla Walla', u'WA', u'USA', u'ALW'], [u'Wenatchee', u'WA', u'USA', u'EAT'], [u'Yakima', u'WA', u'USA', u'YKM']]
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset