// for ignoring full matches to the key tuple.
static int knockout_check(VectorIndex index,void *item,void *data) {
Knockout *kod = (Knockout*) data;
+ void *key = kod->item;
+ HashVector *hv = (HashVector*) item;
+ TupleSchema *type = (TupleSchema *)hv->type;
VectorIndex i = 0;
- for ( ; i < ((HashVector*) item)->table.size; i++ ) {
- void *old = HashVector_next( (HashVector*) item, &i, kod->item );
+ for ( ; i < hv->table.size; i++ ) {
+ void *old = HashVector_next( hv, &i );
if ( old ) {
+ if ( key && type->base.haskey( type, old, key ) == 0 ) {
+ continue;
+ }
HashVector_add( &kod->knockouts, old );
}
}
// Delete them from all tables
VectorIndex i;
for ( i = 0; i < this->knockouts.table.size; i++ ) {
- void *t = HashVector_next( &this->knockouts, &i, 0 );
+ void *t = HashVector_next( &this->knockouts, &i );
if ( t ) {
HashVector_delete( &r->content, t );
Vector_iterate( &r->constraints, 0, knockout_delete, t );
}
void *Relation_next(Relation *r,VectorIndex *index,Tuple *query) {
- return HashVector_next( &r->content, index, query );
+ HashVector *hv = &r->content;
+ void *key = query;
+ TupleSchema *type = (TupleSchema *) hv->type;
+ for ( ; (*index) < hv->table.size; (*index)++ ) {
+ void *old = HashVector_next( hv, index );
+ if ( old ) {
+ if ( key && type->base.haskey( type, old, key ) == 0 ) {
+ continue;
+ }
+ return old;
+ }
+ }
+ (*index) = hv->table.size;
+ return 0;
}