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
30ae6678
Commit
30ae6678
authored
Jan 24, 2014
by
Rich Prohaska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#171 add a field types array to classify types into fixed, variable and blob types
parent
02573a41
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
40 deletions
+45
-40
storage/tokudb/ha_tokudb.cc
storage/tokudb/ha_tokudb.cc
+24
-27
storage/tokudb/ha_tokudb_alter_common.cc
storage/tokudb/ha_tokudb_alter_common.cc
+3
-10
storage/tokudb/hatoku_cmp.cc
storage/tokudb/hatoku_cmp.cc
+2
-2
storage/tokudb/hatoku_cmp.h
storage/tokudb/hatoku_cmp.h
+16
-1
No files found.
storage/tokudb/ha_tokudb.cc
View file @
30ae6678
...
...
@@ -144,7 +144,7 @@ static const char *ha_tokudb_exts[] = {
static
inline
uint32_t
get_fixed_field_size
(
KEY_AND_COL_INFO
*
kc_info
,
TABLE_SHARE
*
table_share
,
uint
keynr
)
{
uint
offset
=
0
;
for
(
uint
i
=
0
;
i
<
table_share
->
fields
;
i
++
)
{
if
(
kc_info
->
field_lengths
[
i
]
&&
!
bitmap_is_set
(
&
kc_info
->
key_filters
[
keynr
],
i
))
{
if
(
is_fixed_field
(
kc_info
,
i
)
&&
!
bitmap_is_set
(
&
kc_info
->
key_filters
[
keynr
],
i
))
{
offset
+=
kc_info
->
field_lengths
[
i
];
}
}
...
...
@@ -155,7 +155,7 @@ static inline uint32_t get_fixed_field_size(KEY_AND_COL_INFO* kc_info, TABLE_SHA
static
inline
uint32_t
get_len_of_offsets
(
KEY_AND_COL_INFO
*
kc_info
,
TABLE_SHARE
*
table_share
,
uint
keynr
)
{
uint
len
=
0
;
for
(
uint
i
=
0
;
i
<
table_share
->
fields
;
i
++
)
{
if
(
kc_info
->
length_bytes
[
i
]
&&
!
bitmap_is_set
(
&
kc_info
->
key_filters
[
keynr
],
i
))
{
if
(
is_variable_field
(
kc_info
,
i
)
&&
!
bitmap_is_set
(
&
kc_info
->
key_filters
[
keynr
],
i
))
{
len
+=
kc_info
->
num_offset_bytes
;
}
}
...
...
@@ -183,13 +183,13 @@ static int allocate_key_and_col_info ( TABLE_SHARE* table_share, KEY_AND_COL_INF
//
// create the field lengths
//
kc_info
->
field_lengths
=
(
uint16_t
*
)
tokudb_my_malloc
(
table_share
->
fields
*
sizeof
(
uint16_t
),
MYF
(
MY_WME
|
MY_ZEROFILL
));
kc_info
->
length_bytes
=
(
uchar
*
)
tokudb_my_malloc
(
table_share
->
fields
,
MYF
(
MY_WME
|
MY_ZEROFILL
));
kc_info
->
blob_fields
=
(
uint32_t
*
)
tokudb_my_malloc
(
table_share
->
fields
*
sizeof
(
uint32_t
),
MYF
(
MY_WME
|
MY_ZEROFILL
));
if
(
kc_info
->
field_lengths
==
NULL
||
kc_info
->
length_bytes
==
NULL
||
kc_info
->
blob_fields
==
NULL
)
{
kc_info
->
multi_ptr
=
tokudb_my_multi_malloc
(
MYF
(
MY_WME
+
MY_ZEROFILL
),
&
kc_info
->
field_types
,
(
uint
)(
table_share
->
fields
*
sizeof
(
uint8_t
)),
&
kc_info
->
field_lengths
,
(
uint
)(
table_share
->
fields
*
sizeof
(
uint16_t
)),
&
kc_info
->
length_bytes
,
(
uint
)(
table_share
->
fields
*
sizeof
(
uint8_t
)),
&
kc_info
->
blob_fields
,
(
uint
)(
table_share
->
fields
*
sizeof
(
uint32_t
)),
NullS
);
if
(
kc_info
->
multi_ptr
==
NULL
)
{
error
=
ENOMEM
;
goto
exit
;
}
...
...
@@ -198,9 +198,7 @@ static int allocate_key_and_col_info ( TABLE_SHARE* table_share, KEY_AND_COL_INF
for
(
uint
i
=
0
;
MAX_KEY
+
1
;
i
++
)
{
bitmap_free
(
&
kc_info
->
key_filters
[
i
]);
}
tokudb_my_free
(
kc_info
->
field_lengths
);
tokudb_my_free
(
kc_info
->
length_bytes
);
tokudb_my_free
(
kc_info
->
blob_fields
);
tokudb_my_free
(
kc_info
->
multi_ptr
);
}
return
error
;
}
...
...
@@ -214,12 +212,11 @@ static void free_key_and_col_info (KEY_AND_COL_INFO* kc_info) {
tokudb_my_free
(
kc_info
->
cp_info
[
i
]);
kc_info
->
cp_info
[
i
]
=
NULL
;
// 3144
}
tokudb_my_free
(
kc_info
->
field_lengths
);
tokudb_my_free
(
kc_info
->
multi_ptr
);
kc_info
->
field_types
=
NULL
;
kc_info
->
field_lengths
=
NULL
;
tokudb_my_free
(
kc_info
->
length_bytes
);
kc_info
->
length_bytes
=
NULL
;
tokudb_my_free
(
kc_info
->
blob_fields
);
kc_info
->
blob_fields
=
NULL
;
}
...
...
@@ -1414,11 +1411,11 @@ static int initialize_col_pack_info(KEY_AND_COL_INFO* kc_info, TABLE_SHARE* tabl
// offsets are calculated AFTER the NULL bytes
//
if
(
!
bitmap_is_set
(
&
kc_info
->
key_filters
[
keynr
],
j
))
{
if
(
kc_info
->
field_lengths
[
j
]
)
{
if
(
is_fixed_field
(
kc_info
,
j
)
)
{
curr
->
col_pack_val
=
curr_fixed_offset
;
curr_fixed_offset
+=
kc_info
->
field_lengths
[
j
];
}
else
if
(
kc_info
->
length_bytes
[
j
]
)
{
else
if
(
is_variable_field
(
kc_info
,
j
)
)
{
curr
->
col_pack_val
=
curr_var_index
;
curr_var_index
++
;
}
...
...
@@ -1473,10 +1470,12 @@ static int initialize_key_and_col_info(TABLE_SHARE* table_share, TABLE* table, K
case
toku_type_fixstring
:
pack_length
=
field
->
pack_length
();
assert
(
pack_length
<
1
<<
16
);
kc_info
->
field_types
[
i
]
=
KEY_AND_COL_INFO
::
TOKUDB_FIXED_FIELD
;
kc_info
->
field_lengths
[
i
]
=
(
uint16_t
)
pack_length
;
kc_info
->
length_bytes
[
i
]
=
0
;
break
;
case
toku_type_blob
:
kc_info
->
field_types
[
i
]
=
KEY_AND_COL_INFO
::
TOKUDB_BLOB_FIELD
;
kc_info
->
field_lengths
[
i
]
=
0
;
kc_info
->
length_bytes
[
i
]
=
0
;
kc_info
->
blob_fields
[
curr_blob_field_index
]
=
i
;
...
...
@@ -1484,9 +1483,7 @@ static int initialize_key_and_col_info(TABLE_SHARE* table_share, TABLE* table, K
break
;
case
toku_type_varstring
:
case
toku_type_varbinary
:
//
// meaning it is variable sized
//
kc_info
->
field_types
[
i
]
=
KEY_AND_COL_INFO
::
TOKUDB_VARIABLE_FIELD
;
kc_info
->
field_lengths
[
i
]
=
0
;
kc_info
->
length_bytes
[
i
]
=
(
uchar
)((
Field_varstring
*
)
field
)
->
length_bytes
;
max_var_bytes
+=
field
->
field_length
;
...
...
@@ -2256,14 +2253,14 @@ int ha_tokudb::pack_row_in_buff(
if
(
bitmap_is_set
(
&
share
->
kc_info
.
key_filters
[
index
],
i
))
{
continue
;
}
if
(
share
->
kc_info
.
field_lengths
[
i
]
)
{
if
(
is_fixed_field
(
&
share
->
kc_info
,
i
)
)
{
fixed_field_ptr
=
pack_fixed_field
(
fixed_field_ptr
,
record
+
curr_field_offset
,
share
->
kc_info
.
field_lengths
[
i
]
);
}
else
if
(
share
->
kc_info
.
length_bytes
[
i
]
)
{
else
if
(
is_variable_field
(
&
share
->
kc_info
,
i
)
)
{
var_field_data_ptr
=
pack_var_field
(
var_field_offset_ptr
,
var_field_data_ptr
,
...
...
@@ -2423,7 +2420,7 @@ int ha_tokudb::unpack_row(
continue
;
}
if
(
share
->
kc_info
.
field_lengths
[
i
]
)
{
if
(
is_fixed_field
(
&
share
->
kc_info
,
i
)
)
{
fixed_field_ptr
=
unpack_fixed_field
(
record
+
field_offset
(
field
,
table
),
fixed_field_ptr
,
...
...
@@ -2434,7 +2431,7 @@ int ha_tokudb::unpack_row(
// here, we DO modify var_field_data_ptr or var_field_offset_ptr
// as we unpack variable sized fields
//
else
if
(
share
->
kc_info
.
length_bytes
[
i
]
)
{
else
if
(
is_variable_field
(
&
share
->
kc_info
,
i
)
)
{
switch
(
share
->
kc_info
.
num_offset_bytes
)
{
case
(
1
):
data_end_offset
=
var_field_offset_ptr
[
0
];
...
...
@@ -4327,7 +4324,7 @@ void ha_tokudb::set_query_columns(uint keynr) {
//
// if fixed field length
//
if
(
share
->
kc_info
.
field_lengths
[
i
]
!=
0
)
{
if
(
is_fixed_field
(
&
share
->
kc_info
,
i
)
)
{
//
// save the offset into the list
//
...
...
@@ -4337,7 +4334,7 @@ void ha_tokudb::set_query_columns(uint keynr) {
//
// varchar or varbinary
//
else
if
(
share
->
kc_info
.
length_bytes
[
i
]
!=
0
)
{
else
if
(
is_variable_field
(
&
share
->
kc_info
,
i
)
)
{
var_cols_for_query
[
curr_var_col_index
]
=
i
;
curr_var_col_index
++
;
}
...
...
storage/tokudb/ha_tokudb_alter_common.cc
View file @
30ae6678
...
...
@@ -423,7 +423,7 @@ static uint32_t fill_dynamic_row_mutator(
pos
++
;
}
}
if
(
src_kc_info
->
field_lengths
[
curr_index
]
!=
0
)
{
if
(
is_fixed_field
(
src_kc_info
,
curr_index
)
)
{
// we have a fixed field being dropped
// store the offset and the number of bytes
pos
[
0
]
=
COL_FIXED
;
...
...
@@ -446,7 +446,7 @@ static uint32_t fill_dynamic_row_mutator(
pos
+=
num_bytes
;
}
}
else
if
(
src_kc_info
->
length_bytes
[
curr_index
]
!=
0
)
{
else
if
(
is_variable_field
(
src_kc_info
,
curr_index
)
)
{
pos
[
0
]
=
COL_VAR
;
pos
++
;
//store the index of the variable column
...
...
@@ -516,10 +516,7 @@ static uint32_t fill_dynamic_blob_row_mutator(
for
(
uint32_t
i
=
0
;
i
<
num_columns
;
i
++
)
{
uint32_t
curr_field_index
=
columns
[
i
];
Field
*
curr_field
=
src_table
->
field
[
curr_field_index
];
if
(
src_kc_info
->
field_lengths
[
curr_field_index
]
==
0
&&
src_kc_info
->
length_bytes
[
curr_field_index
]
==
0
)
{
if
(
is_blob_field
(
src_kc_info
,
curr_field_index
))
{
// find out which blob it is
uint32_t
blob_index
=
src_kc_info
->
num_blobs
;
for
(
uint32_t
j
=
0
;
j
<
src_kc_info
->
num_blobs
;
j
++
)
{
...
...
@@ -547,10 +544,6 @@ static uint32_t fill_dynamic_blob_row_mutator(
pos
+=
len_bytes
;
}
}
else
{
// not a blob, continue
continue
;
}
}
return
pos
-
buf
;
}
...
...
storage/tokudb/hatoku_cmp.cc
View file @
30ae6678
...
...
@@ -2227,7 +2227,7 @@ static uint32_t create_toku_clustering_val_pack_descriptor (
last_col
=
0
;
for
(
uint
i
=
0
;
i
<
table_share
->
fields
;
i
++
)
{
bool
col_filtered
=
bitmap_is_set
(
&
kc_info
->
key_filters
[
keynr
],
i
);
if
(
kc_info
->
field_lengths
[
i
]
==
0
)
{
if
(
!
is_fixed_field
(
kc_info
,
i
)
)
{
//
// not a fixed field, continue
//
...
...
@@ -2274,7 +2274,7 @@ static uint32_t create_toku_clustering_val_pack_descriptor (
last_col
=
0
;
for
(
uint
i
=
0
;
i
<
table_share
->
fields
;
i
++
)
{
bool
col_filtered
=
bitmap_is_set
(
&
kc_info
->
key_filters
[
keynr
],
i
);
if
(
kc_info
->
length_bytes
[
i
]
==
0
)
{
if
(
!
is_variable_field
(
kc_info
,
i
)
)
{
//
// not a var field, continue
//
...
...
storage/tokudb/hatoku_cmp.h
View file @
30ae6678
...
...
@@ -180,8 +180,11 @@ typedef struct st_key_and_col_info {
// length_bytes[i] is 0
// 'i' shows up in blob_fields
//
void
*
multi_ptr
;
enum
{
TOKUDB_FIXED_FIELD
,
TOKUDB_VARIABLE_FIELD
,
TOKUDB_BLOB_FIELD
};
uint8_t
*
field_types
;
uint16_t
*
field_lengths
;
//stores the field lengths of fixed size fields (1<<16 - 1 max),
u
char
*
length_bytes
;
// stores the length of lengths of varchars and varbinaries
u
int8_t
*
length_bytes
;
// stores the length of lengths of varchars and varbinaries
uint32_t
*
blob_fields
;
// list of indexes of blob fields,
uint32_t
num_blobs
;
// number of blobs in the table
//
...
...
@@ -197,6 +200,18 @@ typedef struct st_key_and_col_info {
uint32_t
num_offset_bytes
;
//number of bytes needed to encode the offset
}
KEY_AND_COL_INFO
;
static
bool
is_fixed_field
(
KEY_AND_COL_INFO
*
kcinfo
,
uint
field_num
)
{
return
kcinfo
->
field_types
[
field_num
]
==
KEY_AND_COL_INFO
::
TOKUDB_FIXED_FIELD
;
}
static
bool
is_variable_field
(
KEY_AND_COL_INFO
*
kcinfo
,
uint
field_num
)
{
return
kcinfo
->
field_types
[
field_num
]
==
KEY_AND_COL_INFO
::
TOKUDB_VARIABLE_FIELD
;
}
static
bool
is_blob_field
(
KEY_AND_COL_INFO
*
kcinfo
,
uint
field_num
)
{
return
kcinfo
->
field_types
[
field_num
]
==
KEY_AND_COL_INFO
::
TOKUDB_BLOB_FIELD
;
}
static
bool
field_valid_for_tokudb_table
(
Field
*
field
);
static
void
get_var_field_info
(
...
...
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