Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Pagination #35

Open
JumpingCrazyBeaver2319 opened this issue Jul 9, 2021 · 1 comment
Open

Pagination #35

JumpingCrazyBeaver2319 opened this issue Jul 9, 2021 · 1 comment

Comments

@JumpingCrazyBeaver2319
Copy link

Is there a recommended approach for pagination, or is it not supported by this db?

@SalomonBrys
Copy link
Member

SalomonBrys commented Jul 11, 2021

A Cursor can stay opened as long as you'd like, so you can keep it open and manage paging with it.

Another way is to use transientSeekKey and seekTo, which is not documented (and it should be, this is a mistake).

transientSeekKey returns a Memory that's only valid until the cursor moves, so you need to copy its bytes.
seekTo takes a Memory and moves the cursor to the corresponding position.

val sk: ByteArray = cursor.transientSeekKey().getBytes()

/*... You can save this ByteArray in instanceState, for example */

cursor.seekTo(sk.asMemory())

I'll leave this issue open until this behaviour is properly documented

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants