DocumentCursor
An ordered walk over the documents a store holds, as one view of it sees them.
store.scan(from = Key.of("user:"), to = Key.of("user:~")).use { cursor ->
while (cursor.next()) println("${cursor.key} -> ${cursor.document.toJsonString()}")
}One entry per key, newest first, tombstones skipped. Underneath, a key exists once per commit that touched it, spread across memtables and every level of the tree; the merge emits all of them in order and this collapses them. A deleted key produces nothing rather than an entry with no document, because a caller iterating documents should not have to know that deletions are stored.
A cursor is a view, not a copy. document reads straight out of a mapped segment, so the cursor holds the segments it is walking for as long as it is open — which is why it is AutoCloseable and why leaving one open holds disk space the way a Snapshot does. Both key and document are valid until the next next.
Not thread-safe: one cursor belongs to one thread. Any number of cursors may run at once.