import logging


def read_log_file(input_file):
    """
    Read a file containing counts and dataset_ids, in the format output by sort | uniq -c

    Args:
        input_file (str): The path to counted dataset_ids grepped, sedded, sorted, and counted
            beforehand for memory reasons.

    Returns:
        A dict of {dataset_id: count}
    """
    logging.info("Reading request logs from {}".format(input_file))
    with open(input_file, "r") as infi:
        lines = [line.strip().split() for line in infi]

    return {dsid: int(count) for count, dsid in lines}