• + 0 comments
    def mapper(record):
        record = record.replace('\n', '')
        data = record.split(',')
        if data[0] == 'Department':
            mapReducer.emitIntermediate(data[1], ('D', data[2]))
        elif data[0] == 'Employee':
            mapReducer.emitIntermediate(data[2], ('P', data[1]))    
        
    def reducer(key, list_of_values):
        name = [ item[1] for item in list_of_values if item[0] == 'P'][0]
        
        for item in [item[1] for item in list_of_values if item[0] == 'D']:
            mapReducer.emit((key, name, item))