簡體   English   中英

如何使用bigtable Go客戶端支持分頁?

[英]how does one support pagination using bigtable Go client?

我使用userId#timestamp的rowKey將時間序列數據存儲在bigtable中。 給定查詢參數(userId,startTime,endTime),我如何支持分頁,即從“ offset”開始返回“ limit”記錄?

請注意,bigId中可能不存在userId#startTime rowKey,但在startTime / EndTime之前和之后會有一些數據點。 Bigtable Go客戶端似乎支持帶prefixRange參數的ReadRows。 當我使用ReadRows進行迭代時,我可以使用userId的prefixRange和'seek'到startTime,但是如果starTime / endTime過去,這似乎效率很低。 有沒有更好的辦法 ??

你可以開始ReadRows從操作userId#startTimeuserId#endTimeNewRange和設限與返回的行數LimitRows讀取選項。

err = tbl.ReadRows(ctx, NewRange("<userId>#<startTime>", "<userId>#<endTime>"), func(r Row) bool {
    fmt.Println("Got a row")
    return true
}, LimitRows(100))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM