Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Commit cafebae

Browse files
committed
iter: expose paging state
1 parent f394212 commit cafebae

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

query.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,14 @@ func (q *Query) NoSkipMetadata() *Query {
295295
type Result transport.QueryResult
296296

297297
func (q *Query) Iter(ctx context.Context) Iter {
298+
stmt := q.stmt.Clone()
299+
300+
var pageState []byte
301+
if q.pageState != nil {
302+
pageState := make([]byte, len(q.pageState))
303+
copy(pageState, q.pageState)
304+
}
305+
298306
it := Iter{
299307
requestCh: make(chan struct{}, 1),
300308
nextCh: make(chan transport.QueryResult),
@@ -308,12 +316,13 @@ func (q *Query) Iter(ctx context.Context) Iter {
308316
}
309317

310318
worker := iterWorker{
311-
stmt: q.stmt.Clone(),
319+
stmt: stmt,
312320

313-
rd: q.retryPolicy.NewRetryDecider(),
314-
queryInfo: info,
315-
pickNode: q.session.cfg.HostSelectionPolicy.Node,
316-
queryExec: q.exec,
321+
rd: q.retryPolicy.NewRetryDecider(),
322+
queryInfo: info,
323+
pickNode: q.session.cfg.HostSelectionPolicy.Node,
324+
queryExec: q.exec,
325+
pagingState: pageState,
317326

318327
requestCh: it.requestCh,
319328
nextCh: it.nextCh,
@@ -341,6 +350,10 @@ var (
341350
ErrNoMoreRows = fmt.Errorf("no more rows left")
342351
)
343352

353+
func (it *Iter) PageState() []byte {
354+
return it.result.PagingState
355+
}
356+
344357
func (it *Iter) Next() (frame.Row, error) {
345358
if it.closed {
346359
return nil, ErrClosedIter

0 commit comments

Comments
 (0)