aboutsummaryrefslogtreecommitdiffstats
path: root/lib/drl
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-09-26 15:35:39 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-09-26 15:35:39 -0300
commitb555c28c7e6c315fc0394baf213ecb08b21ed959 (patch)
treea1a181863805d013aafcd5957944790328ce027b /lib/drl
parente32ba6294781691846c3ab19281fe977350b4d0f (diff)
downloadSakura-b555c28c7e6c315fc0394baf213ecb08b21ed959.tar.gz
Sakura-b555c28c7e6c315fc0394baf213ecb08b21ed959.zip
further deletions on drl and prelude
Diffstat (limited to 'lib/drl')
-rw-r--r--lib/drl/ast.ml26
-rw-r--r--lib/drl/executor.ml62
-rw-r--r--lib/drl/parser.ml17
-rw-r--r--lib/drl/sublanguage.ml11
4 files changed, 0 insertions, 116 deletions
diff --git a/lib/drl/ast.ml b/lib/drl/ast.ml
deleted file mode 100644
index 2fd56e6..0000000
--- a/lib/drl/ast.ml
+++ /dev/null
@@ -1,26 +0,0 @@
-open Sexplib.Std
-
-(** Literal values for Const nodes *)
-type value = Int of int | Float of float | Str of string | Bool of bool [@@deriving sexp]
-
-(** Convert an AST value to an AbstractValue.t (Obj.t) via Obj.repr *)
-let value_to_abstract : value -> Conventions.AbstractValue.t = function
- | Int n -> Obj.repr n
- | Float f -> Obj.repr f
- | Str s -> Obj.repr s
- | Bool b -> Obj.repr b
-
-type direction = Asc | Desc [@@deriving sexp]
-
-type query =
- | Base of string (** base relation by name *)
- | Const of (string * value) list (** constant single-tuple relation *)
- | Select of query * query (** σ semijoin: (filter, source) *)
- | Join of string list * query * query (** ⋈ natural equijoin on named attrs *)
- | Cartesian of query * query (** × Cartesian product *)
- | Project of string list * query (** π restrict columns *)
- | Rename of (string * string) list * query (** ρ rename (old,new) pairs *)
- | Union of query * query (** ∪ — compatible schemas assumed *)
- | Diff of query * query (** − *)
- | Take of int * query (** τ *)
-[@@deriving sexp]
diff --git a/lib/drl/executor.ml b/lib/drl/executor.ml
deleted file mode 100644
index 6ff3551..0000000
--- a/lib/drl/executor.ml
+++ /dev/null
@@ -1,62 +0,0 @@
-module Make (NT : Nt.S) = struct
- module Error = struct
- open Condition
-
- let parse_error error = condition "parse-error" error empty
-
- let relation_not_found name =
- condition "relation-not-found" "Relation not found" ("name" |=| of_string name)
-
- let unsupported_operator msg = condition "unsupported-operator" msg empty
- end
-
- let ( let* ) = Result.bind
-
- (* Compile a DRL AST query to a Tarski VM plan node tree.
- A qualified base reference ([<mg>:<rel>]) resolves through [ctx.resolve]
- to its stored-relation path; an unqualified name resolves to the
- session-scoped ephemeral binding created by DML [Define]. *)
- let rec compile (ctx : Sublanguage_context.t) (q : Ast.query) : (Nt.plan_node, Condition.t) result
- =
- match q with
- | Ast.Base name -> (
- match Qualified_name.try_parse name with
- | Error _ -> Ok (Nt.Scan {path= Sublanguage_context.ephemeral_path ctx name; args= []})
- | Ok fqn -> Ok (Nt.Scan {path= ctx.resolve fqn; args= []}) )
- | Ast.Join (on_attrs, q1, q2) ->
- let* p1 = compile ctx q1 in
- let* p2 = compile ctx q2 in
- Ok (Nt.Join {left= p1; right= p2; on_attrs})
- | Ast.Take (n, q) ->
- let* p = compile ctx q in
- Ok (Nt.Take {limit= n; source= p})
- | Ast.Project (attrs, q) ->
- let* p = compile ctx q in
- Ok (Nt.Project {attrs; source= p})
- | Ast.Const _ ->
- Error
- (Error.unsupported_operator "Const: literal relations not yet reachable by VM; use Base")
- | _ ->
- Error
- (Error.unsupported_operator
- "Select/Rename/Union/Diff/Cartesian require VM operators not yet implemented" )
-
- let page_limit = 16
-
- let execute (ctx : Sublanguage_context.t) (q : Ast.query) :
- (Sublanguage_types.result, Condition.t) result =
- let* plan = compile ctx q in
- let rel_name = "query_result" in
- let* stream = NT.execute_query plan ~rel_name in
- let rec drain acc count =
- if count >= page_limit then List.rev acc, true
- else
- match NT.stream_next stream with
- | Error _ -> List.rev acc, false
- | Ok None -> List.rev acc, false
- | Ok (Some t) -> drain (t :: acc) (count + 1)
- in
- let rows, has_more = drain [] 0 in
- ignore (NT.stream_close stream);
- Ok (Sublanguage_types.Cursor {cursor_id= "0"; rows; has_more})
-end
diff --git a/lib/drl/parser.ml b/lib/drl/parser.ml
deleted file mode 100644
index abb3070..0000000
--- a/lib/drl/parser.ml
+++ /dev/null
@@ -1,17 +0,0 @@
-module Error = struct
- open Condition
-
- let parse_error msg = condition "parse-error" msg empty
-end
-
-let of_sexp sexp =
- match Ast.query_of_sexp sexp with
- | q -> Ok q
- | exception exn -> Error (Error.parse_error (Printexc.to_string exn))
-
-let of_string s =
- match Sexplib.Sexp.of_string s |> Ast.query_of_sexp with
- | q -> Ok q
- | exception exn -> Error (Error.parse_error (Printexc.to_string exn))
-
-let to_string q = Ast.sexp_of_query q |> Sexplib.Sexp.to_string_hum
diff --git a/lib/drl/sublanguage.ml b/lib/drl/sublanguage.ml
deleted file mode 100644
index d5c5977..0000000
--- a/lib/drl/sublanguage.ml
+++ /dev/null
@@ -1,11 +0,0 @@
-module Make (NT : Nt.S) = struct
- module Exec = Executor.Make (NT)
-
- type configuration = unit
- type ast = Ast.query
-
- let name = "drl"
- let parse _ = Ok ()
- let parse_sexp sexp = Parser.of_sexp sexp
- let execute ctx ast = Exec.execute ctx ast
-end