def METHOD_NAME(self, func):
    """
    Dump all of the records that match the given rule
    Parameters
    ----------
    func: callable
        The signature of the function is (MeasureInput, [MeasureResult]) -> bool
    Returns
    -------
    list of records in tuple (MeasureInput, MeasureResult) matching the rule
    Examples
    --------
    get records for a target
    >>> db.filter(lambda inp, results: "cuda" in inp.target.keys)
    get records with errors
    >>> db.filter(lambda inp, results: any(r.error_no != 0 for r in results))
    """
    matched_records = list()
    # may consider filtering in iterator in the future
    for key in self.db.keys():
        current = self.get(key)
        try:
            records = [decode(x) for x in current.split(RedisDatabase.MAGIC_SPLIT)]
            records = [rec for rec in records if rec is not None]
        except TypeError:  # got a badly formatted/old format record
            continue
        if not records:
            continue
        inps, results = zip(*records)
        inp = inps[0]
        if not func(inp, results):
            continue
        result = max(results, key=lambda res: res.timestamp)
        matched_records.append((inp, result))
    return matched_records