import statistics


def getMergeOperation(datatype):
    """ FIO log files with a numjobs larger than 1 generates a separate file
    for each job thread. So if numjobs is 8, there will be eight files.

    We need to merge the data from all those job files into one result.
    Depending on the type of data, we must sum or average the data.

    This function returns the appropriate function/operation based on the type.
    """

    operationMapping = {'iops': sum,
                        'lat': statistics.mean,
                        'clat': statistics.mean,
                        'slat': statistics.mean,
                        'bw': sum,
                        'timestamp': statistics.mean}

    opfunc = operationMapping[datatype]
    return opfunc