'Returns the newest values for attributes that match \'prefix\'.
Args:
subject: The subject.
prefix: The attribute prefix.
limit: The maximum number of records to return.
Returns:
A list of the form (attribute, value, timestamp).'

@utils.Synchronized
def GetNewestFromPrefix(self, subject, prefix, limit=None):

    pattern = (prefix + '%')
    subject = utils.SmartStr(subject)
    query = 'SELECT    predicate,    MAX(timestamp),    value    FROM    tbl\n                                                            WHERE    subject    =    ?    AND    predicate    LIKE    ?\n                                                            GROUP    BY    predicate'
    if limit:
        query += '    LIMIT    ?'
        args = (subject, pattern, limit)
    else:
        args = (subject, pattern)
    data = self.Execute(query, args).fetchall()
    return [(pred, val, ts) for (pred, ts, val) in data]
