无法计算BigTable中的行数

时间:2016-10-24 06:15:27

标签: bigtable google-cloud-bigtable

https://cloud.google.com/bigtable/docs/go/cbt-reference

在本参考文献中,我尝试了以下命令

cbt count <table>

用于三个不同的表格。

对于其中一个我得到了我的预期:行数,有点害羞的1M。

对于第二个表,我收到以下错误:

[~]$ cbt count prod.userprofile
2016/10/23 22:47:48 Reading rows: rpc error: code = 4 desc = Error while reading table 'projects/focal-elf-631/instances/campaign-stat/tables/prod.userprofile'
[~]$ cbt count prod.userprofile
2016/10/23 23:00:23 Reading rows: rpc error: code = 4 desc = Error while reading table 'projects/focal-elf-631/instances/campaign-stat/tables/prod.userprofile'

我试了几次,但每次都得到同样的错误。

对于最后一个,我得到了一个不同的错误(错误代码与上面相同,但其描述不同):

[~]$ cbt count prod.appprofile
2016/10/23 22:45:17 Reading rows: rpc error: code = 4 desc = Error while reading table 'projects/focal-elf-631/instances/campaign-stat/tables/prod.appprofile' : Response was not consumed in time; terminating connection. (Possible causes: row size > 256MB, slow client data read, and network problems)
[~]$ cbt count prod.appprofile
2016/10/23 23:11:10 Reading rows: rpc error: code = 4 desc = Error while reading table 'projects/focal-elf-631/instances/campaign-stat/tables/prod.appprofile' : Response was not consumed in time; terminating connection. (Possible causes: row size > 256MB, slow client data read, and network problems)

我也曾多次试过这个,没有任何改变。

我使用'rpc错误代码4'作为关键字在stackoverflow上搜索并搜索,但没有找到任何有用的内容。

我真的很好奇为什么这个命令会失败,我能做些什么来解决这个问题(顺便说一句,这两个表都在24/7生产中使用,我们有几十个大表节点工作正常,所以我不认为它与带宽或QPS有关。)

任何帮助都将非常感激。

2 个答案:

答案 0 :(得分:3)

计算大表需要读取Bigtable中每一行的内容。没有一个概念就是只获得一个代表计数的值。

遗憾的是,这类问题需要像map / reduce这样的东西。幸运的是,做count with Dataflow非常简单。

答案 1 :(得分:0)

作为替代方案,可能(尽管不是最好的)使用原子计数器,即:

  1. Happybase:https://google-cloud-python-happybase.readthedocs.io/en/latest/happybase-table.html#google.cloud.happybase.table.Table.counter_inc
  2. 原生API:https://googlecloudplatform.github.io/google-cloud-python/stable/bigtable-row.html#google.cloud.bigtable.row.AppendRow.increment_cell_value
  3. 如果你在某些条件下设计第二个表作为计数器的二级索引,它可以有很好的性能(如果你不同时读取和写入爆炸计数器,或者你因为hotspotting)。

    然而,正如@ solomon-duskis所提出的,Map / Reduce绝对是一个更强大的解决方案。

相关问题