X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=vector%2Ftupleitem.c;h=ad1326735e816c5fa7989378c8e0f1fcfe81bb69;hb=e887b2e80a665a45b411a0d9fd832f96a1a4f893;hp=99539be33c1c7c80b4c45d19e27a7963d7afad98;hpb=d9858ce46cb09b9127c7246f628e65982aa43a15;p=rrq%2Frrqmisc.git diff --git a/vector/tupleitem.c b/vector/tupleitem.c index 99539be..ad13267 100644 --- a/vector/tupleitem.c +++ b/vector/tupleitem.c @@ -22,15 +22,19 @@ * 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; - unsigned long value = 0; + unsigned long value = 5381; for ( ; i < def->arity; i++ ) { if ( COLUMN[i] ) { value <<= 3; - value += COLUMN[i]->hashcode( COLUMN[i], (*kp)[i] ); + if ( (*kp)[i] ) { + value += COLUMN[i]->hashcode( COLUMN[i], (*kp)[i] ); + } else { + value += 17; + } } } return value; @@ -40,21 +44,16 @@ static unsigned long tupleitem_hashcode(itemkeyfun *this,void *key) { * 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; for ( ; i < def->arity; i++ ) { - if ( COLUMN[i] == 0 ) { - if ( (*kp)[i] && (*tp)[i] != (*kp)[i] ) { + if ( COLUMN[i] && (*kp)[i] ) { + if ( COLUMN[i]->haskey( COLUMN[i], (*tp)[i], (*kp)[i] ) == 0 ) { return 0; } - continue; - } - if ( (*kp)[i] && - COLUMN[i]->haskey( COLUMN[i], (*tp)[i], (*kp)[i] ) == 0 ) { - return 0; } } return 1; @@ -65,7 +64,7 @@ static int tupleitem_haskey(itemkeyfun *this,void *item,void *key) { * 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; @@ -88,7 +87,7 @@ static void *tupleitem_itemkey(itemkeyfun *this,void *item) { * 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;