Below is the list of changes that have just been committed into a local
5.0 repository of svoj. When svoj does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1906 05/09/14 16:34:32 svoj@stripped +4 -0
WL#2575 - Fulltext: Parser plugin for FTS
Better names in fulltext boolean parser API.
plugin/fulltext/cnet_parser.c
1.2 05/09/14 16:34:28 svoj@stripped +3 -3
API change: mysql_add_word has 4 params now.
myisam/ft_parser.c
1.51 05/09/14 16:34:28 svoj@stripped +13 -12
Magic numbers changed to enum.
Better names according to plugin.h change.
myisam/ft_boolean_search.c
1.93 05/09/14 16:34:28 svoj@stripped +32 -31
MYSQL_FTPARSER_BOOLEAN_INFO is now param of ftb_query_add_word.
"extra" removed from MY_FTB_PARAM - not needed anymore.
include/plugin.h
1.8 05/09/14 16:34:28 svoj@stripped +13 -5
MYSQL_FTPARSER_BOOLEAN_INFO is now param of mysql_add_word.
Better names for BOOLEAN_INFO members.
boolean_info->type is enum now.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: svoj
# Host: svoj-laptop.mysql.com
# Root: /home/svoj/devel/mysql/CNET/mysql-5.0
--- 1.50/myisam/ft_parser.c 2005-09-12 16:41:46 +05:00
+++ 1.51/myisam/ft_parser.c 2005-09-14 16:34:28 +05:00
@@ -116,8 +116,8 @@
uint mwc, length, mbl;
param->yesno=(FTB_YES==' ') ? 1 : (param->quot != 0);
- param->plusminus=param->pmsign=0;
- param->type= 0;
+ param->weight_adjust= param->wasign= 0;
+ param->type= FT_CHUNK_TYPE_EOF;
while (doc<end)
{
@@ -128,7 +128,7 @@
{
param->quot=doc;
*start=doc+1;
- param->type= 3; /* FTB_RBR */
+ param->type= FT_CHUNK_TYPE_RBR;
goto ret;
}
if (!param->quot)
@@ -138,7 +138,7 @@
/* param->prev=' '; */
*start=doc+1;
if (*doc == FTB_LQUOT) param->quot=*start;
- param->type= (*doc == FTB_RBR) + 2;
+ param->type= (*doc == FTB_RBR ? FT_CHUNK_TYPE_RBR : FT_CHUNK_TYPE_LBR);
goto ret;
}
if (param->prev == ' ')
@@ -146,14 +146,14 @@
if (*doc == FTB_YES ) { param->yesno=+1; continue; } else
if (*doc == FTB_EGAL) { param->yesno= 0; continue; } else
if (*doc == FTB_NO ) { param->yesno=-1; continue; } else
- if (*doc == FTB_INC ) { param->plusminus++; continue; } else
- if (*doc == FTB_DEC ) { param->plusminus--; continue; } else
- if (*doc == FTB_NEG ) { param->pmsign=!param->pmsign; continue; }
+ if (*doc == FTB_INC ) { param->weight_adjust++; continue; } else
+ if (*doc == FTB_DEC ) { param->weight_adjust--; continue; } else
+ if (*doc == FTB_NEG ) { param->wasign= !param->wasign; continue; }
}
}
param->prev=*doc;
param->yesno=(FTB_YES==' ') ? 1 : (param->quot != 0);
- param->plusminus=param->pmsign=0;
+ param->weight_adjust= param->wasign= 0;
}
mwc=length=0;
@@ -172,13 +172,13 @@
|| param->trunc) && length < ft_max_word_len)
{
*start=doc;
- param->type= 1;
+ param->type= FT_CHUNK_TYPE_WORD;
goto ret;
}
else if (length) /* make sure length > 0 (if start contains spaces only) */
{
*start= doc;
- param->type= 4;
+ param->type= FT_CHUNK_TYPE_STOPWORD;
goto ret;
}
}
@@ -236,7 +236,8 @@
}
-static int ft_add_word(void *param, byte *word, uint word_len)
+static int ft_add_word(void *param, byte *word, uint word_len,
+ MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused)))
{
TREE *wtree;
FT_WORD w;
@@ -272,7 +273,7 @@
wtree= ((MY_FT_PARSER_PARAM *)param)->wtree;
while (ft_simple_get_word(wtree->custom_arg, &doc, end, &w, TRUE))
- if (ft_add_word(param, w.pos, w.len))
+ if (ft_add_word(param, w.pos, w.len, 0))
DBUG_RETURN(1);
DBUG_RETURN(0);
}
--- 1.92/myisam/ft_boolean_search.c 2005-09-12 16:41:46 +05:00
+++ 1.93/myisam/ft_boolean_search.c 2005-09-14 16:34:28 +05:00
@@ -134,50 +134,51 @@
typedef struct st_my_ftb_param
{
- MYSQL_FTPARSER_BOOLEAN_INFO *info;
FTB *ftb;
FTB_EXPR *ftbe;
byte *up_quot;
- uint extra;
uint depth;
} MY_FTB_PARAM;
-static int ftb_query_add_word(void *param, byte *word, uint word_len)
+static int ftb_query_add_word(void *param, byte *word, uint word_len,
+ MYSQL_FTPARSER_BOOLEAN_INFO *info)
{
MY_FTB_PARAM *ftb_param= (MY_FTB_PARAM *)param;
FTB_WORD *ftbw;
FTB_EXPR *ftbe;
FT_WORD *phrase_word;
LIST *phrase_list;
- int r= ftb_param->info->plusminus;
+ int r= info->weight_adjust;
float weight= (float)
- (ftb_param->info->pmsign ? nwghts : wghts)[(r>5)?5:((r<-5)?-5:r)];
+ (info->wasign ? nwghts : wghts)[(r>5)?5:((r<-5)?-5:r)];
- switch (ftb_param->info->type) {
- case 1: /* word found */
+ switch (info->type) {
+ case FT_CHUNK_TYPE_WORD:
ftbw= (FTB_WORD *)alloc_root(&ftb_param->ftb->mem_root,
sizeof(FTB_WORD) +
- (ftb_param->info->trunc ? MI_MAX_KEY_BUFF :
+ (info->trunc ? MI_MAX_KEY_BUFF :
word_len * ftb_param->ftb->charset->mbmaxlen +
- ftb_param->extra));
+ HA_FT_WLEN +
+ ftb_param->ftb->info->s->rec_reflength));
ftbw->len= word_len + 1;
ftbw->flags= 0;
ftbw->off= 0;
- if (ftb_param->info->yesno > 0) ftbw->flags|= FTB_FLAG_YES;
- if (ftb_param->info->yesno < 0) ftbw->flags|= FTB_FLAG_NO;
- if (ftb_param->info->trunc) ftbw->flags|= FTB_FLAG_TRUNC;
+ if (info->yesno > 0) ftbw->flags|= FTB_FLAG_YES;
+ if (info->yesno < 0) ftbw->flags|= FTB_FLAG_NO;
+ if (info->trunc) ftbw->flags|= FTB_FLAG_TRUNC;
ftbw->weight= weight;
ftbw->up= ftb_param->ftbe;
ftbw->docid[0]= ftbw->docid[1]= HA_OFFSET_ERROR;
- ftbw->ndepth= (ftb_param->info->yesno < 0) + ftb_param->depth;
+ ftbw->ndepth= (info->yesno < 0) + ftb_param->depth;
ftbw->key_root= HA_OFFSET_ERROR;
memcpy(ftbw->word + 1, word, word_len);
ftbw->word[0]= word_len;
- if (ftb_param->info->yesno > 0) ftb_param->ftbe->ythresh++;
+ if (info->yesno > 0) ftbw->up->ythresh++;
queue_insert(&ftb_param->ftb->queue, (byte *)ftbw);
- ftb_param->ftb->with_scan|= (ftb_param->info->trunc & FTB_FLAG_TRUNC);
- case 4: /* not indexed word (stopword or too short/long) */
+ ftb_param->ftb->with_scan|= (info->trunc & FTB_FLAG_TRUNC);
+ /* fall through */
+ case FT_CHUNK_TYPE_STOPWORD:
if (! ftb_param->up_quot) break;
phrase_word= (FT_WORD *)alloc_root(&ftb_param->ftb->mem_root, sizeof(FT_WORD));
phrase_list= (LIST *)alloc_root(&ftb_param->ftb->mem_root, sizeof(LIST));
@@ -186,25 +187,25 @@
phrase_list->data= (void *)phrase_word;
ftb_param->ftbe->phrase= list_add(ftb_param->ftbe->phrase, phrase_list);
break;
- case 2: /* left bracket */
+ case FT_CHUNK_TYPE_LBR:
ftbe=(FTB_EXPR *)alloc_root(&ftb_param->ftb->mem_root, sizeof(FTB_EXPR));
ftbe->flags= 0;
- if (ftb_param->info->yesno > 0) ftbe->flags|= FTB_FLAG_YES;
- if (ftb_param->info->yesno < 0) ftbe->flags|= FTB_FLAG_NO;
+ if (info->yesno > 0) ftbe->flags|= FTB_FLAG_YES;
+ if (info->yesno < 0) ftbe->flags|= FTB_FLAG_NO;
ftbe->weight= weight;
ftbe->up= ftb_param->ftbe;
ftbe->ythresh= ftbe->yweaks= 0;
ftbe->docid[0]= ftbe->docid[1]= HA_OFFSET_ERROR;
ftbe->phrase= NULL;
- if (ftb_param->info->quot) ftb_param->ftb->with_scan|= 2;
- if (ftb_param->info->yesno > 0) ftb_param->ftbe->ythresh++;
+ if (info->quot) ftb_param->ftb->with_scan|= 2;
+ if (info->yesno > 0) ftbe->up->ythresh++;
ftb_param->ftbe= ftbe;
ftb_param->depth++;
- ftb_param->up_quot= ftb_param->info->quot;
+ ftb_param->up_quot= info->quot;
break;
- case 3: /* right bracket */
+ case FT_CHUNK_TYPE_RBR:
if (ftb_param->up_quot) ftb_param->ftbe->phrase= list_reverse(ftb_param->ftbe->phrase);
- ftb_param->info->quot= 0;
+ info->quot= 0;
if (ftb_param->ftbe->up)
{
ftb_param->ftbe= ftb_param->ftbe->up;
@@ -212,6 +213,8 @@
ftb_param->up_quot= 0;
}
break;
+ case FT_CHUNK_TYPE_EOF:
+ break;
}
return(0);
}
@@ -220,14 +223,16 @@
static int ftb_parse_query_internal(void *param, byte *query, uint len)
{
MY_FTB_PARAM *ftb_param= (MY_FTB_PARAM *)param;
- MYSQL_FTPARSER_BOOLEAN_INFO *info= ftb_param->info;
+ MYSQL_FTPARSER_BOOLEAN_INFO info;
CHARSET_INFO *cs= ftb_param->ftb->charset;
byte **start= &query;
byte *end= query + len;
FT_WORD w;
- while (ft_get_word(cs, start, end, &w, info))
- ftb_query_add_word(param, w.pos, w.len);
+ info.prev= ' ';
+ info.quot= 0;
+ while (ft_get_word(cs, start, end, &w, &info))
+ ftb_query_add_word(param, w.pos, w.len, &info);
return(0);
}
@@ -241,10 +246,6 @@
if (ftb->state != UNINITIALIZED)
return;
- param.boolean_info.prev=' ';
- param.boolean_info.quot= 0;
- ftb_param.info= ¶m.boolean_info;
- ftb_param.extra= HA_FT_WLEN + ftb->info->s->rec_reflength;
ftb_param.ftb= ftb;
ftb_param.depth= 0;
ftb_param.ftbe= ftb->root;
--- 1.7/include/plugin.h 2005-09-12 16:41:45 +05:00
+++ 1.8/include/plugin.h 2005-09-14 16:34:28 +05:00
@@ -45,13 +45,21 @@
#define MYSQL_FTPARSER_NL_MODE 0
#define MYSQL_FTPARSER_DOCUMENT_MODE 2
#define MYSQL_FTPARSER_QUERY_MODE 0
+enum enum_ft_chunk_type
+{
+ FT_CHUNK_TYPE_EOF= 0,
+ FT_CHUNK_TYPE_WORD= 1,
+ FT_CHUNK_TYPE_LBR= 2,
+ FT_CHUNK_TYPE_RBR= 3,
+ FT_CHUNK_TYPE_STOPWORD= 4
+};
typedef struct st_mysql_ftparser_boolean_info
{
- int type;
+ enum enum_ft_chunk_type type;
int yesno;
- int plusminus;
- bool pmsign;
+ int weight_adjust;
+ bool wasign;
bool trunc;
/* These are parser state and must be removed. */
byte prev;
@@ -61,14 +69,14 @@
typedef struct st_mysql_ftparser_param
{
int (*mysql_parse)(void *param, byte *doc, uint doc_len);
- int (*mysql_add_word)(void *param, byte *word, uint word_len);
+ int (*mysql_add_word)(void *param, byte *word, uint word_len,
+ MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info);
void *ftparser_state;
void *mysql_ftparam;
CHARSET_INFO *cs;
byte *doc;
uint length;
int flags;
- MYSQL_FTPARSER_BOOLEAN_INFO boolean_info;
} MYSQL_FTPARSER_PARAM;
struct st_mysql_ftparser
--- 1.1/plugin/fulltext/cnet_parser.c 2005-09-02 02:59:49 +05:00
+++ 1.2/plugin/fulltext/cnet_parser.c 2005-09-14 16:34:28 +05:00
@@ -107,12 +107,12 @@
if (end == docend)
{
if (end - start > min_word_len)
- param->mysql_add_word(param->mysql_ftparam, start, end - start);
+ param->mysql_add_word(param->mysql_ftparam, start, end - start, 0);
break;
}
else if ((l= check_in_array(end, docend - end)))
{
- param->mysql_add_word(param->mysql_ftparam, end, l);
+ param->mysql_add_word(param->mysql_ftparam, end, l, 0);
end+= l;
if (end == docend)
break;
@@ -121,7 +121,7 @@
else if (! isalnum(*end))
{
if (end - start > min_word_len)
- param->mysql_add_word(param->mysql_ftparam, start, end - start);
+ param->mysql_add_word(param->mysql_ftparam, start, end - start, 0);
start= end + 1;
}
}
| Thread |
|---|
| • bk commit into 5.0 tree (svoj:1.1906) | svoj | 14 Sep |