#include "ftdefs.h"#include "ft_eval.h"#include <stdarg.h>#include <my_getopt.h>Include dependency graph for ft_eval.c:

Go to the source code of this file.
Functions | |
| static void | print_error (int exit_code, const char *fmt,...) |
| static void | get_options (int argc, char *argv[]) |
| static int | create_record (char *pos, FILE *file) |
| static void | usage () |
| int | main (int argc, char *argv[]) |
| static my_bool | get_one_option (int optid, const struct my_option *opt __attribute__((unused)), char *argument) |
Variables | |
| static struct my_option | my_long_options [] |
| static int create_record | ( | char * | pos, | |
| FILE * | file | |||
| ) | [static] |
Definition at line 203 of file ft_eval.c.
References blob_record, bzero, int2store, int4store, st_columndef::length, MAX_BLOB_LENGTH, MAX_REC_LENGTH, memcpy_fixed, print_error(), recinfo, and strlen().
Referenced by main(), and run_test().
00204 { 00205 uint tmp; char *ptr; 00206 00207 bzero((char *)pos,MAX_REC_LENGTH); 00208 00209 /* column 1 - VARCHAR */ 00210 if (!(fgets(pos+2,MAX_REC_LENGTH-32,file))) 00211 { 00212 if (feof(file)) 00213 return 0; 00214 else 00215 print_error(1,"fgets(docid) - 1"); 00216 } 00217 tmp=(uint) strlen(pos+2)-1; 00218 int2store(pos,tmp); 00219 pos+=recinfo[0].length; 00220 00221 /* column 2 - BLOB */ 00222 00223 if (!(fgets(blob_record,MAX_BLOB_LENGTH,file))) 00224 print_error(1,"fgets(docid) - 2"); 00225 tmp=(uint) strlen(blob_record); 00226 int4store(pos,tmp); 00227 ptr=blob_record; 00228 memcpy_fixed(pos+4,&ptr,sizeof(char*)); 00229 return 1; 00230 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static my_bool get_one_option | ( | int | optid, | |
| const struct my_option *opt | __attribute__((unused)), | |||
| char * | argument | |||
| ) | [static] |
Definition at line 139 of file ft_eval.c.
References DBUG_PUSH, exit, f, ft_precompiled_stopwords, malloc, n, NULL, print_error(), realloc, silent, stopwordlist, strdup(), SWL_INIT, SWL_PLUS, and usage().
00141 { 00142 switch (optid) { 00143 case 's': 00144 if (stopwordlist && stopwordlist != ft_precompiled_stopwords) 00145 break; 00146 { 00147 FILE *f; char s[HA_FT_MAXLEN]; int i=0,n=SWL_INIT; 00148 00149 if (!(stopwordlist=(const char**) malloc(n*sizeof(char *)))) 00150 print_error(1,"malloc(%d)",n*sizeof(char *)); 00151 if (!(f=fopen(argument,"r"))) 00152 print_error(1,"fopen(%s)",argument); 00153 while (!feof(f)) 00154 { 00155 if (!(fgets(s,HA_FT_MAXLEN,f))) 00156 print_error(1,"fgets(s,%d,%s)",HA_FT_MAXLEN,argument); 00157 if (!(stopwordlist[i++]=strdup(s))) 00158 print_error(1,"strdup(%s)",s); 00159 if (i >= n) 00160 { 00161 n+=SWL_PLUS; 00162 if (!(stopwordlist=(const char**) realloc((char*) stopwordlist, 00163 n*sizeof(char *)))) 00164 print_error(1,"realloc(%d)",n*sizeof(char *)); 00165 } 00166 } 00167 fclose(f); 00168 stopwordlist[i]=NULL; 00169 break; 00170 } 00171 case 'q': silent=1; break; 00172 case 'S': if (stopwordlist==ft_precompiled_stopwords) stopwordlist=NULL; break; 00173 case '#': 00174 DBUG_PUSH (argument); 00175 break; 00176 case 'V': 00177 case '?': 00178 case 'h': 00179 usage(); 00180 exit(1); 00181 } 00182 return 0; 00183 }
Here is the call graph for this function:

| static void get_options | ( | int | argc, | |
| char * | argv[] | |||
| ) | [static] |
Definition at line 186 of file ft_eval.c.
References d_file, df, exit, get_one_option(), handle_options(), my_long_options, print_error(), q_file, and qf.
00187 { 00188 int ho_error; 00189 00190 if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) 00191 exit(ho_error); 00192 00193 if (!(d_file=argv[optind])) print_error(1,"No d_file"); 00194 if (!(df=fopen(d_file,"r"))) 00195 print_error(1,"fopen(%s)",d_file); 00196 if (!(q_file=argv[optind+1])) print_error(1,"No q_file"); 00197 if (!(qf=fopen(q_file,"r"))) 00198 print_error(1,"fopen(%s)",q_file); 00199 return; 00200 } /* get options */
Here is the call graph for this function:

