aboutsummaryrefslogblamecommitdiffstats
path: root/lib/relation.ml
blob: 0855b57ece5240b08d8532511a60710e82652d4e (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
                    
                                                   
 


                                     




                          
                                
                   
                                     





                                
                                









                                                     

                                   
                    
                       

                                            
                                 
                                                                     



                            
                                                                       



                                               
           
         





                        
   
module Tree = Merkle
(** Use the Merkle module for tuple hash storage *)

module RelationConstraint = struct
  type name = string
  type t = (name * Constraint.t) list
end

module Provenance = struct
  type t =
    | Undefined
    | Base of Conventions.Name.t
    | Join of t * t
    | Select of t * (Tuple.t -> bool)
    | Project of t * string list
    | Take of t * int
end

module Lineage = struct
  type t =
    | Base of Conventions.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 : Conventions.Hash.t option;
  name : Conventions.Name.t;
  schema : Schema.t;
  tree : Tree.t option;
  constraints : RelationConstraint.t option;
  cardinality : Conventions.Cardinality.t;
  generator : Generator.t option;
  membership_criteria : (string -> Tree.t option) -> Tuple.t -> bool;
  provenance : Provenance.t;
  lineage : Lineage.t;
}

let make ~hash ~name ~schema ~tree ~constraints ~cardinality ~generator
    ~membership_criteria ~provenance ~lineage =
  {
    hash;
    name;
    schema;
    tree;
    constraints;
    cardinality;
    generator;
    membership_criteria;
    provenance;
    lineage;
  }