diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-03-06 00:04:57 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2026-03-06 00:04:57 -0300 |
| commit | 1f084d995444683e2885beb6e12eeee6df1241d3 (patch) | |
| tree | 726e599e026ff79f9456bda93c383a47cfaa8120 /lib | |
| parent | 8c640a262969ef44cd8bc0e0abe95e2a54f4c3f5 (diff) | |
| download | Sakura-1f084d995444683e2885beb6e12eeee6df1241d3.tar.gz Sakura-1f084d995444683e2885beb6e12eeee6df1241d3.zip | |
relation type
Diffstat (limited to '')
| -rw-r--r-- | lib/interop.ml | 3 | ||||
| -rw-r--r-- | lib/relation.ml | 109 |
2 files changed, 111 insertions, 1 deletions
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) + |
