spelling correction
[rrq/rrqmisc.git] / vector / tupleitem.h
1 #ifndef tupleitem_H
2 #define tupleitem_H
3
4 #include <itemkeyfun.h>
5
6 /**
7  * A tuple is an array of void*
8  */
9 typedef void *tuple[];
10
11 /**
12  * A tupleschema record declares the itemkeyfun functions for tuple
13  * items together with applicable arity and domain combinations. The
14  * macro \ref TUPLEITEMINIT may be used to initialize particular
15  * tupleschema records, which each become tupleitem declaration for
16  * its particular arity and parts declarations
17  * \extends itemkeyfun
18  */
19 typedef struct {
20     /**
21      * These are the itemkeyfun callback functions to support
22      * hashvector use for tuple items. The functions expects their
23      * itemkeyfun pointer to be within a tupleschema record so as to
24      * provide the handling of the tuple columns.
25      */
26     itemkeyfun base;
27
28     /**
29      * This is the number of columns in a tuple.
30      */
31     int arity;
32
33     /**
34      * This points to an array of pointers to the tuple item domains
35      * as represented by their associated itemkeyfun records.
36      */
37     itemkeyfun **columns;
38 } tupleschema;
39
40 /**
41  * Create a tuples with given values.
42  */
43 extern tuple *tuple_create(int arity,...);
44
45 /**
46  * Create a tuples with given values.
47  */
48 extern tupleschema *tupleschema_create(int arity,tuple *columns);
49
50 /**
51  * Copy the given tupleschema into a new tupleschema with some columns
52  * masked. This represents a sub-index type using the unmasked columns
53  * for indexing.
54  */
55 extern tupleschema *tupleschema_mask(tupleschema *schema,...);
56
57 /**
58  * \brief Return 1/0 to indicate whether the query matches the item.
59  */
60 extern int tupleschema_match(tupleschema *def,tuple *query,tuple *item);
61
62 /**
63  * The TUPLEITEMINIT macro is used for initializing a tupleschema
64  * record appropriately for a given arity and corresponding sequence
65  * of parts itemkeyfun pointers.
66  */
67 #define TUPLEITEMINIT(arity, ... ) {    \
68         .functions = {                          \
69             .hashcode = tupleitem_hashcode,     \
70             .haskey = tupleitem_haskey,         \
71             .itemkey = tupleitem_itemkey,       \
72             .releasekey = tupleitem_releasekey  \
73         },                                      \
74             .arity = arity,                     \
75             .schema = { __VA_ARGS__ }           \
76     }
77
78 #endif