如何只读取 Cloud Bigtable 中的某些列族?

How to read only some column families from Cloud Bigtable?

我有一个 Cloud Bigtable table,它有两个列族:smalllarge。我想扫描所有行并访问 small 列中的值:

client = bigtable.Client(project=project_id, admin=False)
instance = client.instance(instance_id)
table = instance.table(table_id)

for row in table.yield_rows():
    key = row.row_key.decode('utf-8')
    small_value = row.cells[small_cf][b''][0].value
    print(key, small_value)

这有效,但也会获取我不关心的 large CF 的值。如何只从一组特定的 CF 中获取数据?

您可以为此使用 FamilyNameRegexFilter,例如:

for row in table.yield_rows(filter_=FamilyNameRegexFilter('small')):