kir*_*ala 5 pagination go google-cloud-platform google-cloud-bigtable
我使用userId #timestamp的rowKey将时间序列数据存储在bigtable中.给定查询参数(userId,startTime,endTime)我如何支持分页,即从'offset'开始返回'limit'记录?
请注意userId #startTime rowKey可能不存在于bigtable中,但在startTime/EndTime之前和之后会有一些数据点.Bigtable Go客户端似乎支持带有prefixRange参数的ReadRows.当我使用ReadRows迭代时,我可以使用userRd的prefixRange和'seek'到startTime,但是如果starTime/endTime是过去的话,这似乎效率很低.有没有更好的办法 ??
小智 5
你可以开始ReadRows从操作userId#startTime
到userId#endTime
与NewRange和设置限制上的行数与返回的LimitRows阅读选项.
err = tbl.ReadRows(ctx, NewRange("<userId>#<startTime>", "<userId>#<endTime>"), func(r Row) bool {
fmt.Println("Got a row")
return true
}, LimitRows(100))
Run Code Online (Sandbox Code Playgroud)