Map Reduce Advanced - Count number of friends

  • + 0 comments

    Simple way:

    def mapper(record):
        f1, f2 = record.replace('\n', '').split(' ')
        mapReducer.emitIntermediate(f1, f2)
        mapReducer.emitIntermediate(f2, f1)
    
    def reducer(key, list_of_values):
        mapReducer.emit([key, len(list_of_values)])