douzhuan1467 2018-12-18 01:59
浏览 57
已采纳

如何使用bigtable Go客户端支持分页?

I store time series data in bigtable with a rowKey of userId#timestamp. Given query parameters of (userId, startTime, endTime) how can I support pagination i.e return 'limit' records starting from 'offset' ?

note that userId#startTime rowKey may not exist in bigtable but there will some datapoints before and after startTime/EndTime. Bigtable Go client seems to support ReadRows with a prefixRange argument. I could use a prefixRange of userId and 'seek' to the startTime as I iterate using ReadRows but this seems very inefficient if starTime/endTime is way in the past. is there a better way ??

  • 写回答

1条回答 默认 最新

  • dongqiuqiu4736 2018-12-18 17:10
    关注

    You can start a ReadRows operation from userId#startTime to userId#endTime with a NewRange and set a limit on the number of rows returned with a LimitRows read option.

    err = tbl.ReadRows(ctx, NewRange("<userId>#<startTime>", "<userId>#<endTime>"), func(r Row) bool {
        fmt.Println("Got a row")
        return true
    }, LimitRows(100))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度