" -l LEXFILE - file with words and its frequents (default gendata/lex)\n"
" -g GAMMAFILE - file with doc's length distribution (default \n"
" gendata/gamma-lens)\n"
- " -l FLGAS - options for db's schema (see below)\n"
+ " -l FLAGS - options for db's schema (see below)\n"
" -s ID - SQL mode: output is a SQL queries, ID is an identifier for insert\n"
" statement\n"
" -q - do not print progress message\n",
" -l LEXFILE - file with words and its frequents (default gendata/query-lex)\n"
" -g GAMMAFILE - file with doc's length distribution (default \n"
" gendata/query-lens)\n"
- " -l FLGAS - options for db's schema (see below)\n"
+ " -l FLAGS - options for db's schema (see below)\n"
" -s ID - SQL mode: output is a SQL queries, ID is an identifier for insert\n"
" statement\n"
" -r - row mode: timing every query\n"
if ( DBDesc[i].init )
return DBDesc[i].rdbms;
} else if ( strcasecmp(name,DBDesc[i].shortname) == 0 ) {
- if ( DBDesc[i].init == NULL ) {
- fprintf(stderr,"Support of '%s' isn't compiled-in\n", DBDesc[i].longname);
- exit(1);
- }
+ if ( DBDesc[i].init == NULL )
+ fatal("Support of '%s' isn't compiled-in\n", DBDesc[i].longname);
+
return DBDesc[i].rdbms;
}
}
- fprintf(stderr,"Can't find a RDBMS\n");
- exit(1);
+ fatal("Can't find a RDBMS\n");
return NULLSQL;
}
if ( strcasestr(flg,"or") )
flags |= FLG_OR;
- if ( (flags & FLG_GIST) && (flags & FLG_GIN) ) {
- fprintf(stderr,"GIN and GiST flags are mutually exclusive\n");
- exit(1);
- }
- if ( (flags & FLG_AND) && (flags & FLG_OR) ) {
- fprintf(stderr,"AND and OR flags are mutually exclusive\n");
- exit(1);
- } else if ( ( flags & ( FLG_AND | FLG_OR ) ) == 0 )
+ if ( (flags & FLG_GIST) && (flags & FLG_GIN) )
+ fatal("GIN and GiST flags are mutually exclusive\n");
+ if ( (flags & FLG_AND) && (flags & FLG_OR) )
+ fatal("AND and OR flags are mutually exclusive\n");
+ else if ( ( flags & ( FLG_AND | FLG_OR ) ) == 0 )
flags |= FLG_AND;
return flags;
ftsDB **dbs = (ftsDB**)malloc(sizeof(ftsDB*) * n);
int i;
- if (!dbs) {
- fprintf(stderr,"Not enough mwmory\n");
- exit(1);
- }
+ if (!dbs)
+ fatal("Not enough mwmory\n");
for(i=0;i<n;i++) {
dbs[i] = DBDesc[rdbms].init(connstr);
static pthread_mutex_t mutexFinish = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutexWordGen = PTHREAD_MUTEX_INITIALIZER;
+static void
+printQueryWords(StringBuf *b, char **words) {
+ char **wptr = words, *ptr;
+
+ b->strlen = 0;
+ while(*wptr) {
+ if ( wptr != words )
+ sb_add(b, " ", 1);
+
+ ptr = *wptr;
+ while( *ptr ) {
+ if ( *ptr == '\'' )
+ sb_add( b, "'", 1 );
+ sb_add( b, ptr, 1 );
+ ptr++;
+ }
+
+ wptr++;
+ }
+}
+
/*
* main test function, executed in thread
*/
char **words;
struct timeval begin;
double elapsed;
+ StringBuf b = {NULL,0,0};
for(i=0;i<benchCount;i++) {
/*
if ( rowMode ) {
elapsed = elapsedtime(&begin);
- printf("INSERT INTO fb_row (id, f_and, f_or, nclients, nres, elapsed) VALUES (%d, '%c', '%c', %d, %d, %g);\n",
+ printQueryWords(&b, words);
+
+ printf("INSERT INTO fb_row (id, f_and, f_or, nclients, query, nres, elapsed) VALUES (%d, '%c', '%c', %d, '%s', %d, %g);\n",
Id,
( benchFlags & FLG_AND ) ? 't' : 'f',
( benchFlags & FLG_OR ) ? 't' : 'f',
nClients,
+ b.str,
db->nres - nres,
elapsed
);
fflush(stdout);
}
+void
+fatal(const char *format, ...) {
+ va_list args;
+
+ va_start(args, format);
+ vfprintf(stderr, format, args);
+ va_end(args);
+
+ fflush(stderr);
+
+ exit(1);
+}
+
+
extern char *optarg;
int
pthread_mutex_lock( &mutexFinish );
for(i=0;i<nClients;i++) {
- if ( pthread_create(tid+i, NULL, execBench, (void*)dbs[i]) != 0 ) {
- fprintf(stderr,"pthread_create failed: %s\n", strerror(errno));
- exit(1);
- }
+ if ( pthread_create(tid+i, NULL, execBench, (void*)dbs[i]) != 0 )
+ fatal("pthread_create failed: %s\n", strerror(errno));
}
for(;;) {
sleepTo.tv_sec = time(NULL) + 1;
res = pthread_cond_timedwait( &condFinish, &mutexFinish, &sleepTo );
- if ( !(res == ETIMEDOUT || res == 0) ) {
- fprintf(stderr,"pthread_cond_timedwait failed: %s\n", strerror(errno));
- exit(1);
- }
+ if ( !(res == ETIMEDOUT || res == 0) )
+ fatal("pthread_cond_timedwait failed: %s\n", strerror(errno));
}
elapsed = elapsedtime(&begin);
pthread_mutex_unlock( &mutexFinish );