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
67546a26
Commit
67546a26
authored
Nov 24, 2020
by
Varun Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trying setup for fixed size descriptors
parent
5876acb3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
14 deletions
+55
-14
sql/filesort.cc
sql/filesort.cc
+20
-4
sql/sql_class.h
sql/sql_class.h
+2
-0
sql/sql_statistics.cc
sql/sql_statistics.cc
+11
-8
sql/uniques.cc
sql/uniques.cc
+20
-0
sql/uniques.h
sql/uniques.h
+2
-2
No files found.
sql/filesort.cc
View file @
67546a26
...
...
@@ -2834,12 +2834,28 @@ void SORT_FIELD::setup(Item *item_arg, bool with_suffix)
}
void
SORT_FIELD
::
setup_for_fixed_size_keys
(
Field
*
fld
)
{
field
=
fld
;
item
=
NULL
;
reverse
=
false
;
SORT_FIELD_ATTR
::
setup_for_fixed_size_keys
(
fld
);
}
void
SORT_FIELD_ATTR
::
setup_for_fixed_size_keys
(
Field
*
field
)
{
original_length
=
length
=
field
->
pack_length
();
cs
=
field
->
charset
();
suffix_length
=
0
;
type
=
SORT_FIELD_ATTR
::
FIXED_SIZE
;
maybe_null
=
field
->
maybe_null
();
length_bytes
=
0
;
}
void
SORT_FIELD_ATTR
::
setup
(
Field
*
fld
,
bool
with_suffix
)
{
/*
For unique needs to be set to FALSE always
but we can even pass the reverse as an argument to the function
*/
original_length
=
length
=
(
with_suffix
?
fld
->
sort_length
()
:
fld
->
sort_length_without_suffix
());
...
...
sql/sql_class.h
View file @
67546a26
...
...
@@ -6448,6 +6448,7 @@ struct SORT_FIELD_ATTR
bool
check_if_packing_possible
(
THD
*
thd
)
const
;
bool
is_variable_sized
()
{
return
type
==
VARIABLE_SIZE
;
}
void
setup
(
Field
*
fld
,
bool
with_suffix
);
void
setup_for_fixed_size_keys
(
Field
*
fld
);
int
compare_nullability
(
uchar
*
a
,
uchar
*
b
);
};
...
...
@@ -6459,6 +6460,7 @@ struct SORT_FIELD: public SORT_FIELD_ATTR
bool
reverse
;
/* if descending sort */
void
setup
(
Field
*
fld
,
bool
with_suffix
);
void
setup
(
Item
*
item
,
bool
with_suffix
);
void
setup_for_fixed_size_keys
(
Field
*
fld
);
};
...
...
sql/sql_statistics.cc
View file @
67546a26
...
...
@@ -1725,7 +1725,7 @@ class Count_distinct_field: public Sql_alloc
desc
=
new
Variable_size_keys_simple
(
tree_key_length
);
if
(
!
desc
)
return
true
;
// OOM
tree
=
new
Unique_impl
((
qsort_cmp2
)
simple_packed_str_
key_cmp
,
tree
=
new
Unique_impl
((
qsort_cmp2
)
key_cmp
,
(
void
*
)
this
,
tree_key_length
,
max_heap_table_size
,
1
,
desc
);
if
(
!
tree
)
...
...
@@ -1734,12 +1734,15 @@ class Count_distinct_field: public Sql_alloc
}
tree_key_length
=
table_field
->
pack_length
();
desc
=
new
Fixed_size_keys_
descriptor
(
tree_key_length
);
desc
=
new
Fixed_size_keys_
simple
(
tree_key_length
);
if
(
!
desc
)
return
true
;
// OOM
tree
=
new
Unique_impl
((
qsort_cmp2
)
simple_str_key_cmp
,
(
void
*
)
table_field
,
tree
=
new
Unique_impl
((
qsort_cmp2
)
key_cmp
,
(
void
*
)
this
,
tree_key_length
,
max_heap_table_size
,
1
,
desc
);
return
tree
==
NULL
;
if
(
!
tree
)
return
true
;
// OOM
return
tree
->
get_descriptor
()
->
setup
(
thd
,
table_field
);
}
...
...
@@ -1816,7 +1819,7 @@ class Count_distinct_field: public Sql_alloc
return
table_field
->
collected_stats
->
histogram
.
get_values
();
}
static
int
simple_packed_str_
key_cmp
(
void
*
arg
,
uchar
*
key1
,
uchar
*
key2
);
static
int
key_cmp
(
void
*
arg
,
uchar
*
key1
,
uchar
*
key2
);
};
/*
...
...
@@ -1832,9 +1835,9 @@ class Count_distinct_field: public Sql_alloc
@retval = 0 if key1 = key2
@retval > 0 if key1 > key2
*/
int
Count_distinct_field
::
simple_packed_str_
key_cmp
(
void
*
arg
,
uchar
*
key1
,
uchar
*
key2
)
int
Count_distinct_field
::
key_cmp
(
void
*
arg
,
uchar
*
key1
,
uchar
*
key2
)
{
Count_distinct_field
*
compare_arg
=
(
Count_distinct_field
*
)
arg
;
DBUG_ASSERT
(
compare_arg
->
tree
->
get_descriptor
());
...
...
sql/uniques.cc
View file @
67546a26
...
...
@@ -1083,6 +1083,21 @@ Fixed_size_keys_descriptor::setup(THD *thd, Item_sum *item,
bool
Fixed_size_keys_descriptor
::
setup
(
THD
*
thd
,
Field
*
field
)
{
SORT_FIELD
*
sort
,
*
pos
;
if
(
sortorder
)
return
false
;
DBUG_ASSERT
(
sort_keys
==
NULL
);
sortorder
=
(
SORT_FIELD
*
)
thd
->
alloc
(
sizeof
(
SORT_FIELD
));
pos
=
sort
=
sortorder
;
if
(
!
pos
)
return
true
;
sort_keys
=
new
Sort_keys
(
sortorder
,
1
);
if
(
!
sort_keys
)
return
true
;
sort
=
pos
=
sortorder
;
pos
->
setup_for_fixed_size_keys
(
field
);
return
false
;
}
...
...
@@ -1100,3 +1115,8 @@ Fixed_size_keys_descriptor::Fixed_size_keys_descriptor(uint length)
sort_keys
=
NULL
;
sortorder
=
NULL
;
}
Fixed_size_keys_simple
::
Fixed_size_keys_simple
(
uint
length
)
:
Fixed_size_keys_descriptor
(
length
)
{}
sql/uniques.h
View file @
67546a26
...
...
@@ -77,7 +77,7 @@ class Fixed_size_keys_descriptor : public Descriptor
{
public:
Fixed_size_keys_descriptor
(
uint
length
);
~
Fixed_size_keys_descriptor
()
{}
virtual
~
Fixed_size_keys_descriptor
()
{}
uint
get_length_of_key
(
uchar
*
ptr
)
override
{
return
max_length
;
}
bool
setup
(
THD
*
thd
,
Field
*
field
);
bool
setup
(
THD
*
thd
,
Item_sum
*
item
,
...
...
@@ -111,7 +111,7 @@ class Variable_size_keys_descriptor : public Descriptor
public:
Variable_size_keys_descriptor
(
uint
length
);
~
Variable_size_keys_descriptor
();
virtual
~
Variable_size_keys_descriptor
();
Sort_keys
*
get_keys
()
{
return
sort_keys
;
}
SORT_FIELD
*
get_sortorder
()
{
return
sortorder
;
}
...
...
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