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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
5a9a3e91
Commit
5a9a3e91
authored
Sep 25, 2001
by
serg@serg.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get rid of ft_search. Now there're two sets of ft_ functions, ft_nlq_* and ft_boolean_*
parent
57e4c8ef
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
91 additions
and
113 deletions
+91
-113
include/ft_global.h
include/ft_global.h
+6
-6
myisam/Makefile.am
myisam/Makefile.am
+1
-1
myisam/ft_dump.c
myisam/ft_dump.c
+2
-2
myisam/ft_eval.c
myisam/ft_eval.c
+4
-4
myisam/ft_nlq_search.c
myisam/ft_nlq_search.c
+53
-11
myisam/ft_search.c
myisam/ft_search.c
+0
-75
myisam/ft_test1.c
myisam/ft_test1.c
+4
-4
sql/ha_myisam.cc
sql/ha_myisam.cc
+1
-1
sql/ha_myisam.h
sql/ha_myisam.h
+2
-2
sql/handler.h
sql/handler.h
+1
-1
sql/item_func.cc
sql/item_func.cc
+1
-1
sql/item_func.h
sql/item_func.h
+13
-2
sql/item_strfunc.h
sql/item_strfunc.h
+3
-3
No files found.
include/ft_global.h
View file @
5a9a3e91
...
...
@@ -50,12 +50,12 @@ extern uint ft_max_word_len_for_sort;
int
ft_init_stopwords
(
const
char
**
);
void
ft_free_stopwords
(
void
);
FT_DOCLIST
*
ft_init_search
(
void
*
,
uint
,
byte
*
,
uint
,
my_bool
);
int
ft_read_next
(
FT_DOCLIST
*
,
char
*
);
#define ft_close_search(handler) my_free(((gptr)(handler)),MYF(0))
#define ft_get_relevance(handler) (((FT_DOCLIST *)(handler))->doc[((FT_DOCLIST *)(handler))->curdoc].weight)
#define ft_get_docid(handler) (((FT_DOCLIST *)(handler))->doc[((FT_DOCLIST *)(handler))->curdoc].dpos)
#define ft_reinit_search(handler) (((FT_DOCLIST *)(handler))->curdoc=-1)
FT_DOCLIST
*
ft_
nlq_
init_search
(
void
*
,
uint
,
byte
*
,
uint
,
my_bool
);
int
ft_
nlq_
read_next
(
FT_DOCLIST
*
,
char
*
);
#define ft_
nlq_
close_search(handler) my_free(((gptr)(handler)),MYF(0))
#define ft_
nlq_
get_relevance(handler) (((FT_DOCLIST *)(handler))->doc[((FT_DOCLIST *)(handler))->curdoc].weight)
#define ft_
nlq_
get_docid(handler) (((FT_DOCLIST *)(handler))->doc[((FT_DOCLIST *)(handler))->curdoc].dpos)
#define ft_
nlq_
reinit_search(handler) (((FT_DOCLIST *)(handler))->curdoc=-1)
#ifdef __cplusplus
}
...
...
myisam/Makefile.am
View file @
5a9a3e91
...
...
@@ -45,7 +45,7 @@ libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
mi_range.c mi_dbug.c mi_checksum.c mi_log.c
\
mi_changed.c mi_static.c mi_delete_all.c
\
mi_delete_table.c mi_rename.c mi_check.c
\
ft_parser.c ft_s
earch.c ft_s
topwords.c ft_static.c
\
ft_parser.c ft_stopwords.c ft_static.c
\
ft_update.c ft_boolean_search.c ft_nlq_search.c sort.c
CLEANFILES
=
test
?.MY? FT?.MY? isam.log mi_test_all
DEFS
=
-DMAP_TO_USE_RAID
...
...
myisam/ft_dump.c
View file @
5a9a3e91
...
...
@@ -77,7 +77,7 @@ int main(int argc,char *argv[])
ft_init_stopwords
(
ft_precompiled_stopwords
);
result
=
ft_init_search
(
info
,
inx
,
query
,
strlen
(
query
),
1
);
result
=
ft_
nlq_
init_search
(
info
,
inx
,
query
,
strlen
(
query
),
1
);
if
(
!
result
)
goto
err
;
...
...
@@ -87,7 +87,7 @@ int main(int argc,char *argv[])
for
(
i
=
0
;
i
<
result
->
ndocs
;
i
++
)
printf
(
"%9qx %20.7f
\n
"
,
result
->
doc
[
i
].
dpos
,
result
->
doc
[
i
].
weight
);
ft_close_search
(
result
);
ft_
nlq_
close_search
(
result
);
}
else
{
...
...
myisam/ft_eval.c
View file @
5a9a3e91
...
...
@@ -83,23 +83,23 @@ int main(int argc,char *argv[])
for
(
i
=
1
;
create_record
(
record
,
qf
);
i
++
)
{
FT_DOCLIST
*
result
;
double
w
;
int
t
,
err
;
result
=
ft_init_search
(
file
,
0
,
blob_record
,(
uint
)
strlen
(
blob_record
),
1
);
result
=
ft_
nlq_
init_search
(
file
,
0
,
blob_record
,(
uint
)
strlen
(
blob_record
),
1
);
if
(
!
result
)
{
printf
(
"Query %d failed with errno %3d
\n
"
,
i
,
my_errno
);
goto
err
;
}
if
(
!
silent
)
printf
(
"Query %d. Found: %d.
\n
"
,
i
,
result
->
ndocs
);
for
(
j
=
0
;(
err
=
ft_read_next
(
result
,
read_record
))
==
0
;
j
++
)
{
for
(
j
=
0
;(
err
=
ft_
nlq_
read_next
(
result
,
read_record
))
==
0
;
j
++
)
{
t
=
uint2korr
(
read_record
);
w
=
ft_get_relevance
(
result
);
w
=
ft_
nlq_
get_relevance
(
result
);
printf
(
"%d %.*s %f
\n
"
,
i
,
t
,
read_record
+
2
,
w
);
}
if
(
err
!=
HA_ERR_END_OF_FILE
)
{
printf
(
"ft_read_next %d failed with errno %3d
\n
"
,
j
,
my_errno
);
goto
err
;
}
ft_close_search
(
result
);
ft_
nlq_
close_search
(
result
);
}
if
(
mi_close
(
file
))
goto
err
;
...
...
myisam/ft_nlq_search.c
View file @
5a9a3e91
...
...
@@ -147,15 +147,28 @@ static int walk_and_copy(FT_SUPERDOC *from,
return
0
;
}
FT_DOCLIST
*
ft_nlq_search
(
MI_INFO
*
info
,
uint
keynr
,
byte
*
query
,
uint
query_len
)
static
int
FT_DOC_cmp
(
FT_DOC
*
a
,
FT_DOC
*
b
)
{
return
sgn
(
b
->
weight
-
a
->
weight
);
}
FT_DOCLIST
*
ft_nlq_init_search
(
void
*
info
,
uint
keynr
,
byte
*
query
,
uint
query_len
,
my_bool
presort
)
{
TREE
*
wtree
,
allocated_wtree
;
ALL_IN_ONE
aio
;
ALL_IN_ONE
aio
;
FT_DOC
*
dptr
;
FT_DOCLIST
*
dlist
=
NULL
;
my_off_t
saved_lastpos
=
((
MI_INFO
*
)
info
)
->
lastpos
;
aio
.
info
=
info
;
/* black magic ON */
if
((
int
)
(
keynr
=
_mi_check_index
((
MI_INFO
*
)
info
,
keynr
))
<
0
)
return
NULL
;
if
(
_mi_readinfo
((
MI_INFO
*
)
info
,
F_RDLCK
,
1
))
return
NULL
;
/* black magic OFF */
aio
.
info
=
(
MI_INFO
*
)
info
;
aio
.
keynr
=
keynr
;
aio
.
keybuff
=
aio
.
info
->
lastkey
+
aio
.
info
->
s
->
base
.
max_key_length
;
aio
.
keyinfo
=
aio
.
info
->
s
->
keyinfo
+
keynr
;
...
...
@@ -167,26 +180,55 @@ FT_DOCLIST *ft_nlq_search(MI_INFO *info, uint keynr, byte *query,
NULL
,
NULL
);
if
(
!
(
wtree
=
ft_parse
(
&
allocated_wtree
,
query
,
query_len
)))
return
NULL
;
goto
err
;
if
(
tree_walk
(
wtree
,
(
tree_walk_action
)
&
walk_and_match
,
&
aio
,
left_root_right
))
goto
err
;
left_root_right
))
goto
err
2
;
dlist
=
(
FT_DOCLIST
*
)
my_malloc
(
sizeof
(
FT_DOCLIST
)
+
sizeof
(
FT_DOC
)
*
(
aio
.
dtree
.
elements_in_tree
-
1
),
MYF
(
0
));
dlist
=
(
FT_DOCLIST
*
)
my_malloc
(
sizeof
(
FT_DOCLIST
)
+
sizeof
(
FT_DOC
)
*
(
aio
.
dtree
.
elements_in_tree
-
1
),
MYF
(
0
));
if
(
!
dlist
)
goto
err
;
goto
err
2
;
dlist
->
ndocs
=
aio
.
dtree
.
elements_in_tree
;
dlist
->
curdoc
=-
1
;
dlist
->
info
=
aio
.
info
;
dptr
=
dlist
->
doc
;
tree_walk
(
&
aio
.
dtree
,
(
tree_walk_action
)
&
walk_and_copy
,
&
dptr
,
left_root_right
);
tree_walk
(
&
aio
.
dtree
,
(
tree_walk_action
)
&
walk_and_copy
,
&
dptr
,
left_root_right
);
err:
if
(
presort
)
qsort
(
dlist
->
doc
,
dlist
->
ndocs
,
sizeof
(
FT_DOC
),
(
qsort_cmp
)
&
FT_DOC_cmp
);
err2:
delete_tree
(
wtree
);
delete_tree
(
&
aio
.
dtree
);
err:
((
MI_INFO
*
)
info
)
->
lastpos
=
saved_lastpos
;
return
dlist
;
}
int
ft_nlq_read_next
(
FT_DOCLIST
*
handler
,
char
*
record
)
{
MI_INFO
*
info
=
(
MI_INFO
*
)
handler
->
info
;
if
(
++
handler
->
curdoc
>=
handler
->
ndocs
)
{
--
handler
->
curdoc
;
return
HA_ERR_END_OF_FILE
;
}
info
->
update
&=
(
HA_STATE_CHANGED
|
HA_STATE_ROW_CHANGED
);
info
->
lastpos
=
handler
->
doc
[
handler
->
curdoc
].
dpos
;
if
(
!
(
*
info
->
read_record
)(
info
,
info
->
lastpos
,
record
))
{
info
->
update
|=
HA_STATE_AKTIV
;
/* Record is read */
return
0
;
}
return
my_errno
;
}
myisam/ft_search.c
deleted
100644 → 0
View file @
57e4c8ef
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Written by Sergei A. Golubchik, who has a shared copyright to this code */
#include "ftdefs.h"
/* queries myisam and returns list of documents matched */
static
int
FT_DOC_cmp
(
FT_DOC
*
a
,
FT_DOC
*
b
)
{
return
sgn
(
b
->
weight
-
a
->
weight
);
}
FT_DOCLIST
*
ft_init_search
(
void
*
info
,
uint
keynr
,
byte
*
query
,
uint
query_len
,
my_bool
presort
)
{
FT_DOCLIST
*
dlist
;
my_off_t
saved_lastpos
=
((
MI_INFO
*
)
info
)
->
lastpos
;
/* black magic ON */
if
((
int
)
(
keynr
=
_mi_check_index
((
MI_INFO
*
)
info
,
keynr
))
<
0
)
return
NULL
;
if
(
_mi_readinfo
((
MI_INFO
*
)
info
,
F_RDLCK
,
1
))
return
NULL
;
/* black magic OFF */
// if (is_boolean(query, query_len))
// dlist=ft_boolean_search(info,keynr,query,query_len);
// else
dlist
=
ft_nlq_search
(
info
,
keynr
,
query
,
query_len
);
if
(
dlist
&&
presort
)
{
qsort
(
dlist
->
doc
,
dlist
->
ndocs
,
sizeof
(
FT_DOC
),
(
qsort_cmp
)
&
FT_DOC_cmp
);
}
((
MI_INFO
*
)
info
)
->
lastpos
=
saved_lastpos
;
return
dlist
;
}
int
ft_read_next
(
FT_DOCLIST
*
handler
,
char
*
record
)
{
MI_INFO
*
info
=
(
MI_INFO
*
)
handler
->
info
;
if
(
++
handler
->
curdoc
>=
handler
->
ndocs
)
{
--
handler
->
curdoc
;
return
HA_ERR_END_OF_FILE
;
}
info
->
update
&=
(
HA_STATE_CHANGED
|
HA_STATE_ROW_CHANGED
);
info
->
lastpos
=
handler
->
doc
[
handler
->
curdoc
].
dpos
;
if
(
!
(
*
info
->
read_record
)(
info
,
info
->
lastpos
,
record
))
{
info
->
update
|=
HA_STATE_AKTIV
;
/* Record is read */
return
0
;
}
return
my_errno
;
}
myisam/ft_test1.c
View file @
5a9a3e91
...
...
@@ -137,7 +137,7 @@ static int run_test(const char *filename)
printf
(
"- Reading rows with key
\n
"
);
for
(
i
=
0
;
i
<
NQUERIES
;
i
++
)
{
FT_DOCLIST
*
result
;
result
=
ft_init_search
(
file
,
0
,(
char
*
)
query
[
i
],
strlen
(
query
[
i
]),
1
);
result
=
ft_
nlq_
init_search
(
file
,
0
,(
char
*
)
query
[
i
],
strlen
(
query
[
i
]),
1
);
if
(
!
result
)
{
printf
(
"Query %d: `%s' failed with errno %3d
\n
"
,
i
,
query
[
i
],
my_errno
);
continue
;
...
...
@@ -145,7 +145,7 @@ static int run_test(const char *filename)
printf
(
"Query %d: `%s'. Found: %d. Top five documents:
\n
"
,
i
,
query
[
i
],
result
->
ndocs
);
for
(
j
=
0
;
j
<
5
;
j
++
)
{
double
w
;
int
err
;
err
=
ft_read_next
(
result
,
read_record
);
err
=
ft_
nlq_
read_next
(
result
,
read_record
);
if
(
err
==
HA_ERR_END_OF_FILE
)
{
printf
(
"No more matches!
\n
"
);
break
;
...
...
@@ -153,7 +153,7 @@ static int run_test(const char *filename)
printf
(
"ft_read_next %d failed with errno %3d
\n
"
,
j
,
my_errno
);
break
;
}
w
=
ft_get_relevance
(
result
);
w
=
ft_
nlq_
get_relevance
(
result
);
if
(
key_field
==
FIELD_VARCHAR
)
{
uint
l
;
char
*
p
;
...
...
@@ -164,7 +164,7 @@ static int run_test(const char *filename)
printf
(
"%10.7f: %.*s
\n
"
,
w
,
recinfo
[
1
].
length
,
recinfo
[
0
].
length
+
read_record
);
}
ft_close_search
(
result
);
ft_
nlq_
close_search
(
result
);
}
if
(
mi_close
(
file
))
goto
err
;
...
...
sql/ha_myisam.cc
View file @
5a9a3e91
...
...
@@ -1197,7 +1197,7 @@ int ha_myisam::ft_read(byte * buf)
thread_safe_increment
(
ha_read_next_count
,
&
LOCK_status
);
// why ?
error
=
ft_read_next
((
FT_DOCLIST
*
)
ft_handler
,(
char
*
)
buf
);
error
=
ft_
nlq_
read_next
((
FT_DOCLIST
*
)
ft_handler
,(
char
*
)
buf
);
table
->
status
=
error
?
STATUS_NOT_FOUND
:
0
;
return
error
;
...
...
sql/ha_myisam.h
View file @
5a9a3e91
...
...
@@ -76,9 +76,9 @@ class ha_myisam: public handler
int
index_next_same
(
byte
*
buf
,
const
byte
*
key
,
uint
keylen
);
int
index_end
()
{
ft_handler
=
NULL
;
return
0
;
}
int
ft_init
()
{
if
(
!
ft_handler
)
return
1
;
ft_reinit_search
(
ft_handler
);
return
0
;
}
{
if
(
!
ft_handler
)
return
1
;
ft_
nlq_
reinit_search
(
ft_handler
);
return
0
;
}
void
*
ft_init_ext
(
uint
inx
,
const
byte
*
key
,
uint
keylen
,
bool
presort
)
{
return
ft_init_search
(
file
,
inx
,(
byte
*
)
key
,
keylen
,
presort
);
}
{
return
ft_
nlq_
init_search
(
file
,
inx
,(
byte
*
)
key
,
keylen
,
presort
);
}
int
ft_read
(
byte
*
buf
);
int
rnd_init
(
bool
scan
=
1
);
int
rnd_next
(
byte
*
buf
);
...
...
sql/handler.h
View file @
5a9a3e91
...
...
@@ -237,7 +237,7 @@ class handler :public Sql_alloc
virtual
int
update_row
(
const
byte
*
old_data
,
byte
*
new_data
)
=
0
;
virtual
int
delete_row
(
const
byte
*
buf
)
=
0
;
virtual
int
index_read
(
byte
*
buf
,
const
byte
*
key
,
uint
key_len
,
enum
ha_rkey_function
find_flag
)
=
0
;
uint
key_len
,
enum
ha_rkey_function
find_flag
)
=
0
;
virtual
int
index_read_idx
(
byte
*
buf
,
uint
index
,
const
byte
*
key
,
uint
key_len
,
enum
ha_rkey_function
find_flag
)
=
0
;
virtual
int
index_next
(
byte
*
buf
)
=
0
;
...
...
sql/item_func.cc
View file @
5a9a3e91
...
...
@@ -1914,7 +1914,7 @@ double Item_func_match_nl::val()
if
(
join_key
)
{
if
(
table
->
file
->
ft_handler
)
return
ft_get_relevance
(
ft_handler
);
return
ft_
nlq_
get_relevance
(
ft_handler
);
join_key
=
0
;
// Magic here ! See ha_myisam::ft_read()
}
...
...
sql/item_func.h
View file @
5a9a3e91
...
...
@@ -893,10 +893,21 @@ class Item_func_match_nl :public Item_func_match
{
public:
Item_func_match_nl
(
List
<
Item
>
&
a
,
Item
*
b
)
:
Item_func_match
(
a
,
b
)
{}
const
char
*
func_name
()
const
{
return
"match_NL"
;
}
const
char
*
func_name
()
const
{
return
"match_nl"
;
}
double
val
();
int
ft_handler_init
(
const
byte
*
query
,
uint
querylen
,
bool
presort
)
{
ft_handler
=
table
->
file
->
ft_init_ext
(
key
,
query
,
querylen
,
presort
);
}
int
ft_handler_close
()
{
ft_nlq_close_search
(
ft_handler
);
ft_handler
=
0
;
}
};
#if 0
class Item_func_match_bool :public Item_func_match
{
public:
Item_func_match_nl(List<Item> &a, Item *b): Item_func_match(a,b) {}
const char *func_name() const { return "match_bool"; }
double val();
int ft_handler_init(const byte *query, uint querylen, bool presort)
{ ft_handler=table->file->ft_init_ext(key, query, querylen, presort); }
int ft_handler_close() { ft_close_search(ft_handler); ft_handler=0; }
};
#endif
sql/item_strfunc.h
View file @
5a9a3e91
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
...
...
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