package links

  1. Overview
  2. Docs

This module provides an efficient method of performing calculations on delta sets. This is done by storing the records in a sorted order and by keeping track of the columns of the whole set of records rather than in each record itself.

module Simple_record : sig ... end
module Inconsistent_columns_error : sig ... end
type t
val construct : records:Links_lens__.Phrase_value.t list -> t
val construct_cols : columns:string list -> records:Links_lens__.Phrase_value.t list -> t
val construct_full : columns:string list -> plus:Simple_record.t list -> neg:Simple_record.t list -> t
val columns : t -> string list
val plus_rows : t -> Simple_record.t array
val neg_rows : t -> Simple_record.t array
val map_values : f:(Links_lens__.Phrase_value.t -> Links_lens__.Phrase_value.t) -> t -> t
val is_positive : t -> bool

The record set does not contain negative entries.

val total_size : t -> int

The total number of records in the set.

val pp : Format.formatter -> t -> unit
val pp_tabular : Format.formatter -> t -> unit

Print the set in tabular form.

val find : t -> record:Simple_record.t -> bool

Returns true if the record set contains record as a positive row.

val get_cols_map : t -> columns:string list -> 'a list -> 'a list

Generate a function which maps a set of columns to a subset of those columns specified by columns.

Example:

let sr = (* sorted records with columns A, B, C, D *) in
let map = get_cols_map sr ~columns:["B"; "D"] in
let proj = map [1; 2; 3; 4] in
(* proj = [2; 4] *)
val sort : t -> unit
val project_onto : t -> columns:string list -> t

Project the record set onto the given list of column names.

val project_onto_set : t -> onto:t -> t

Project the record set onto the columns of onto.

val filter : t -> predicate:Phrase.t -> t

Filter out all records that don't match predicate.

val merge : t -> t -> t

Perform a delta merge (\oplus) between two record sets.

module Reorder_error : sig ... end
val reorder : t -> first:string list -> (t, Reorder_error.t) result

Reorder the columns, so that the columns first appear at the beginning.

val reorder_exn : t -> first:string list -> t
module Join_error : sig ... end
val join : t -> t -> on:(string * string * string) list -> (t, Join_error.t) result

Perform a relational join on two sets. on consists out of tuples with the order:

  • output name
  • left input name
  • right input name
val join_exn : t -> t -> on:(string * string * string) list -> t
val negate : t -> t

Swap positive and negative entries.

val negative : t -> t

Get only the negative subset of the record set.

val minus : t -> t -> t

Subtract one delta set from another. Both sets must be positive only.

val to_value : t -> Links_lens__.Phrase_value.t list

Convert a positive delta set into a value type.

val project_fun_dep : t -> fun_dep:Fun_dep.t -> (string list * string list) * (Simple_record.t * Simple_record.t) array * (Simple_record.t * Simple_record.t) array
val calculate_fd_changelist : t -> fun_deps:Fun_dep.Set.t -> ((string list * string list) * (Simple_record.t * Simple_record.t) list) list
val relational_update : t -> fun_deps:Fun_dep.Set.t -> update_with:t -> t
val relational_merge : t -> fun_deps:Fun_dep.Set.t -> update_with:t -> t
val relational_extend : t -> key:string -> by:string -> data:t -> default:Links_lens__.Phrase_value.t -> (t, Reorder_error.t) result

Extend the given set of sorted records by the column by and populate it using the relational data data containing the functional dependency key -> by. Use the default value specified if no entry in data is found.

val relational_extend_exn : t -> key:string -> by:string -> data:t -> default:Links_lens__.Phrase_value.t -> t
val all_values : t -> Simple_record.t list

Get all distinct values of both positive and negative records in this set in a sorted list.

val to_diff : t -> key:string list -> (string list * (Simple_record.t list * Simple_record.t list * Simple_record.t list), Reorder_error.t) result
val to_diff_exn : t -> key:string list -> string list * (Simple_record.t list * Simple_record.t list * Simple_record.t list)
val force_positive : t -> t