Add "relation" implementation based on hashvector
[rrq/rrqmisc.git] / vector / relation.h
1 #ifndef relation_H
2 #define relation_H
3
4 #include <hashvector.h>
5 #include <tupleitem.h>
6
7 /**
8  * A relation is an implementation of a tuple set with a primary key
9  * through a hashvector whose "type" defines the key. Additional
10  * hashvectors may be added to impose additional key restrictions and
11  * the final relation is the intersection of them all.
12  *
13  * The relation record itself holds the column schema whereas the
14  * indexes hold key schemas that in practice are copies of the column
15  * schema with some columns blanked out.
16  */
17 typedef struct {
18     vector indexes; // one or more indexes over the tuple collection
19     tupleschema *columns;
20 } relation;
21
22 /**
23  * Create a relation of the given arity and tupleschema.
24  */
25 extern relation *relation_create(int arity,tupleschema *schema);
26
27 /**
28  * Add a a key index to the relation by identifying the value part for
29  * this index.
30  */
31 extern int relation_addindex(relation *r,tupleschema *ts);
32
33
34 /**
35  * Add a tuple to a relation.
36  * \returns a vector of all knocked out tuples.
37  */
38 extern vector *relation_add(relation *r,tuple *t);
39
40 #endif