barrel_query_cursor (barrel_docdb v1.1.1)
View SourceQuery cursor management for chunked query execution
Manages cursor state for paginated queries using ETS. Each cursor holds: - Snapshot reference for consistent reads across chunks - Last key position for resumption - Query metadata for validation - Expiry time for cleanup
Summary
Functions
Create a new cursor with snapshot Returns an opaque cursor token
Drop a cursor entry WITHOUT releasing its snapshot. Used when resuming: the successor cursor (or the terminal chunk) now owns the shared snapshot, so releasing it here would drop a snapshot still in use by later chunks.
Look up a cursor by token Returns cursor data if valid and not expired
Release a cursor and its snapshot
Start the cursor manager
Update cursor position after a chunk
Functions
Create a new cursor with snapshot Returns an opaque cursor token
-spec detach(binary()) -> ok.
Drop a cursor entry WITHOUT releasing its snapshot. Used when resuming: the successor cursor (or the terminal chunk) now owns the shared snapshot, so releasing it here would drop a snapshot still in use by later chunks.
-spec lookup(binary()) -> {ok, #cursor{id :: binary(), store_ref :: term(), db_name :: binary(), snapshot :: term() | undefined, last_key :: binary(), query_type :: atom(), created_at :: integer(), expires_at :: integer()}} | {error, not_found | expired}.
Look up a cursor by token Returns cursor data if valid and not expired
-spec release(binary()) -> ok.
Release a cursor and its snapshot
Start the cursor manager
Update cursor position after a chunk