-void *Relation_next(Relation *r,VectorIndex *index,tuple *Query) {
- return HashVector_next( &r->content, index, Query );
+void *Relation_next(Relation *r,VectorIndex *index,Tuple *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;