return "(null)";
}
-void prtuple(char *pre, tuple *t) {
+void prtuple(char *pre, Tuple *t) {
if ( t ) {
- fprintf( stderr, "%s<%s, %s>\n", pre, val((*t)[0]), val((*t)[1]) );
+ fprintf( stderr, "%s<%s, %s>\n", pre,
+ val(t->elements[0]), val(t->elements[1]) );
} else {
// fprintf( stderr, "%s< >\n", pre );
}
}
void prdropout(const VectorIndex index,const void *t) {
- prtuple( ".. ", (tuple*)t );
+ prtuple( ".. ", (Tuple*)t );
}
void add_Relation(Relation *r,char *p,char *c) {
- tuple *t = tuple_create( 2, p, c);
+ Tuple *t = Tuple_create( 2, p, c);
prtuple( "Adding: ", t );
Vector *dropped = Relation_add( r, t );
if ( dropped ) {
}
typedef union {
+ Tuple tup;
struct {
+ void *type;
void *c1;
void *c2;
} cols;
- void *tup[2];
-} tuple2;
+} Tuple2;
int main(int argc,char **argv) {
Relation *rltn2 = Relation_create(
TupleSchema_create(
- 2, tuple_create( 2, (void*) &stringitem, (void*) &stringitem ) ) );
+ Tuple_create( 2, (void*) &stringitem, (void*) &stringitem ) ) );
Relation_add_constraint( rltn2, 0, 1 );
add_Relation( rltn2, "benton", "holly" );
add_Relation( rltn2, "benton", "molly");
add_Relation( rltn2, "gully", "holly");
add_Relation( rltn2, "gully", "vanitha");
VectorIndex index = 0;
- tuple2 q1 = {{ "benton", 0 }};
- tuple *t;
+ Tuple2 q1 = (Tuple2) { .cols = { 0, "benton", 0 }};
+ Tuple *t;
prtuple( "Simple query: ", &q1.tup );
for ( ; index < rltn2->content.table.size; index++ ) {
t = Relation_next( rltn2, &index, &q1.tup );
prtuple( ".. ", t );
}
// Test Generic query
- q1 = (tuple2) {{ 0, 0 }};
+ q1 = (Tuple2) { .cols = { 0, 0, 0 }};
prtuple( "Generic query: ", &q1.tup );
for ( index = 0 ; index < rltn2->content.table.size; index++ ) {
t = Relation_next( rltn2, &index, &q1.tup );
prtuple( ".. ", t );
}
// Test deletion
- q1 = (tuple2) {{ "gully", 0 }};
+ q1 = (Tuple2) { .cols = { 0, "gully", 0 }};
prtuple( "Deletion query: ", &q1.tup );
Vector *deleted = Relation_delete( rltn2, &q1.tup );
for ( index = 0 ; index < rltn2->content.table.size; index++ ) {
prtuple( ".. ", t );
}
for ( index = 0 ; index < deleted->size; index++ ) {
- tuple **p = (tuple**) Vector_next_used( deleted, &index );
+ Tuple **p = (Tuple**) Vector_next_used( deleted, &index );
prtuple( "** ", p? *p : 0 );
}
return 0;