#define SIZE(x) (sizeof(x)/sizeof(void*))
-static char *tuple2string(Relation *r,tuple *t) {
+static char *tuple2string(Relation *r,Tuple *t) {
#define LIMIT 10000
static char tmp[10][ LIMIT ];
static int i = 0;
return tmp[i++];
}
-static void query_report(Relation *r,tuple *query) {
+static void query_report(Relation *r,Tuple *query) {
VectorIndex i;
for ( i = 0; i < r->content.table.size; i++ ) {
- tuple *t = HashVector_next( &r->content, &i, query );
+ Tuple *t = Relation_next( r, &i, query );
fprintf( stderr, "check %s\n", tuple2string( r, t ) );
}
}
-static void query_report_all(Relation *r,tuple *query[]) {
+static void query_report_all(Relation *r,Tuple *query[]) {
int j;
for ( j = 0; query[j]; j++ ) {
fprintf( stderr, "query %s\n", tuple2string( r, query[j] ) );
VectorIndex i;
if ( v ) {
for ( i = 0; i < v->size; i++ ) {
- tuple **t = (tuple **) Vector_next_used( v, &i );
+ Tuple **t = (Tuple **) Vector_next_used( v, &i );
fprintf( stderr, "knock %s\n", tuple2string( r, t? *t : 0 ) );
}
Vector_resize( v, 0, Vector_clear_any, 0 );
}
// Test addition with several tuples, terminated by 0
-static void test_Relation_add(Relation *r,tuple *query[]) {
+static void test_Relation_add(Relation *r,Tuple *query[]) {
int j;
for ( j = 0; query[j]; j++ ) {
fprintf( stderr, "add %s\n", tuple2string( r, query[j] ) );
}
// Test deletion with several queries, terminated by 0
-static void test_Relation_delete(Relation *r,tuple *query[]) {
+static void test_Relation_delete(Relation *r,Tuple *query[]) {
int j;
for ( j = 0; query[j]; j++ ) {
fprintf( stderr, "delete %s\n", tuple2string( r, query[j] ) );
int main(int argc,char **argv) {
// AxB
- tuple *data2[] = {
+ Tuple *data2[] = {
TUPLE( "a", "b" ),
TUPLE( "a", "c" ),
TUPLE( "a", "d" ),
TUPLE( "b", "d" ),
0
};
- tuple *query2[] = {
+ Tuple *query2[] = {
TUPLE( "a", 0 ),
TUPLE( 0, "d" ),
0
test_Relation_delete( &rel2, query2 );
// AxBxC
- tuple *data3[] = {
+ Tuple *data3[] = {
TUPLE( "a", "b", "c" ), // <a,b,?> <a,?,c> ***
TUPLE( "a", "c", "d" ), // <a,c,?> <a,?,d> ***
TUPLE( "a", "b", "e" ), // <a,b,?> <a,?,e> => -<a,b,c>
TUPLE( "f", "b", "d" ), // <f,b,?> <f,?,c>
0
};
- tuple *query3[] = {
+ Tuple *query3[] = {
TUPLE( "a", 0, "d" ),
TUPLE( 0, 0, "d" ),
TUPLE( 0, "c", 0 ),