【问题标题】:What is optimal API to scan Google Cloud BigTable data in Python?在 Python 中扫描 Google Cloud BigTable 数据的最佳 API 是什么?
【发布时间】:2017-04-08 18:46:45
【问题描述】:

我看到 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 使用?

【问题讨论】:

    标签: python apache-spark google-cloud-bigtable


    【解决方案1】:

    这些库中的任何一个都可以与 PySpark 一起使用,但是如果您正在构建一个新的应用程序,我们通常推荐我们的原生 API(第一个示例)而不是 HappyBase。

    我们为 Google Cloud Bigtable 提供了 HappyBase 适配器,以方便开发人员寻找更轻松的途径,使用 HappyBase 将现有工作负载从 HBase 部署迁移到 Google Cloud Bigtable。

    【讨论】:

      猜你喜欢
      • 2018-04-05
      • 2015-07-16
      • 2019-01-26
      • 2020-04-14
      • 2018-11-03
      • 1970-01-01
      • 1970-01-01
      • 2022-06-12
      • 1970-01-01
      相关资源
      最近更新 更多