如何仅从Cloud Bigtable中读取某些列族?

时间:2018-07-13 22:47:19

标签: python bigtable google-cloud-bigtable

我有一个Cloud Bigtable表,其中包含两个列族: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中获取数据?

1 个答案:

答案 0 :(得分:3)

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

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