我在 Google Cloud 的示例代码中看到有 2 个 hbase 表扫描 API:
1) 使用 google.cloud 模块 bigtable 对象 https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/bigtable/hello/main.py
from google.cloud import bigtable
client = bigtable.Client(project=project_id, admin=True)
instance = client.instance(instance_id)
table = instance.table(table_id)
partial_rows = table.read_rows(...)
partial_rows.consume_all()
for row_key, row in partial_rows.rows.items():
2) 使用 google.cloud 模块 bigtable 和 happybase 对象 https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/bigtable/hello_happybase/main.py
from google.cloud import bigtable
from google.cloud import happybase
client = bigtable.Client(project=project_id, admin=True)
instance = client.instance(instance_id)
connection = happybase.Connection(instance=instance)
table = connection.table(table_name)
for key, row in table.scan():
推荐使用这两种机制中的哪一种来扫描 BigTable?
此外,它们是否适合从 PySpark 使用?
最佳答案
这些库中的任何一个都可以与 PySpark 一起使用,但是如果您要构建新的应用程序,我们通常建议使用我们的 native API(第一个示例)而不是 HappyBase。
我们为 Google Cloud Bigtable 提供 HappyBase 适配器,方便开发人员寻找更简单的途径,使用 HappyBase 将现有工作负载从 HBase 部署迁移到 Google Cloud Bigtable。
关于python - 在 Python 中扫描 Google Cloud BigTable 数据的最佳 API 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40786823/