fix vararg usae; use static callbacks
[rrq/rrqmisc.git] / vector / tupleitem.h
index baec9e3806d51e5d0897713d52d1f9b7169f5cb4..595666848c34a9f49be0a0158c1385b1991b3979 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,53 +23,35 @@ 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;
 
 /**
- * This callback function returns the hashcode of a key.
- *
- * \param this is a pointer to the itemkeyfun record from where this
- * callback got invoked
- *
- * \param key is the key to produce a hascode for
- *
- * \returns the hashcode which is a vector_index (i.e. unsigned long)
- *
- * The hashcode is used for indexing into the backing vector for
- * finding the an item via its key. The same key must map consistently
- * to the same hashcode while the hashtable contains an item with that
- * key. Different keys map map to the same hashcode, in which case the
- * vector placement is made at the first empty or hole slot following
- * the hashcode index.
- */
-extern unsigned long tupleitem_hashcode(itemkeyfun *this,void *key);
-
-/**
- * This callback function determines whether an item has a
- * given key or not.
+ * Create a tuples with given values.
  */
-extern int tupleitem_haskey(itemkeyfun *this,void *item,void *key);
+extern tuple *tuple_create(int arity,...);
 
 /**
- * This callback function returns the key of an item by considering
- * the arity and schema.
+ * Create a tuples with given values.
  */
-extern void *tupleitem_itemkey(itemkeyfun *this,void *item);
+extern tupleschema *tupleschema_create(int arity,tuple *columns);
 
 /**
- * This callback function handles a key obtained from the itemkey
- * callback function to reclaim temporary allocation.
+ * 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 void tupleitem_releasekey(itemkeyfun *this,void *key);
+extern tupleschema *tupleschema_mask(tupleschema *schema,...);
 
 /**
  * The TUPLEITEMINIT macro is used for initializing a tupleschema
@@ -72,7 +59,7 @@ extern void tupleitem_releasekey(itemkeyfun *this,void *key);
  * of parts itemkeyfun pointers.
  */
 #define TUPLEITEMINIT(arity, ... ) {   \
-       functions = {                           \
+       .functions = {                          \
            .hashcode = tupleitem_hashcode,     \
            .haskey = tupleitem_haskey,         \
            .itemkey = tupleitem_itemkey,       \