Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
2aa80e0b
Commit
2aa80e0b
authored
Mar 07, 2005
by
svoj@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG#8351 post-review improvements.
parent
efa1092c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
31 deletions
+38
-31
myisam/ft_boolean_search.c
myisam/ft_boolean_search.c
+28
-21
myisam/ft_parser.c
myisam/ft_parser.c
+10
-10
No files found.
myisam/ft_boolean_search.c
View file @
2aa80e0b
...
...
@@ -68,7 +68,6 @@ struct st_ftb_expr
my_off_t
docid
[
2
];
float
weight
;
float
cur_weight
;
byte
*
quot
,
*
qend
;
LIST
*
phrase
;
/* phrase words */
uint
yesses
;
/* number of "yes" words matched */
uint
nos
;
/* number of "no" words matched */
...
...
@@ -133,7 +132,7 @@ static int FTB_WORD_cmp_list(CHARSET_INFO *cs, FTB_WORD **a, FTB_WORD **b)
}
static
void
_ftb_parse_query
(
FTB
*
ftb
,
byte
**
start
,
byte
*
end
,
FTB_EXPR
*
up
,
uint
depth
)
FTB_EXPR
*
up
,
uint
depth
,
byte
*
up_quot
)
{
byte
res
;
FTB_PARAM
param
;
...
...
@@ -148,8 +147,7 @@ static void _ftb_parse_query(FTB *ftb, byte **start, byte *end,
return
;
param
.
prev
=
' '
;
param
.
quot
=
up
->
quot
;
up
->
phrase
=
NULL
;
param
.
quot
=
up_quot
;
while
((
res
=
ft_get_word
(
ftb
->
charset
,
start
,
end
,
&
w
,
&
param
)))
{
int
r
=
param
.
plusminus
;
...
...
@@ -176,8 +174,8 @@ static void _ftb_parse_query(FTB *ftb, byte **start, byte *end,
if
(
param
.
yesno
>
0
)
up
->
ythresh
++
;
queue_insert
(
&
ftb
->
queue
,
(
byte
*
)
ftbw
);
ftb
->
with_scan
|=
(
param
.
trunc
&
FTB_FLAG_TRUNC
);
case
4
:
if
(
!
up
->
quot
)
break
;
case
4
:
/* not indexed word (stopword or too short/long) */
if
(
!
up
_
quot
)
break
;
phrase_word
=
(
FT_WORD
*
)
alloc_root
(
&
ftb
->
mem_root
,
sizeof
(
FT_WORD
));
phrase_list
=
(
LIST
*
)
alloc_root
(
&
ftb
->
mem_root
,
sizeof
(
LIST
));
phrase_word
->
pos
=
w
.
pos
;
...
...
@@ -194,17 +192,14 @@ static void _ftb_parse_query(FTB *ftb, byte **start, byte *end,
ftbe
->
up
=
up
;
ftbe
->
ythresh
=
ftbe
->
yweaks
=
0
;
ftbe
->
docid
[
0
]
=
ftbe
->
docid
[
1
]
=
HA_OFFSET_ERROR
;
if
((
ftbe
->
quot
=
param
.
quot
))
ftb
->
with_scan
|=
2
;
ftbe
->
phrase
=
NULL
;
if
(
param
.
quot
)
ftb
->
with_scan
|=
2
;
if
(
param
.
yesno
>
0
)
up
->
ythresh
++
;
_ftb_parse_query
(
ftb
,
start
,
end
,
ftbe
,
depth
+
1
);
_ftb_parse_query
(
ftb
,
start
,
end
,
ftbe
,
depth
+
1
,
param
.
quot
);
param
.
quot
=
0
;
break
;
case
3
:
/* right bracket */
if
(
up
->
quot
)
{
up
->
qend
=
param
.
quot
;
up
->
phrase
=
list_reverse
(
up
->
phrase
);
}
if
(
up_quot
)
up
->
phrase
=
list_reverse
(
up
->
phrase
);
return
;
}
}
...
...
@@ -426,12 +421,12 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query,
ftbe
->
weight
=
1
;
ftbe
->
flags
=
FTB_FLAG_YES
;
ftbe
->
nos
=
1
;
ftbe
->
quot
=
0
;
ftbe
->
up
=
0
;
ftbe
->
ythresh
=
ftbe
->
yweaks
=
0
;
ftbe
->
docid
[
0
]
=
ftbe
->
docid
[
1
]
=
HA_OFFSET_ERROR
;
ftbe
->
phrase
=
NULL
;
ftb
->
root
=
ftbe
;
_ftb_parse_query
(
ftb
,
&
query
,
query
+
query_len
,
ftbe
,
0
);
_ftb_parse_query
(
ftb
,
&
query
,
query
+
query_len
,
ftbe
,
0
,
NULL
);
ftb
->
list
=
(
FTB_WORD
**
)
alloc_root
(
&
ftb
->
mem_root
,
sizeof
(
FTB_WORD
*
)
*
ftb
->
queue
.
elements
);
memcpy
(
ftb
->
list
,
ftb
->
queue
.
root
+
1
,
sizeof
(
FTB_WORD
*
)
*
ftb
->
queue
.
elements
);
...
...
@@ -447,15 +442,27 @@ err:
}
/* returns 1 if str0 ~= /\bstr1\b/ */
static
int
_ftb_strstr
(
const
byte
*
s0
,
const
byte
*
e0
,
/*
Checks if given buffer matches phrase list.
SYNOPSIS
_ftb_check_phrase()
s0 start of buffer
e0 end of buffer
phrase broken into list phrase
cs charset info
RETURN VALUE
1 is returned if phrase found, 0 else.
*/
static
int
_ftb_check_phrase
(
const
byte
*
s0
,
const
byte
*
e0
,
LIST
*
phrase
,
CHARSET_INFO
*
cs
)
{
FT_WORD
h_word
;
const
byte
*
h_start
=
s0
;
DBUG_ENTER
(
"_ftb_strstr"
);
if
(
!
phrase
)
DBUG_RETURN
(
0
);
DBUG_ASSERT
(
phrase
);
while
(
ft_simple_get_word
(
cs
,
(
byte
**
)
&
h_start
,
e0
,
&
h_word
,
FALSE
))
{
...
...
@@ -504,7 +511,7 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_
{
yn
=
ftbe
->
flags
;
weight
=
ftbe
->
cur_weight
*
ftbe
->
weight
;
if
(
mode
&&
ftbe
->
quot
)
if
(
mode
&&
ftbe
->
phrase
)
{
int
not_found
=
1
;
...
...
@@ -513,7 +520,7 @@ static void _ftb_climb_the_tree(FTB *ftb, FTB_WORD *ftbw, FT_SEG_ITERATOR *ftsi_
{
if
(
!
ftsi
.
pos
)
continue
;
not_found
=
!
_ftb_
strstr
(
ftsi
.
pos
,
ftsi
.
pos
+
ftsi
.
len
,
not_found
=
!
_ftb_
check_phrase
(
ftsi
.
pos
,
ftsi
.
pos
+
ftsi
.
len
,
ftbe
->
phrase
,
ftb
->
charset
);
}
if
(
not_found
)
break
;
...
...
myisam/ft_parser.c
View file @
2aa80e0b
...
...
@@ -93,13 +93,14 @@ my_bool ft_boolean_check_syntax_string(const byte *str)
return
0
;
}
/* returns:
* 0 - eof
* 1 - word found
* 2 - left bracket
* 3 - right bracket
* 4 - stopword found
*/
/*
RETURN VALUE
0 - eof
1 - word found
2 - left bracket
3 - right bracket
4 - stopword found
*/
byte
ft_get_word
(
CHARSET_INFO
*
cs
,
byte
**
start
,
byte
*
end
,
FT_WORD
*
word
,
FTB_PARAM
*
param
)
{
...
...
@@ -162,7 +163,7 @@ byte ft_get_word(CHARSET_INFO *cs, byte **start, byte *end,
*
start
=
doc
;
return
1
;
}
else
if
(
length
)
else
if
(
length
)
/* make sure length > 0 (if start contains spaces only) */
{
*
start
=
doc
;
return
4
;
...
...
@@ -207,8 +208,7 @@ byte ft_simple_get_word(CHARSET_INFO *cs, byte **start, const byte *end,
*
start
=
doc
;
DBUG_RETURN
(
1
);
}
}
while
(
doc
<
end
);
}
while
(
doc
<
end
);
DBUG_RETURN
(
0
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment