diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-03-24 17:51:03 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-24 17:51:03 -0300 |
| commit | 013cbf09e4ea9871311bf52b6873c43fc9be5441 (patch) | |
| tree | 1a7fd541c215fadb4e18c5cda551bb2b707bdc8b /lib/scl/sublanguage.ml | |
| parent | a98fad877fa9ddacb32898b01e23d588f8df04aa (diff) | |
| download | Sakura-013cbf09e4ea9871311bf52b6873c43fc9be5441.tar.gz Sakura-013cbf09e4ea9871311bf52b6873c43fc9be5441.zip | |
Session with stream control sublanguage (#55)
SCL adds cursor-based streaming to Sakura so clients can consume DRL query results incrementally in bounded batches rather than all at once. Three statements: Begin, Fetch, and Close. `open`, `advance`, and `release` cursors backed by a session registry that suspends the generator between calls. SCL is just an optional consumption layer above the existing algebra.
Diffstat (limited to '')
| -rw-r--r-- | lib/scl/sublanguage.ml | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/scl/sublanguage.ml b/lib/scl/sublanguage.ml new file mode 100644 index 0000000..7098ced --- /dev/null +++ b/lib/scl/sublanguage.ml @@ -0,0 +1,26 @@ +module Make (Storage : Management.Physical.S) = struct + module Exec = Executor.Make(Storage) + + type storage = Storage.t + type ast = Ast.statement + type error = Exec.error + + let name = "scl" + + let parse_sexp sexp = + match Parser.of_sexp sexp with + | Ok r -> Ok r + | Error (Parser.ParseError s) -> Error (Exec.ParseError s) + + let execute storage db ast = + Exec.execute storage db ast + |> Result.map (function + | Executor.Batch { cursor_id; rows; has_more } -> + Sublanguage.Cursor { cursor_id; rows; has_more } + | Executor.Closed db -> + Sublanguage.Transition (db, "cursor closed")) + + let sexp_of_error = Exec.sexp_of_error +end + +module Memory = Make(Management.Physical.Memory) |
