def split_on_attributes(keys,rows):
  """
  Given a tuple of column names 'keys', and a collection of dict-like
  rows, returns a dictionary where every unique value as defined by keys
  is a key in the dictionary, and the value under that key is a list
  containing the corresponding rows.
  """
  ret = {}
  
  for row in rows:
    key = tuple([row[k] for k in keys])
    vals = ret.get(key)
    if vals is None:
      vals = []
      ret[key] = vals
    vals.append(row)

  return ret