* vector placement is made at the first empty or hole slot following
* the hashcode index.
*/
-static unsigned long tupleitem_hashcode(itemkeyfun *this,void *key) {
+static unsigned long tupleitem_hashcode(void *this,void *key) {
tupleschema *def = (tupleschema *) this;
tuple *kp = (tuple*) key;
int i = 0;
* This callback function determines whether an item has a
* given key or not.
*/
-static int tupleitem_haskey(itemkeyfun *this,void *item,void *key) {
+static int tupleitem_haskey(void *this,void *item,void *key) {
tupleschema *def = (tupleschema *) this;
tuple *kp = (tuple*) key;
tuple *tp = (tuple*) item;
int i = 0;
- int haskey = 1;
for ( ; i < def->arity; i++ ) {
- if ( COLUMN[i] ) {
- haskey &= COLUMN[i]->haskey( COLUMN[i], (*tp)[i], (*kp)[i] );
+ if ( COLUMN[i] == 0 ) {
+ if ( (*kp)[i] && (*tp)[i] != (*kp)[i] ) {
+ return 0;
+ }
+ continue;
+ }
+ if ( (*kp)[i] &&
+ COLUMN[i]->haskey( COLUMN[i], (*tp)[i], (*kp)[i] ) == 0 ) {
+ return 0;
}
}
- return haskey;
+ return 1;
}
* This callback function returns the key of an item by considering
* the arity and mask.
*/
-static void *tupleitem_itemkey(itemkeyfun *this,void *item) {
+static void *tupleitem_itemkey(void *this,void *item) {
tupleschema *def = (tupleschema *) this;
tuple *tp = (tuple*) item;
int i, j;
* This callback function handles a key obtained from the itemkey
* callback function to reclaim temporary allocation.
*/
-static void tupleitem_releasekey(itemkeyfun *this,void *key) {
+static void tupleitem_releasekey(void *this,void *key) {
tupleschema *def = (tupleschema *) this;
tuple *kp = (tuple*) key;
int i,j;
tupleschema *tupleschema_create(int arity,tuple *columns) {
tupleschema *ts = (tupleschema*) malloc( sizeof( tupleschema ) );
(*ts) = (tupleschema) {
- .functions = {
+ .base = {
.hashcode = tupleitem_hashcode,
.haskey = tupleitem_haskey,
.itemkey = tupleitem_itemkey,
}
return mask;
}
+