aboutsummaryrefslogblamecommitdiffstats
path: root/lib/relation.ml
blob: 705dcc5358349a1f41c1bbaad368c0bbd7e67347 (plain) (tree)
1
2
3
4
5
6
7
                    
                                                  

   


                                     




                          
                                
                   
                                     





                                
                                









                                                     

                                   
                       

                                            
                                 
                                        



                            
                                                               




                                               





                        
  
module Tree = struct
  type t = unit (* TODO: Radix Merkle tree here *)
end

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;
  tree : Tree.t option;
  constraints : RelationConstraint.t option;
  cardinality : Conventions.Cardinality.t;
  generator : Generator.t option;
  membership_criteria : Tuple.t -> bool;
  provenance : Provenance.t;
  lineage : Lineage.t;
}

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