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
e3849552
Commit
e3849552
authored
Nov 06, 2001
by
serg@serg.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
8c7186b9
1f5c9976
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
252 additions
and
137 deletions
+252
-137
include/queues.h
include/queues.h
+1
-0
myisam/ft_boolean_search.c
myisam/ft_boolean_search.c
+166
-91
myisam/ft_parser.c
myisam/ft_parser.c
+11
-23
myisam/ft_update.c
myisam/ft_update.c
+20
-12
myisam/ftdefs.h
myisam/ftdefs.h
+2
-2
mysql-test/r/fulltext_cache.result
mysql-test/r/fulltext_cache.result
+26
-4
mysql-test/t/fulltext_cache.test
mysql-test/t/fulltext_cache.test
+10
-4
mysys/queues.c
mysys/queues.c
+16
-1
No files found.
include/queues.h
View file @
e3849552
...
...
@@ -53,6 +53,7 @@ void delete_queue(QUEUE *queue);
void
queue_insert
(
QUEUE
*
queue
,
byte
*
element
);
byte
*
queue_remove
(
QUEUE
*
queue
,
uint
idx
);
void
_downheap
(
QUEUE
*
queue
,
uint
idx
);
void
queue_fix
(
QUEUE
*
queue
);
#define is_queue_inited(queue) ((queue)->root != 0)
#ifdef __cplusplus
...
...
myisam/ft_boolean_search.c
View file @
e3849552
This diff is collapsed.
Click to expand it.
myisam/ft_parser.c
View file @
e3849552
...
...
@@ -33,17 +33,16 @@ typedef struct st_ft_docstat {
double
max
,
nsum
,
nsum2
;
#endif
/* EVAL_RUN */
MI_INFO
*
info
;
uint
keynr
;
byte
*
keybuf
;
//
MI_INFO *info;
//
uint keynr;
//
byte *keybuf;
}
FT_DOCSTAT
;
static
int
FT_WORD_cmp
(
void
*
cmp_arg
__attribute__
((
unused
)),
FT_WORD
*
w1
,
FT_WORD
*
w2
)
static
int
FT_WORD_cmp
(
void
*
cmp_arg
,
FT_WORD
*
w1
,
FT_WORD
*
w2
)
{
return
_mi_compare_text
(
default_charset_info
,
(
uchar
*
)
w1
->
pos
,
w1
->
len
,
(
uchar
*
)
w2
->
pos
,
w2
->
len
,
0
);
(
uchar
*
)
w2
->
pos
,
w2
->
len
,
(
my_bool
)
cmp_arg
);
}
static
int
walk_and_copy
(
FT_WORD
*
word
,
uint32
count
,
FT_DOCSTAT
*
docstat
)
...
...
@@ -64,7 +63,9 @@ static int walk_and_copy(FT_WORD *word,uint32 count,FT_DOCSTAT *docstat)
/* transforms tree of words into the array, applying normalization */
FT_WORD
*
ft_linearize
(
MI_INFO
*
info
,
uint
keynr
,
byte
*
keybuf
,
TREE
*
wtree
)
FT_WORD
*
ft_linearize
(
//MI_INFO *info, uint keynr,
//byte *keybuf,
TREE
*
wtree
)
{
FT_WORD
*
wlist
,
*
p
;
FT_DOCSTAT
docstat
;
...
...
@@ -73,9 +74,9 @@ FT_WORD * ft_linearize(MI_INFO *info, uint keynr, byte *keybuf, TREE *wtree)
if
((
wlist
=
(
FT_WORD
*
)
my_malloc
(
sizeof
(
FT_WORD
)
*
(
1
+
wtree
->
elements_in_tree
),
MYF
(
0
))))
{
docstat
.
info
=
info
;
docstat
.
keynr
=
keynr
;
docstat
.
keybuf
=
keybuf
;
//
docstat.info=info;
//
docstat.keynr=keynr;
//
docstat.keybuf=keybuf;
docstat
.
list
=
wlist
;
docstat
.
uniq
=
wtree
->
elements_in_tree
;
#ifdef EVAL_RUN
...
...
@@ -207,19 +208,6 @@ byte ft_simple_get_word(byte **start, byte *end, FT_WORD *word)
return
0
;
}
int
is_boolean
(
byte
*
q
,
uint
len
)
{
if
(
!
len
)
return
0
;
if
(
*
q
==
FTB_YES
||
*
q
==
FTB_NO
)
return
1
;
for
(
++
q
;
--
len
;
++
q
)
{
if
((
*
q
==
FTB_YES
||
*
q
==
FTB_NO
)
&&
q
[
-
1
]
==
' '
&&
true_word_char
(
q
[
1
]))
return
1
;
}
return
0
;
}
TREE
*
ft_parse
(
TREE
*
wtree
,
byte
*
doc
,
int
doclen
)
{
byte
*
end
=
doc
+
doclen
;
...
...
myisam/ft_update.c
View file @
e3849552
...
...
@@ -29,17 +29,12 @@
/* parses a document i.e. calls _mi_ft_parse for every keyseg */
FT_WORD
*
_mi_ft_parserecord
(
MI_INFO
*
info
,
uint
keynr
,
byte
*
keybuf
,
const
byte
*
record
)
uint
_mi_ft_parse
(
TREE
*
parsed
,
MI_INFO
*
info
,
uint
keynr
,
const
byte
*
record
)
{
TREE
*
parsed
,
ptree
;
MI_KEYSEG
*
keyseg
;
byte
*
pos
;
uint
i
;
MI_KEYSEG
*
keyseg
=
info
->
s
->
keyinfo
[
keynr
].
seg
;
bzero
(
parsed
=&
ptree
,
sizeof
(
ptree
));
keyseg
=
info
->
s
->
keyinfo
[
keynr
].
seg
;
for
(
i
=
info
->
s
->
keyinfo
[
keynr
].
keysegs
-
FT_SEGS
;
i
--
;
)
{
uint
len
;
...
...
@@ -62,13 +57,26 @@ FT_WORD * _mi_ft_parserecord(MI_INFO *info, uint keynr, byte *keybuf,
}
else
len
=
keyseg
->
length
;
if
(
!
(
parsed
=
ft_parse
(
parsed
,
pos
,
len
)))
return
NULL
;
if
(
!
(
ft_parse
(
parsed
,
pos
,
len
)))
return
1
;
}
/* Handle the case where all columns are NULL */
if
(
!
is_tree_inited
(
parsed
)
&&
!
(
parsed
=
ft_parse
(
parsed
,
(
byte
*
)
""
,
0
)))
if
(
!
is_tree_inited
(
parsed
)
&&
!
(
ft_parse
(
parsed
,
(
byte
*
)
""
,
0
)))
return
1
;
else
return
0
;
}
FT_WORD
*
_mi_ft_parserecord
(
MI_INFO
*
info
,
uint
keynr
,
byte
*
keybuf
,
const
byte
*
record
)
{
TREE
ptree
;
bzero
(
&
ptree
,
sizeof
(
ptree
));
if
(
_mi_ft_parse
(
&
ptree
,
info
,
keynr
,
record
))
return
NULL
;
return
ft_linearize
(
info
,
keynr
,
keybuf
,
parsed
);
return
ft_linearize
(
/*info, keynr, keybuf, */
&
ptree
);
}
static
int
_mi_ft_store
(
MI_INFO
*
info
,
uint
keynr
,
byte
*
keybuf
,
...
...
@@ -158,7 +166,7 @@ int _mi_ft_cmp(MI_INFO *info, uint keynr, const byte *rec1, const byte *rec2)
}
/* update a document entry */
int
_mi_ft_update
(
MI_INFO
*
info
,
uint
keynr
,
byte
*
keybuf
,
int
_mi_ft_update
(
MI_INFO
*
info
,
uint
keynr
,
byte
*
keybuf
,
const
byte
*
oldrec
,
const
byte
*
newrec
,
my_off_t
pos
)
{
int
error
=
-
1
;
...
...
myisam/ftdefs.h
View file @
e3849552
...
...
@@ -120,8 +120,8 @@ byte ft_get_word(byte **, byte *, FT_WORD *, FTB_PARAM *);
byte
ft_simple_get_word
(
byte
**
,
byte
*
,
FT_WORD
*
);
TREE
*
ft_parse
(
TREE
*
,
byte
*
,
int
);
FT_WORD
*
ft_linearize
(
MI_INFO
*
,
uint
,
byte
*
,
TREE
*
);
FT_WORD
*
_mi_ft_parserecord
(
MI_INFO
*
,
uint
,
byte
*
,
const
byte
*
);
FT_WORD
*
ft_linearize
(
/*MI_INFO *, uint, byte *, */
TREE
*
);
FT_WORD
*
_mi_ft_parserecord
(
MI_INFO
*
,
uint
,
byte
*
,
const
byte
*
);
const
struct
_ft_vft
_ft_vft_nlq
;
FT_INFO
*
ft_init_nlq_search
(
MI_INFO
*
,
uint
,
byte
*
,
uint
,
my_bool
);
...
...
mysql-test/r/fulltext_cache.result
View file @
e3849552
...
...
@@ -21,8 +21,8 @@ INSERT INTO t2 VALUES (5,2,'um copo de Vodka');
INSERT INTO t2 VALUES (6,2,'um chocolate Snickers');
INSERT INTO t2 VALUES (7,1,'Bife');
INSERT INTO t2 VALUES (8,1,'Pizza de Salmao');
SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi')
as x FROM t1, t2
WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id;
SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi')
as x FROM t1, t2
WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id;
q item id x
aaaaaaaaa dsaass de sushi 1 1.92378664016724
aaaaaaaaa dsaass de Bolo de Chocolate 2 0
...
...
@@ -32,8 +32,19 @@ ssde df s fsda sad er um copo de Vodka 5 0
ssde df s fsda sad er um chocolate Snickers 6 0
aaaaaaaaa dsaass de Bife 7 0
aaaaaaaaa dsaass de Pizza de Salmao 8 0
SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi') as x FROM t2, t1
WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id;
SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi' IN BOOLEAN MODE)
as x FROM t1, t2 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id;
q item id x
aaaaaaaaa dsaass de sushi 1 1
aaaaaaaaa dsaass de Bolo de Chocolate 2 0
aaaaaaaaa dsaass de Feijoada 3 0
aaaaaaaaa dsaass de Mousse de Chocolate 4 0
ssde df s fsda sad er um copo de Vodka 5 0
ssde df s fsda sad er um chocolate Snickers 6 0
aaaaaaaaa dsaass de Bife 7 0
aaaaaaaaa dsaass de Pizza de Salmao 8 0
SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi')
as x FROM t2, t1 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id;
q item id x
aaaaaaaaa dsaass de sushi 1 1.92378664016724
aaaaaaaaa dsaass de Bolo de Chocolate 2 0
...
...
@@ -43,4 +54,15 @@ ssde df s fsda sad er um copo de Vodka 5 0
ssde df s fsda sad er um chocolate Snickers 6 0
aaaaaaaaa dsaass de Bife 7 0
aaaaaaaaa dsaass de Pizza de Salmao 8 0
SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi' IN BOOLEAN MODE)
as x FROM t2, t1 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id;
q item id x
aaaaaaaaa dsaass de sushi 1 1
aaaaaaaaa dsaass de Bolo de Chocolate 2 0
aaaaaaaaa dsaass de Feijoada 3 0
aaaaaaaaa dsaass de Mousse de Chocolate 4 0
ssde df s fsda sad er um copo de Vodka 5 0
ssde df s fsda sad er um chocolate Snickers 6 0
aaaaaaaaa dsaass de Bife 7 0
aaaaaaaaa dsaass de Pizza de Salmao 8 0
drop table t1, t2;
mysql-test/t/fulltext_cache.test
View file @
e3849552
...
...
@@ -26,10 +26,16 @@ INSERT INTO t2 VALUES (6,2,'um chocolate Snickers');
INSERT
INTO
t2
VALUES
(
7
,
1
,
'Bife'
);
INSERT
INTO
t2
VALUES
(
8
,
1
,
'Pizza de Salmao'
);
SELECT
t1
.
q
,
t2
.
item
,
t2
.
id
,
MATCH
t2
.
item
AGAINST
(
'sushi'
)
as
x
FROM
t1
,
t2
WHERE
(
t2
.
id2
=
t1
.
id
)
ORDER
BY
x
DESC
,
t2
.
id
;
SELECT
t1
.
q
,
t2
.
item
,
t2
.
id
,
MATCH
t2
.
item
AGAINST
(
'sushi'
)
as
x
FROM
t1
,
t2
WHERE
(
t2
.
id2
=
t1
.
id
)
ORDER
BY
x
DESC
,
t2
.
id
;
SELECT
t1
.
q
,
t2
.
item
,
t2
.
id
,
MATCH
t2
.
item
AGAINST
(
'sushi'
)
as
x
FROM
t2
,
t1
WHERE
(
t2
.
id2
=
t1
.
id
)
ORDER
BY
x
DESC
,
t2
.
id
;
SELECT
t1
.
q
,
t2
.
item
,
t2
.
id
,
MATCH
t2
.
item
AGAINST
(
'sushi'
IN
BOOLEAN
MODE
)
as
x
FROM
t1
,
t2
WHERE
(
t2
.
id2
=
t1
.
id
)
ORDER
BY
x
DESC
,
t2
.
id
;
SELECT
t1
.
q
,
t2
.
item
,
t2
.
id
,
MATCH
t2
.
item
AGAINST
(
'sushi'
)
as
x
FROM
t2
,
t1
WHERE
(
t2
.
id2
=
t1
.
id
)
ORDER
BY
x
DESC
,
t2
.
id
;
SELECT
t1
.
q
,
t2
.
item
,
t2
.
id
,
MATCH
t2
.
item
AGAINST
(
'sushi'
IN
BOOLEAN
MODE
)
as
x
FROM
t2
,
t1
WHERE
(
t2
.
id2
=
t1
.
id
)
ORDER
BY
x
DESC
,
t2
.
id
;
drop
table
t1
,
t2
;
mysys/queues.c
View file @
e3849552
...
...
@@ -124,7 +124,6 @@ byte *queue_remove(register QUEUE *queue, uint idx)
}
}
/* Fix when element on top has been replaced */
#ifndef queue_replaced
...
...
@@ -166,3 +165,19 @@ void _downheap(register QUEUE *queue, uint idx)
}
queue
->
root
[
idx
]
=
element
;
}
static
int
queue_fix_cmp
(
QUEUE
*
queue
,
void
*
a
,
void
*
b
)
{
return
queue
->
compare
(
queue
->
first_cmp_arg
,
a
+
queue
->
offset_to_key
,
b
+
queue
->
offset_to_key
);
}
/* Fix heap when every element was changed */
void
queue_fix
(
QUEUE
*
queue
)
{
qsort2
(
queue
->
root
+
1
,
queue
->
elements
,
sizeof
(
void
*
),
(
qsort2_cmp
)
queue_fix_cmp
,
queue
);
}
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