/* * Copyright (c) 2006 Teodor Sigaev * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __FTSBENCH_H__ #define __FTSBENCH_H__ #include /* utils */ typedef struct { char* str; int strlen; int length; } StringBuf; void sb_add(StringBuf *b, char *s, int length); #define sb_addchar(s, c) do { \ if ( (s)->strlen < (s)->length ) \ (s)->str[ (s)->strlen++ ] = (c); \ else { \ char __c = (c); \ sb_add( (s), &__c, 1); \ } \ } while(0) void printScheme(); /* rand.c */ long rnd(); void srnd(long seed); /* finngan.c */ void generate_doc(StringBuf *b); char** generate_querywords(); void finnegan_init(char *lex_file, char *doc_file, int quiet); /* main part */ void report(const char *format, ...); void fatal(const char *format, ...); typedef struct ftsDB { void (*execQuery)(struct ftsDB*, char **, int); void (*startCreateScheme)(struct ftsDB*, int); void (*finishCreateScheme)(struct ftsDB*); void (*InsertRow)(struct ftsDB*, int, char*); void (*Close)(struct ftsDB*); /* stats */ pthread_mutex_t nqueryMutex; int nquery; int nres; /* follow db specific fields */ } ftsDB; #ifdef WITH_PGSQL ftsDB* PGInit(char * connstr); #else #define PGInit NULL #endif #ifdef WITH_MYSQL ftsDB* MYInit(char * connstr); #else #define MYInit NULL #endif #define FLG_GIST (0x00000001) #define FLG_GIN (0x00000002) #define FLG_FUNC (0x00000004) #define FLG_AND (0x00000008) #define FLG_OR (0x00000010) #endif