barrel_bql_exec (barrel_docdb v1.1.1)
View SourceBQL post-stage executor for collection sources: drives barrel_docdb:find/3 with a compiled plan and applies the per-row stages (unnest expansion, frame-residual predicates, order, offset/limit, projection).
The frame helpers (frames_for/2, residual_match/2, finalize/3) are also the reuse surface for the barrel module, which feeds them table-function hits instead of find rows.
A frame is #{doc := map() with id merged in, elem := term() | undefined, score := map()}; score carries the synthetic _score / _distance columns of table-function sources (empty here).
Summary
Functions
Order, offset/limit and project a list of frames.
Fold rows without materializing the full result (streamable plans paginate internally; materializing plans fold the built list). Fun(Row, Acc) -> {ok, Acc} | {stop, Acc}.
Expand a document into frames: one per unnested array element, or a single element-less frame. Missing / non-array unnest values produce no frames (inner-join UNNEST).
Evaluate the frame-residual conjuncts (tagged paths) against a frame. Mirrors the engine's exists-and-satisfies leaf semantics.
Run a compiled plan. Streamable plans (no ORDER BY, no UNNEST) keep find/3's chunk semantics: one chunk per call, meta carries the continuation. Materializing plans paginate internally and return everything.
Types
Functions
Order, offset/limit and project a list of frames.
-spec fold(binary(), barrel_bql_lower:plan(), map(), fun((map(), term()) -> {ok, term()} | {stop, term()}), term()) -> {ok, term(), map()} | {error, term()}.
Fold rows without materializing the full result (streamable plans paginate internally; materializing plans fold the built list). Fun(Row, Acc) -> {ok, Acc} | {stop, Acc}.
Expand a document into frames: one per unnested array element, or a single element-less frame. Missing / non-array unnest values produce no frames (inner-join UNNEST).
Evaluate the frame-residual conjuncts (tagged paths) against a frame. Mirrors the engine's exists-and-satisfies leaf semantics.
Run a compiled plan. Streamable plans (no ORDER BY, no UNNEST) keep find/3's chunk semantics: one chunk per call, meta carries the continuation. Materializing plans paginate internally and return everything.