Operators

Operators — Relational operators.

Synopsis


#include <libhrel/relation.h>


gboolean    (*HTuplePredFunc)               (HTuple *tuple,
                                             gpointer user_data);
HRelation*  h_relation_restrict             (HRelation *relation,
                                             HTuplePredFunc predicate_func,
                                             gpointer user_data);
HRelation*  h_relation_restrict_attrs       (HRelation *relation,
                                             ...);
HRelation*  h_relation_restrict_attrs_l     (HRelation *relation,
                                             GSList *list);
HRelation*  h_relation_sort                 (HRelation *relation,
                                             GCompareDataFunc compare_func,
                                             gpointer user_data);
HRelation*  h_relation_sort_by_attrs        (HRelation *relation,
                                             ...);
HRelation*  h_relation_sort_by_attrs_l      (HRelation *relation,
                                             GSList *list);
HRelation*  h_relation_project              (HRelation *relation,
                                             ...);
HRelation*  h_relation_project_l            (HRelation *relation,
                                             GSList *list);
HRelation*  h_relation_union                (HRelation *relation1,
                                             HRelation *relation2);
HRelation*  h_relation_diff                 (HRelation *relation1,
                                             HRelation *relation2);
HRelation*  h_relation_intersect            (HRelation *relation1,
                                             HRelation *relation2);

Description

Details

HTuplePredFunc ()

gboolean    (*HTuplePredFunc)               (HTuple *tuple,
                                             gpointer user_data);

A HTuple predicate function.

tuple : a HTuple
user_data : user data
Returns : either TRUE or FALSE

h_relation_restrict ()

HRelation*  h_relation_restrict             (HRelation *relation,
                                             HTuplePredFunc predicate_func,
                                             gpointer user_data);

Restricts relation to the set of tuples evaluating to TRUE with predicate_func.

relation : a HRelation to perform restrict on
predicate_func : tuple predicate function
user_data : Custom data to pass to predicate_func
Returns : restricted HRelation

h_relation_restrict_attrs ()

HRelation*  h_relation_restrict_attrs       (HRelation *relation,
                                             ...);

Restricts relation to the set of tuples which contain the attribute values listed.

relation : relation to restrict
... : name and value of an attribute, followed by another and so on, then a NULL.
Returns : restricted relation

h_relation_restrict_attrs_l ()

HRelation*  h_relation_restrict_attrs_l     (HRelation *relation,
                                             GSList *list);

A variation of h_relation_restrict_attrs(), taking a GSList for the attribute list.

relation : relation to restrict
list : list of attribute names and their values
Returns : restricted relation

h_relation_sort ()

HRelation*  h_relation_sort                 (HRelation *relation,
                                             GCompareDataFunc compare_func,
                                             gpointer user_data);

Creates a sorted relation.

relation : a relation to sort
compare_func : function to compare a pair of tuples in relation
user_data : Custom data passed to compare_func
Returns : sorted relation

h_relation_sort_by_attrs ()

HRelation*  h_relation_sort_by_attrs        (HRelation *relation,
                                             ...);

Creates a relation sorted by attributes. Each pair of tuples are compared attribute by attribute in the order listed.

relation : relation to sort
... : name of first attribute, followed by the second and so on, then a NULL
Returns : sorted relation

h_relation_sort_by_attrs_l ()

HRelation*  h_relation_sort_by_attrs_l      (HRelation *relation,
                                             GSList *list);

A variation of h_relation_sort_by_attrs(), taking a GSList for the attribute name list.

relation : relation to sort
list : list of attribute names
Returns : sorted relation

h_relation_project ()

HRelation*  h_relation_project              (HRelation *relation,
                                             ...);

Creates a relation on relation projected over a set of attributes.

relation : relation to project
... : name of an attribute, followed by another and so on, then a NULL
Returns : projected relation

h_relation_project_l ()

HRelation*  h_relation_project_l            (HRelation *relation,
                                             GSList *list);

A variation of h_relation_project() taking a GSList of attribute names.

relation : relation to project
list : list of attribute names
Returns : projected relation

h_relation_union ()

HRelation*  h_relation_union                (HRelation *relation1,
                                             HRelation *relation2);

Creates the union of two relations.

relation1 : a HRelation
relation2 : a HRelation
Returns : union of relation1 and relation2

h_relation_diff ()

HRelation*  h_relation_diff                 (HRelation *relation1,
                                             HRelation *relation2);

Creates the difference of two relations.

relation1 : a HRelation
relation2 : a HRelation
Returns : difference of relation1 and relation2

h_relation_intersect ()

HRelation*  h_relation_intersect            (HRelation *relation1,
                                             HRelation *relation2);

Creates the intersection of two relations.

relation1 : a HRelation
relation2 : a HRelation
Returns : intersection of relation1 and relation2