updates towards supporting relation.
[rrq/rrqmisc.git] / vector / tupleitem.h
index baec9e3806d51e5d0897713d52d1f9b7169f5cb4..37d5e248f99b41c73fa9748be9837a6a40346dda 100644 (file)
@@ -3,6 +3,11 @@
 
 #include <itemkeyfun.h>
 
+/**
+ * A tuple is an array of void*
+ */
+typedef void *tuple[];
+
 /**
  * A tupleschema record declares the itemkeyfun functions for tuple
  * items together with applicable arity and domain combinations. The
@@ -18,15 +23,17 @@ typedef struct {
      * provide the handling of the tuple columns.
      */
     itemkeyfun functions;
+
     /**
      * This is the number of columns in a tuple.
      */
     int arity;
+
     /**
-     * This is an array of pointers to the tuple item domains as
-     * represented by their associated itemkeyfun records.
+     * This points to an array of pointers to the tuple item domains
+     * as represented by their associated itemkeyfun records.
      */
-    itemkeyfun **schema;
+    itemkeyfun **columns;
 } tupleschema;
 
 /**
@@ -66,13 +73,30 @@ extern void *tupleitem_itemkey(itemkeyfun *this,void *item);
  */
 extern void tupleitem_releasekey(itemkeyfun *this,void *key);
 
+/**
+ * Create a tuples with given values.
+ */
+extern tuple *tuple_create(int arity,...);
+
+/**
+ * Create a tuples with given values.
+ */
+extern tupleschema *tupleschema_create(int arity,tuple *columns);
+
+/**
+ * Copy the given tupleschema into a new tupleschema with some columns
+ * masked. This represents a sub-index type using the unmasked columns
+ * for indexing.
+ */
+extern tupleschema *tupleschema_mask(tupleschema *schema,...);
+
 /**
  * The TUPLEITEMINIT macro is used for initializing a tupleschema
  * record appropriately for a given arity and corresponding sequence
  * of parts itemkeyfun pointers.
  */
 #define TUPLEITEMINIT(arity, ... ) {   \
-       functions = {                           \
+       .functions = {                          \
            .hashcode = tupleitem_hashcode,     \
            .haskey = tupleitem_haskey,         \
            .itemkey = tupleitem_itemkey,       \