diff options
| -rw-r--r-- | .gitignore | 10 | ||||
| -rw-r--r-- | bin/dune | 2 | ||||
| -rw-r--r-- | bin/main.ml | 5 | ||||
| -rw-r--r-- | dune-project | 4 | ||||
| -rw-r--r-- | lib/interop.ml | 3 | ||||
| -rw-r--r-- | lib/relation.ml | 109 |
6 files changed, 124 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd81ad4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +_build/ +.direnv/ + +# Nix build/link artifacts +result +result-* + +# OCaml editor/tooling artifacts +*.merlin +.ocamlformat-lock @@ -3,5 +3,5 @@ (name main) (modules main) (libraries relational_engine) - (package relational_engine) + (package sakura) (modes byte exe)) diff --git a/bin/main.ml b/bin/main.ml index 90d4f24..c5e2c1d 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -3,9 +3,4 @@ let main () = print_endline digest let () = - (* let response = *) - (* Relational_engine.Relation.write_and_retrieve() *) - (* in match response with *) - (* | Ok response -> print_endline response *) - (* | Error err -> print_endline err; *) main () diff --git a/dune-project b/dune-project index a5631f0..02bf004 100644 --- a/dune-project +++ b/dune-project @@ -3,7 +3,7 @@ (using ctypes 0.3) -(name relational_engine) +(name sakura) (generate_opam_files true) @@ -19,7 +19,7 @@ (documentation https://url/to/documentation) (package - (name relational_engine) + (name sakura) (synopsis "A short synopsis") (description "A longer description") (depends ocaml dune) diff --git a/lib/interop.ml b/lib/interop.ml index 3b7a3d2..ea25e0c 100644 --- a/lib/interop.ml +++ b/lib/interop.ml @@ -1,7 +1,8 @@ open Ctypes module Sha256 = struct - let compute_hash content = + type t = string + let compute_hash content: t = let size_with_null_terminator = C.Types.hash_size + 1 in let buf = Ctypes.allocate_n char ~count:size_with_null_terminator in let () = C.Functions.compute_hash buf (Bytes.to_string content) in diff --git a/lib/relation.ml b/lib/relation.ml new file mode 100644 index 0000000..f3f536a --- /dev/null +++ b/lib/relation.ml @@ -0,0 +1,109 @@ +module Hash = struct + type t = Interop.Sha256.t + + let compare = String.compare +end + +module Name = struct + type t = string + + let compare = String.compare +end + +module Tree = struct + type t = unit +end + +module Schema = struct + type t = (string, string) Hashtbl.t + + let create () = Hashtbl.create 16 +end + +module RelationConstraints = struct + type t = (string * string) list +end + +module Cardinality = struct + type t = Finite of int | AlephZero | Continuum +end + +module Generator = struct + type result = + | Done + | Value of (string, string) Hashtbl.t * t + | Error of string + + and t = (string, string) Hashtbl.t -> result +end + +module MembershipCriteria = struct + type t = (string, string) Hashtbl.t + + let create () = Hashtbl.create 16 +end + +module Provenance = struct + type t = + | Undefined + | Base of Name.t + | Join of t * t + | Select of t * MembershipCriteria.t + | Project of t * string list + | Take of t * int +end + +module Lineage = struct + type t = + | Base of Name.t + | Select of (string -> bool) * t + | Project of string list * t + | Join of string * t * t + | ThetaJoin of (string -> string -> bool) * t * t + | Sort of (string -> string -> int) * t + | Take of int * t + | Aggregate of string * string * t +end + +type t = { + hash : Hash.t; + name : Name.t; + tree : Tree.t option; + schema : Schema.t; + constraints : RelationConstraints.t; + cardinality : Cardinality.t; + generator : Generator.t option; + membership_criteria : MembershipCriteria.t; + provenance : Provenance.t; + lineage : Lineage.t; +} + +let make ~hash ~name ~tree ~schema ~constraints ~cardinality ~generator + ~membership_criteria ~provenance ~lineage = + { + hash; + name; + tree; + schema; + constraints; + cardinality; + generator; + membership_criteria; + provenance; + lineage; + } + +let compare left right = + match Name.compare left.name right.name with + | 0 -> Hash.compare left.hash right.hash + | n -> n + +module Ord = struct + type nonrec t = t + + let compare = compare +end + +module Set = Set.Make (Ord) +module Map = Map.Make (Ord) + |
