如何从 bigtable 中获取最近的数据?
How to get recent data from bigtable?
我需要从 BigTable 获取 50 个最新数据(基于时间戳)。
我使用 read_row
获取数据并使用 CellsRowLimitFilter(50)
进行过滤。但它没有 return 最新数据。似乎数据没有根据时间戳排序?如何获取最新数据?
感谢您的帮助。
与 Bigtable 行键相关的所有数据(单元格)都按时间戳存储,提供存储数据如何随时间更改的记录。您正在使用的方法 CellsRowLimitFilter(50)
will return the first N cells of the row,而您想要的是最新的而不是第一个,因此您应该使用 CellsColumnLimitFilter(50)
which will return only the most recent N cells within each column.
原来问题出在架构上。它不是为时间序列数据设计的。我应该用 id#reverse_timestamp
创建行键,数据将从最新的开始排序。现在我可以使用 CellsRowLimitFilter(50)
并获得 50 个最新数据。
我需要从 BigTable 获取 50 个最新数据(基于时间戳)。
我使用 read_row
获取数据并使用 CellsRowLimitFilter(50)
进行过滤。但它没有 return 最新数据。似乎数据没有根据时间戳排序?如何获取最新数据?
感谢您的帮助。
与 Bigtable 行键相关的所有数据(单元格)都按时间戳存储,提供存储数据如何随时间更改的记录。您正在使用的方法 CellsRowLimitFilter(50)
will return the first N cells of the row,而您想要的是最新的而不是第一个,因此您应该使用 CellsColumnLimitFilter(50)
which will return only the most recent N cells within each column.
原来问题出在架构上。它不是为时间序列数据设计的。我应该用 id#reverse_timestamp
创建行键,数据将从最新的开始排序。现在我可以使用 CellsRowLimitFilter(50)
并获得 50 个最新数据。