2024-10-03 04:25:12 发布
网友
JavaHBase库支持一种特殊的过滤器,它只从BT获取行键。用Python也可以这样做吗?最好使用谷歌的lib-https://github.com/googleapis/python-bigtable
爪哇: https://cloud.google.com/bigtable/docs/hbase-client/javadoc/com/google/cloud/bigtable/hbase/adapters/filters/KeyOnlyFilterAdapter
没有使用python库的过滤器,因为HBase库只能获取Bigtable中的行键。但是您仍然可以通过修改“filter\u modify\u strip\u value(project\u id,instance\u id,table\u id)”函数来检索行键,您可以从this github link中找到该函数。仅当需要计算行数或仅需要行键时,请使用此函数,因为该函数使用StripValue filter将每个单元格的值替换为空字符串,但行键仍然存在。您可以尝试使用以下代码:
from google.cloud import bigtable import datetime import google.cloud.bigtable.row_filters as row_filters def filter_modify_strip_value(project_id="my_project_id", instance_id="my-instance-id", table_id="my-table-name"): print(" filter_modify_strip_value ") client = bigtable.Client(project=project_id, admin=True) instance = client.instance(instance_id) table = instance.table(table_id) rows = table.read_rows( filter_=row_filters.StripValueTransformerFilter(True)) for row in rows: print(row.row_key.decode('utf-8')) filter_modify_strip_value()
没有使用python库的过滤器,因为HBase库只能获取Bigtable中的行键。但是您仍然可以通过修改“filter\u modify\u strip\u value(project\u id,instance\u id,table\u id)”函数来检索行键,您可以从this github link中找到该函数。仅当需要计算行数或仅需要行键时,请使用此函数,因为该函数使用StripValue filter将每个单元格的值替换为空字符串,但行键仍然存在。您可以尝试使用以下代码:
相关问题 更多 >
编程相关推荐