| int main | ( | int | argc, | |
| char * | argv[] | |||
| ) |
Definition at line 39 of file ft_eval.c.
References st_HA_KEYSEG::bit_start, blob_record, st_mi_keydef::block_length, bzero, create_record(), df, docid_length, err, error, FIELD_BLOB, FIELD_SKIP_ENDSPACE, filename, st_mi_keydef::flag, st_HA_KEYSEG::flag, ft_init_stopwords(), ft_nlq_close_search(), ft_nlq_get_relevance(), ft_nlq_read_next(), get_options(), HA_BLOB_PART, HA_ERR_END_OF_FILE, HA_FULLTEXT, HA_KEYTYPE_TEXT, key_length, keyinfo, keyseg, st_mi_keydef::keysegs, st_HA_KEYSEG::language, st_HA_KEYSEG::length, mi_close(), mi_create(), mi_open(), mi_portable_sizeof_char_ptr, mi_write(), MY_CHECK_ERROR, my_end(), my_errno, MY_INIT, NULL, st_HA_KEYSEG::null_bit, st_HA_KEYSEG::null_pos, qf, read_record, recinfo, st_mi_keydef::seg, silent, st_HA_KEYSEG::start, stopwordlist, strlen(), st_HA_KEYSEG::type, and uint2korr.
00040 { 00041 MI_INFO *file; 00042 int i,j; 00043 00044 MY_INIT(argv[0]); 00045 get_options(argc,argv); 00046 bzero((char*)recinfo,sizeof(recinfo)); 00047 00048 /* First define 2 columns */ 00049 recinfo[0].type=FIELD_SKIP_ENDSPACE; 00050 recinfo[0].length=docid_length; 00051 recinfo[1].type=FIELD_BLOB; 00052 recinfo[1].length= 4+mi_portable_sizeof_char_ptr; 00053 00054 /* Define a key over the first column */ 00055 keyinfo[0].seg=keyseg; 00056 keyinfo[0].keysegs=1; 00057 keyinfo[0].block_length= 0; /* Default block length */ 00058 keyinfo[0].seg[0].type= HA_KEYTYPE_TEXT; 00059 keyinfo[0].seg[0].flag= HA_BLOB_PART; 00060 keyinfo[0].seg[0].start=recinfo[0].length; 00061 keyinfo[0].seg[0].length=key_length; 00062 keyinfo[0].seg[0].null_bit=0; 00063 keyinfo[0].seg[0].null_pos=0; 00064 keyinfo[0].seg[0].bit_start=4; 00065 keyinfo[0].seg[0].language=MY_CHARSET_CURRENT; 00066 keyinfo[0].flag = HA_FULLTEXT; 00067 00068 if (!silent) 00069 printf("- Creating isam-file\n"); 00070 if (mi_create(filename,1,keyinfo,2,recinfo,0,NULL,(MI_CREATE_INFO*) 0,0)) 00071 goto err; 00072 if (!(file=mi_open(filename,2,0))) 00073 goto err; 00074 if (!silent) 00075 printf("Initializing stopwords\n"); 00076 ft_init_stopwords(stopwordlist); 00077 00078 if (!silent) 00079 printf("- Writing key:s\n"); 00080 00081 my_errno=0; 00082 i=0; 00083 while (create_record(record,df)) 00084 { 00085 error=mi_write(file,record); 00086 if (error) 00087 printf("I= %2d mi_write: %d errno: %d\n",i,error,my_errno); 00088 i++; 00089 } 00090 fclose(df); 00091 00092 if (mi_close(file)) goto err; 00093 if (!silent) 00094 printf("- Reopening file\n"); 00095 if (!(file=mi_open(filename,2,0))) goto err; 00096 if (!silent) 00097 printf("- Reading rows with key\n"); 00098 for (i=1;create_record(record,qf);i++) 00099 { 00100 FT_DOCLIST *result; 00101 double w; 00102 int t, err; 00103 00104 result=ft_nlq_init_search(file,0,blob_record,(uint) strlen(blob_record),1); 00105 if (!result) 00106 { 00107 printf("Query %d failed with errno %3d\n",i,my_errno); 00108 goto err; 00109 } 00110 if (!silent) 00111 printf("Query %d. Found: %d.\n",i,result->ndocs); 00112 for (j=0;(err=ft_nlq_read_next(result, read_record))==0;j++) 00113 { 00114 t=uint2korr(read_record); 00115 w=ft_nlq_get_relevance(result); 00116 printf("%d %.*s %f\n",i,t,read_record+2,w); 00117 } 00118 if (err != HA_ERR_END_OF_FILE) 00119 { 00120 printf("ft_read_next %d failed with errno %3d\n",j,my_errno); 00121 goto err; 00122 } 00123 ft_nlq_close_search(result); 00124 } 00125 00126 if (mi_close(file)) goto err; 00127 my_end(MY_CHECK_ERROR); 00128 00129 return (0); 00130 00131 err: 00132 printf("got error: %3d when using myisam-database\n",my_errno); 00133 return 1; /* skip warning */ 00134 00135 }
Here is the call graph for this function:

| static void print_error | ( | int | exit_code, | |
| const char * | fmt, | |||
| ... | ||||
| ) | [static] |
Definition at line 234 of file ft_eval.c.
References args, exit, my_progname, and VOID.
00235 { 00236 va_list args; 00237 00238 va_start(args,fmt); 00239 fprintf(stderr,"%s: error: ",my_progname); 00240 VOID(vfprintf(stderr, fmt, args)); 00241 VOID(fputc('\n',stderr)); 00242 fflush(stderr); 00243 va_end(args); 00244 exit(exit_code); 00245 }
| static void usage | ( | ) | [static] |
Definition at line 3308 of file mysqltest.c.
03309 { 03310 print_version(); 03311 printf("MySQL AB, by Sasha, Matt, Monty & Jani\n"); 03312 printf("This software comes with ABSOLUTELY NO WARRANTY\n\n"); 03313 printf("Runs a test against the mysql server and compares output with a results file.\n\n"); 03314 printf("Usage: %s [OPTIONS] [database] < test_file\n", my_progname); 03315 my_print_help(my_long_options); 03316 printf(" --no-defaults Don't read default options from any options file.\n"); 03317 my_print_variables(my_long_options); 03318 }
struct my_option my_long_options[] [static] |
Initial value:
{
{"", 's', "", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"", 'q', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", 'S', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", '#', "", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"", 'V', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", '?', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"", 'h', "", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}
1.4.7

