From e887b2e80a665a45b411a0d9fd832f96a1a4f893 Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Fri, 8 Jul 2022 15:16:12 +1000 Subject: [PATCH 1/1] reworked hasing with "query" --- vector/tupleitem.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/vector/tupleitem.c b/vector/tupleitem.c index c63e3ec..ad13267 100644 --- a/vector/tupleitem.c +++ b/vector/tupleitem.c @@ -26,11 +26,15 @@ 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; @@ -46,15 +50,10 @@ static int tupleitem_haskey(void *this,void *item,void *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; -- 2.39.2