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

Commit 89905d2

Browse files
committed
iter: expose paging state
1 parent 84f379b commit 89905d2

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
@@ -297,6 +297,14 @@ func (q *Query) NoSkipMetadata() *Query {
297297
type Result transport.QueryResult
298298

299299
func (q *Query) Iter(ctx context.Context) Iter {
300+
stmt := q.stmt.Clone()
301+
302+
var pageState []byte
303+
if q.pageState != nil {
304+
pageState := make([]byte, len(q.pageState))
305+
copy(pageState, q.pageState)
306+
}
307+
300308
it := Iter{
301309
requestCh: make(chan struct{}, 1),
302310
nextCh: make(chan transport.QueryResult),
@@ -310,12 +318,13 @@ func (q *Query) Iter(ctx context.Context) Iter {
310318
}
311319

312320
worker := iterWorker{
313-
stmt: q.stmt.Clone(),
321+
stmt: stmt,
314322

315-
rd: q.retryPolicy.NewRetryDecider(),
316-
queryInfo: info,
317-
pickNode: q.session.cfg.HostSelectionPolicy.Node,
318-
queryExec: q.exec,
323+
rd: q.retryPolicy.NewRetryDecider(),
324+
queryInfo: info,
325+
pickNode: q.session.cfg.HostSelectionPolicy.Node,
326+
queryExec: q.exec,
327+
pagingState: pageState,
319328

320329
requestCh: it.requestCh,
321330
nextCh: it.nextCh,
@@ -343,6 +352,10 @@ var (
343352
ErrNoMoreRows = fmt.Errorf("no more rows left")
344353
)
345354

355+
func (it *Iter) PageState() []byte {
356+
return it.result.PagingState
357+
}
358+
346359
func (it *Iter) Next() (frame.Row, error) {
347360
if it.closed {
348361
return nil, ErrClosedIter

0 commit comments

Comments
 (0)