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
aaa86cd5
Commit
aaa86cd5
authored
Jun 07, 2024
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mhnsw: build indexes with the columns of exactly right size
parent
daabc81a
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
33 additions
and
20 deletions
+33
-20
include/maria.h
include/maria.h
+1
-1
include/myisam.h
include/myisam.h
+1
-1
sql/handler.cc
sql/handler.cc
+10
-4
sql/sql_base.cc
sql/sql_base.cc
+2
-1
sql/vector_mhnsw.cc
sql/vector_mhnsw.cc
+14
-9
sql/vector_mhnsw.h
sql/vector_mhnsw.h
+1
-2
storage/maria/ha_maria.cc
storage/maria/ha_maria.cc
+1
-0
storage/maria/ma_create.c
storage/maria/ma_create.c
+1
-1
storage/myisam/ha_myisam.cc
storage/myisam/ha_myisam.cc
+1
-0
storage/myisam/mi_create.c
storage/myisam/mi_create.c
+1
-1
No files found.
include/maria.h
View file @
aaa86cd5
...
...
@@ -134,7 +134,7 @@ typedef struct st_maria_create_info
ulong
s3_block_size
;
/* Size of null bitmap at start of row */
uint
null_bytes
;
uint
old_options
;
uint
old_options
,
rec_reflength
;
uint
compression_algorithm
;
enum
data_file_type
org_data_file_type
;
uint16
language
;
...
...
include/myisam.h
View file @
aaa86cd5
...
...
@@ -154,7 +154,7 @@ typedef struct st_mi_create_info
ulonglong
auto_increment
;
ulonglong
data_file_length
;
ulonglong
key_file_length
;
uint
old_options
;
uint
old_options
,
rec_reflength
;
uint16
language
;
my_bool
with_auto_increment
;
}
MI_CREATE_INFO
;
...
...
sql/handler.cc
View file @
aaa86cd5
...
...
@@ -6320,7 +6320,8 @@ int handler::calculate_checksum()
****************************************************************************/
static
int
ha_create_table_from_share
(
THD
*
thd
,
TABLE_SHARE
*
share
,
HA_CREATE_INFO
*
create_info
)
HA_CREATE_INFO
*
create_info
,
uint
*
ref_length
)
{
TABLE
table
;
bool
is_tmp
__attribute__
((
unused
))
=
...
...
@@ -6346,6 +6347,7 @@ static int ha_create_table_from_share(THD *thd, TABLE_SHARE *share,
PSI_CALL_drop_table_share
(
is_tmp
,
share
->
db
.
str
,
(
uint
)
share
->
db
.
length
,
share
->
table_name
.
str
,
(
uint
)
share
->
table_name
.
length
);
}
*
ref_length
=
table
.
file
->
ref_length
;
// for hlindexes
(
void
)
closefrm
(
&
table
);
return
error
;
...
...
@@ -6372,6 +6374,7 @@ int ha_create_table(THD *thd, const char *path, const char *db,
LEX_CUSTRING
*
frm
,
bool
skip_frm_file
)
{
int
error
=
1
;
uint
ref_length
;
TABLE_SHARE
share
;
Abort_on_warning_instant_set
old_abort_on_warning
(
thd
,
0
);
DBUG_ENTER
(
"ha_create_table"
);
...
...
@@ -6399,7 +6402,7 @@ int ha_create_table(THD *thd, const char *path, const char *db,
goto
err
;
}
if
((
error
=
ha_create_table_from_share
(
thd
,
&
share
,
create_info
)))
if
((
error
=
ha_create_table_from_share
(
thd
,
&
share
,
create_info
,
&
ref_length
)))
goto
err
;
/* create secondary tables for high level indexes */
...
...
@@ -6421,11 +6424,14 @@ int ha_create_table(THD *thd, const char *path, const char *db,
my_snprintf
(
path_end
,
HLINDEX_BUF_LEN
,
HLINDEX_TEMPLATE
,
i
);
init_tmp_table_share
(
thd
,
&
index_share
,
db
,
0
,
table_name
,
file_name
,
1
);
index_share
.
db_plugin
=
share
.
db_plugin
;
LEX_CSTRING
sql
=
mhnsw_hlindex_table_def
(
thd
,
ref_length
);
if
((
error
=
index_share
.
init_from_sql_statement_string
(
thd
,
false
,
mhnsw_hlindex_table
.
str
,
mhnsw_hlindex_table
.
length
)))
sql
.
str
,
sql
.
length
)))
break
;
if
((
error
=
ha_create_table_from_share
(
thd
,
&
index_share
,
&
index_cinfo
)))
uint
unused
;
if
((
error
=
ha_create_table_from_share
(
thd
,
&
index_share
,
&
index_cinfo
,
&
unused
)))
break
;
}
free_table_share
(
&
index_share
);
...
...
sql/sql_base.cc
View file @
aaa86cd5
...
...
@@ -9853,8 +9853,9 @@ int TABLE::hlindex_open(uint nr)
path
,
false
);
share
->
db_plugin
=
s
->
db_plugin
;
LEX_CSTRING
sql
=
mhnsw_hlindex_table_def
(
in_use
,
file
->
ref_length
);
if
(
share
->
init_from_sql_statement_string
(
in_use
,
false
,
mhnsw_hlindex_table
.
str
,
mhnsw_hlindex_table
.
length
))
sql
.
str
,
sql
.
length
))
{
free_table_share
(
share
);
return
1
;
...
...
sql/vector_mhnsw.cc
View file @
aaa86cd5
...
...
@@ -21,15 +21,6 @@
#include "key.h"
#include <scope.h>
const
LEX_CSTRING
mhnsw_hlindex_table
=
{
STRING_WITH_LEN
(
"\
CREATE TABLE i ( \
layer int not null, \
src varbinary(255) not null, \
neighbors blob not null, \
index (layer, src)) \
"
)};
class
MHNSW_Context
;
class
FVector
:
public
Sql_alloc
...
...
@@ -614,3 +605,17 @@ int mhnsw_next(TABLE *table)
}
return
HA_ERR_END_OF_FILE
;
}
const
LEX_CSTRING
mhnsw_hlindex_table_def
(
THD
*
thd
,
uint
ref_length
)
{
const
char
templ
[]
=
"CREATE TABLE i ( "
" layer int not null, "
" src varbinary(%u) not null, "
" neighbors varbinary(%u) not null,"
" index (layer, src)) "
;
size_t
len
=
sizeof
(
templ
)
+
32
;
char
*
s
=
thd
->
alloc
(
len
);
len
=
my_snprintf
(
s
,
len
,
templ
,
ref_length
,
2
*
ref_length
*
thd
->
variables
.
hnsw_max_connection_per_layer
);
return
{
s
,
len
};
}
sql/vector_mhnsw.h
View file @
aaa86cd5
...
...
@@ -21,8 +21,7 @@
#include "structs.h"
#include "table.h"
extern
const
LEX_CSTRING
mhnsw_hlindex_table
;
const
LEX_CSTRING
mhnsw_hlindex_table_def
(
THD
*
thd
,
uint
ref_length
);
int
mhnsw_insert
(
TABLE
*
table
,
KEY
*
keyinfo
);
int
mhnsw_first
(
TABLE
*
table
,
KEY
*
keyinfo
,
Item
*
dist
,
ulonglong
limit
);
int
mhnsw_next
(
TABLE
*
table
);
storage/maria/ha_maria.cc
View file @
aaa86cd5
...
...
@@ -3411,6 +3411,7 @@ int ha_maria::create(const char *name, TABLE *table_arg,
&
create_info
,
create_flags
);
my_free
(
recinfo
);
ref_length
=
create_info
.
rec_reflength
;
DBUG_RETURN
(
error
);
}
...
...
storage/maria/ma_create.c
View file @
aaa86cd5
...
...
@@ -745,7 +745,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
share
.
state
.
sortkey
=
(
ushort
)
~
0
;
share
.
state
.
auto_increment
=
ci
->
auto_increment
;
share
.
options
=
options
;
share
.
base
.
rec_reflength
=
pointer
;
share
.
base
.
rec_reflength
=
ci
->
rec_reflength
=
pointer
;
share
.
base
.
block_size
=
maria_block_size
;
share
.
base
.
language
=
(
ci
->
language
?
ci
->
language
:
default_charset_info
->
number
);
...
...
storage/myisam/ha_myisam.cc
View file @
aaa86cd5
...
...
@@ -2304,6 +2304,7 @@ int ha_myisam::create(const char *name, TABLE *table_arg,
record_count
,
recinfo
,
0
,
(
MI_UNIQUEDEF
*
)
0
,
&
create_info
,
create_flags
);
ref_length
=
create_info
.
rec_reflength
;
my_free
(
recinfo
);
DBUG_RETURN
(
error
);
}
...
...
storage/myisam/mi_create.c
View file @
aaa86cd5
...
...
@@ -528,7 +528,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
share
.
state
.
sortkey
=
(
ushort
)
~
0
;
share
.
state
.
auto_increment
=
ci
->
auto_increment
;
share
.
options
=
options
;
share
.
base
.
rec_reflength
=
pointer
;
share
.
base
.
rec_reflength
=
ci
->
rec_reflength
=
pointer
;
/* Get estimate for index file length (this may be wrong for FT keys) */
tmp
=
(
tot_length
+
max_key_block_length
*
keys
*
MI_INDEX_BLOCK_MARGIN
)
/
MI_MIN_KEY_BLOCK_LENGTH
;
...
...
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