barrel_bql_query (barrel v1.0.0)

View Source

BQL execution in barrel: collection sources delegate to the docdb executor; table-function sources (vector_top_k, bm25_top_k, hybrid_top_k) run here, where the vector store and the embedder live.

Table-function pipeline: search top KFetch hits (single over-fetch when a WHERE must filter them, no re-query loop: the contract is UP TO k rows) -> batch-join hits to their documents (hits without a document are dropped) -> residual WHERE via barrel_query:match/2 -> truncate to k -> unnest/order/offset/limit/project through the shared barrel_bql_exec post stages.

Summary

Functions

Start a live query for a compiled SUBSCRIBE plan. Deltas go to the owner; see barrel_bql_live for the message shapes.

Functions

explain(Db, Plan)

-spec explain(barrel:db(), barrel_bql_lower:plan()) -> {ok, map()} | {error, term()}.

fold(Db, Plan, Opts, Fun, Acc)

-spec fold(barrel:db(),
           barrel_bql_lower:plan(),
           map(),
           fun((map(), term()) -> {ok, term()} | {stop, term()}),
           term()) ->
              {ok, term(), map()} | {error, term()}.

run(Db, Plan, Opts)

-spec run(barrel:db(), barrel_bql_lower:plan(), map()) -> {ok, [map()], map()} | {error, term()}.

subscribe_plan(Db, Plan, Opts)

-spec subscribe_plan(barrel:db(), barrel_bql_lower:plan(), map()) ->
                        {ok, #{ref := reference(), pid := pid()}} | {error, term()}.

Start a live query for a compiled SUBSCRIBE plan. Deltas go to the owner; see barrel_bql_live for the message shapes.