X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=vector%2Frelation.h;h=af0756cd09265c2e67196d7feff625bc38cf9c75;hb=813b52397a92922f2540a41c9076a77ca93e1a48;hp=b0996c16b34510649b6235e836a73b496fc80c2d;hpb=c08a0975036f23f972a16a07efb0c07113c96d2e;p=rrq%2Frrqmisc.git diff --git a/vector/relation.h b/vector/relation.h index b0996c1..af0756c 100644 --- a/vector/relation.h +++ b/vector/relation.h @@ -5,24 +5,33 @@ #include /** - * A relation is an implementation of a tuple set with a primary key - * through a hashvector whose "type" defines the key. Additional - * hashvectors may be added to impose additional key restrictions and - * the final relation is the intersection of them all. - * - * The relation record itself holds the column schema whereas the - * indexes hold key schemas that in practice are copies of the column - * schema with some columns blanked out. + * A relation is an implementation of a tuple set with (optional) key + * constraints. The store is a hashvector whose "type" is a + * tupleschema that defines the columns. The key constraints are + * represented as additional hashvectors whose tupleschemas are clones + * of the column schema with some columns excluded. + * \extends hashvector */ typedef struct { - vector indexes; // one or more indexes over the tuple collection - tupleschema *columns; + /** + * This is the primary content store for the relation. Its type + * should be a tupleschema declaring the "item types" for the + * relation columns. + */ + hashvector content; + + /** + * This is a collection of relational constraints, if any, which + * are represented as hashvectors whose tupleschemas are clones of + * the content tupleschema with some columns excluded. + */ + vector constraints; } relation; /** - * Create a relation of the given arity and tupleschema. + * Create a relation for the given tupleschema. */ -extern relation *relation_create(int arity,tupleschema *schema); +extern relation *relation_create(tupleschema *schema); /** * Add a a key index to the relation by identifying the value part for @@ -32,9 +41,24 @@ extern int relation_addindex(relation *r,tupleschema *ts); /** - * Add a tuple to a relation. + * \brief Add a tuple to a relation. + * \param r is th relation concerned. + * \param t is the tuple to add. + * * \returns a vector of all knocked out tuples. */ extern vector *relation_add(relation *r,tuple *t); +/** + * \brief Delete all tuples matching to the query. + * \returns all deleted tuples. + */ +extern vector *relation_delete(relation *r,tuple *query); + +/** + * \brief Return next tuple matching the query at or after the index. + * \returns any such matching tuple and updates *index to its index. + */ +extern void *relation_next(relation *r,vector_index *index,tuple *query); + #endif