• + 0 comments

    Copilot solution:

    def mapper(record):
        record = record.strip().split(",")
        if record[0] == "Employee":
            mapReducer.emitIntermediate(record[2], ("Employee", record[1]))
        elif record[0] == "Department":
            mapReducer.emitIntermediate(record[1], ("Department", record[2]))
            
    
    def reducer(key, list_of_values):
        employee_records = [v for v in list_of_values if v[0]=="Employee"]
        department_records = [v for v in list_of_values if v[0]=="Department"]
        
        for e in employee_records:
            for d in department_records:
                mapReducer.emit((key, e[1], d[1]))