// XXX Let the user pass in a seed.
k = do_subsample
sql = "SELECT _rowid_ FROM %s ORDER BY _rowid_ ASC" % (qt,)
cursor = bdb.sql_execute(sql)
rowids = [row[0] for row in cursor]
n = len(rowids)
seed = struct.pack("<QQQQ", 0, 0, k, n)
uniform = weakprng.weakprng(seed).weakrandom_uniform
randomly_permute(rowids, uniform)
rowids = rowids[:k]
cursor = ((rowid,) for rowid in rowids)
else:
cursor = bdb.sql_execute("""
SELECT _rowid_ FROM %s ORDER BY _rowid_ ASC
""" % (qt,))