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
7a1d56eb
Commit
7a1d56eb
authored
Dec 02, 2020
by
Varun Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attempt to use an Encoder class
parent
23bd5607
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
61 deletions
+63
-61
sql/item_sum.cc
sql/item_sum.cc
+5
-5
sql/sql_statistics.cc
sql/sql_statistics.cc
+2
-2
sql/uniques.cc
sql/uniques.cc
+19
-17
sql/uniques.h
sql/uniques.h
+37
-37
No files found.
sql/item_sum.cc
View file @
7a1d56eb
...
...
@@ -982,10 +982,10 @@ int Aggregator_distinct::insert_record_to_unique()
if
(
tree
->
is_variable_sized
())
{
uint
packed_length
;
if
((
packed_length
=
tree
->
get_descriptor
()
->
make_
packed_
record
(
true
))
==
0
)
if
((
packed_length
=
tree
->
get_descriptor
()
->
make_record
(
true
))
==
0
)
return
-
1
;
// NULL value
DBUG_ASSERT
(
packed_length
<=
tree
->
get_size
());
return
tree
->
unique_add
(
tree
->
get_descriptor
()
->
get_
packed_
rec_ptr
());
return
tree
->
unique_add
(
tree
->
get_descriptor
()
->
get_rec_ptr
());
}
copy_fields
(
tmp_table_param
);
...
...
@@ -4676,7 +4676,7 @@ qsort_cmp2 Item_func_group_concat::get_comparator_function_for_order_by()
uchar
*
Item_func_group_concat
::
get_record_pointer
()
{
return
is_distinct_packed
()
?
unique_filter
->
get_descriptor
()
->
get_
packed_
rec_ptr
()
:
unique_filter
->
get_descriptor
()
->
get_rec_ptr
()
:
(
skip_nulls
()
?
table
->
record
[
0
]
+
table
->
s
->
null_bytes
:
table
->
record
[
0
]);
...
...
@@ -4935,11 +4935,11 @@ int Item_func_group_concat::insert_record_to_unique()
{
uint
packed_length
;
if
((
packed_length
=
unique_filter
->
get_descriptor
()
->
make_
packed_
record
(
skip_nulls
()))
==
0
)
make_record
(
skip_nulls
()))
==
0
)
return
-
1
;
// NULL value
DBUG_ASSERT
(
packed_length
<=
unique_filter
->
get_size
());
return
unique_filter
->
unique_add
(
unique_filter
->
get_descriptor
()
->
get_
packed_
rec_ptr
());
->
get_rec_ptr
());
}
copy_fields
(
tmp_table_param
);
...
...
sql/sql_statistics.cc
View file @
7a1d56eb
...
...
@@ -1758,10 +1758,10 @@ class Count_distinct_field: public Sql_alloc
uint
length
=
tree
->
get_size
();
if
(
tree
->
is_variable_sized
())
{
length
=
tree
->
get_descriptor
()
->
make_
packed_
record
(
true
);
length
=
tree
->
get_descriptor
()
->
make_record
(
true
);
DBUG_ASSERT
(
length
!=
0
);
DBUG_ASSERT
(
length
<=
tree
->
get_size
());
return
tree
->
unique_add
(
tree
->
get_descriptor
()
->
get_
packed_
rec_ptr
());
return
tree
->
unique_add
(
tree
->
get_descriptor
()
->
get_rec_ptr
());
}
return
tree
->
unique_add
(
table_field
->
ptr
);
}
...
...
sql/uniques.cc
View file @
7a1d56eb
...
...
@@ -876,25 +876,32 @@ int Unique_impl::write_record_to_file(uchar *key)
}
Variable_size_
composite_key_desc
::
Variable_size_composite_key_desc
(
uint
length
)
Variable_size_
keys_descriptor
::
Variable_size_keys_descriptor
(
uint
length
)
{
max_length
=
length
;
flags
=
(
1
<<
VARIABLE_SIZED_KEYS_WITH_ORIGINAL_VALUES
);
sort_keys
=
NULL
;
sortorder
=
NULL
;
packed_rec_ptr
=
(
uchar
*
)
my_malloc
(
PSI_INSTRUMENT_ME
,
length
,
MYF
(
MY_WME
|
MY_THREAD_SPECIFIC
));
tmp_buffer
.
alloc
(
length
);
}
Variable_size_keys_descriptor
::~
Variable_size_keys_descriptor
()
{
}
Variable_size_composite_key_desc
::
Variable_size_composite_key_desc
(
uint
length
)
:
Variable_size_keys_descriptor
(
length
)
{
}
Variable_size_composite_key_desc
::~
Variable_size_composite_key_desc
()
Variable_size_keys_simple
::
Variable_size_keys_simple
(
uint
length
)
:
Variable_size_keys_descriptor
(
length
)
{
my_free
(
packed_rec_ptr
);
}
/*
@brief
Make a record with packed values for a key
...
...
@@ -903,7 +910,7 @@ Variable_size_composite_key_desc::~Variable_size_composite_key_desc()
0 NULL value
>0 length of the packed record
*/
uint
Variable_size_composite_key_desc
::
make_packed
_record
(
bool
exclude_nulls
)
/*uint Variable_size_composite_key_desc::make
_record(bool exclude_nulls)
{
Field *field;
SORT_FIELD *sort_field;
...
...
@@ -943,7 +950,7 @@ uint Variable_size_composite_key_desc::make_packed_record(bool exclude_nulls)
store_packed_length(orig_to, length);
return length;
}
*/
/*
@brief
...
...
@@ -964,8 +971,8 @@ uint Variable_size_composite_key_desc::make_packed_record(bool exclude_nulls)
*/
bool
Variable_size_
composite_key_desc
::
setup
(
THD
*
thd
,
Item_sum
*
item
,
uint
non_const_args
,
uint
arg_count
)
Variable_size_
keys_descriptor
::
setup
(
THD
*
thd
,
Item_sum
*
item
,
uint
non_const_args
,
uint
arg_count
)
{
SORT_FIELD
*
sort
,
*
pos
;
if
(
sortorder
)
...
...
@@ -1010,7 +1017,7 @@ Variable_size_composite_key_desc::setup(THD *thd, Item_sum *item,
FALSE setup successful
*/
bool
Variable_size_
composite_key_desc
::
setup
(
THD
*
thd
,
Field
*
field
)
bool
Variable_size_
keys_descriptor
::
setup
(
THD
*
thd
,
Field
*
field
)
{
SORT_FIELD
*
sort
,
*
pos
;
if
(
sortorder
)
...
...
@@ -1075,11 +1082,6 @@ int Variable_size_keys_simple::compare_keys(uchar *a, uchar *b)
}
Variable_size_keys_simple
::
Variable_size_keys_simple
(
uint
length
)
:
Variable_size_composite_key_desc
(
length
)
{}
/* FIXED SIZE KEYS DESCRIPTOR */
...
...
sql/uniques.h
View file @
7a1d56eb
...
...
@@ -65,8 +65,8 @@ class Descriptor : public Sql_alloc
SORT_FIELD
*
get_sortorder
()
{
return
sortorder
;
}
/* need to be moved to a separate class */
virtual
uchar
*
get_
packed_
rec_ptr
()
{
return
NULL
;
}
virtual
uint
make_
packed_
record
(
bool
exclude_nulls
)
{
return
0
;
}
virtual
uchar
*
get_rec_ptr
()
{
return
NULL
;
}
virtual
uint
make_record
(
bool
exclude_nulls
)
{
return
0
;
}
};
...
...
@@ -172,67 +172,58 @@ class Encode_record : public Sql_alloc
uchar
*
rec_ptr
;
String
tmp_buffer
;
Sort_keys
*
sort_keys
;
public:
Encode_record
()
Encode_record
(
Sort_keys
*
keys
)
{
sort_keys
=
keys
;
rec_ptr
=
NULL
;
}
virtual
~
Encode_record
()
{}
virtual
uint
make_record
()
{
return
0
;
}
virtual
uint
make_record
(
bool
exclude_nulls
)
{
return
0
;
}
uchar
*
get_packed_rec_ptr
()
{
return
rec_ptr
;
}
};
class
Encode_record_for_count_distinct
:
public
Encode_record
{
public:
Encode_record_for_count_distinct
()
:
Encode_record
()
{}
Encode_record_for_count_distinct
(
Sort_keys
*
keys
)
:
Encode_record
(
keys
)
{}
~
Encode_record_for_count_distinct
()
{}
uint
make_record
(
)
override
{
return
0
;
}
uint
make_record
(
bool
exclude_nulls
)
override
{
return
0
;
}
};
class
Encode_record_for_group_concat
:
public
Encode_record
{
public:
Encode_record_for_group_concat
()
:
Encode_record
()
{}
Encode_record_for_group_concat
(
Sort_keys
*
keys
)
:
Encode_record
(
keys
)
{}
~
Encode_record_for_group_concat
()
{}
uint
make_record
()
override
{
return
0
;
}
};
uint
make_record
(
bool
exclude_nulls
)
override
{
return
0
;
}
};
/*
Descriptor for variable size keys
*/
class
Variable_size_composite_key_desc
:
public
Descriptor
{
protected:
/*
Packed record ptr for a record of the table, the packed value in this
record is added to the unique tree
*/
uchar
*
packed_rec_ptr
;
String
tmp_buffer
;
class
Variable_size_keys_descriptor
:
public
Descriptor
{
public:
Variable_size_composite_key_desc
(
uint
length
);
virtual
~
Variable_size_composite_key_desc
();
Sort_keys
*
get_keys
()
{
return
sort_keys
;
}
SORT_FIELD
*
get_sortorder
()
{
return
sortorder
;
}
bool
setup
(
THD
*
thd
,
Item_sum
*
item
,
uint
non_const_args
,
uint
arg_count
);
bool
setup
(
THD
*
thd
,
Field
*
field
);
Variable_size_keys_descriptor
(
uint
length
);
virtual
~
Variable_size_keys_descriptor
();
uint
get_length_of_key
(
uchar
*
ptr
)
override
{
return
read_packed_length
(
ptr
);
}
int
compare_keys
(
uchar
*
a
,
uchar
*
b
)
override
;
uint
make_record
(
bool
exclude_nulls
)
{
return
0
;}
uchar
*
get_packed_rec_ptr
()
{
return
NULL
;
}
Sort_keys
*
get_keys
()
{
return
sort_keys
;
}
SORT_FIELD
*
get_sortorder
()
{
return
sortorder
;
}
bool
setup
(
THD
*
thd
,
Item_sum
*
item
,
uint
non_const_args
,
uint
arg_count
);
bool
setup
(
THD
*
thd
,
Field
*
field
);
virtual
int
compare_keys
(
uchar
*
a
,
uchar
*
b
)
override
{
return
0
;
}
// All need to be moved to some new class
// returns the length of the key along with the length bytes for the key
static
uint
read_packed_length
(
uchar
*
p
)
...
...
@@ -243,16 +234,25 @@ class Variable_size_composite_key_desc : public Descriptor
{
int4store
(
p
,
sz
-
size_of_length_field
);
}
static
const
uint
size_of_length_field
=
4
;
uchar
*
get_packed_rec_ptr
()
{
return
packed_rec_ptr
;
}
uint
make_packed_record
(
bool
exclude_nulls
);
};
/*
Descriptor for variable size keys
*/
class
Variable_size_composite_key_desc
:
public
Variable_size_keys_descriptor
{
public:
Variable_size_composite_key_desc
(
uint
length
);
~
Variable_size_composite_key_desc
()
{}
int
compare_keys
(
uchar
*
a
,
uchar
*
b
)
override
;
};
/* Descriptor for variable size keys with only one component */
class
Variable_size_keys_simple
:
public
Variable_size_
composite_key_desc
class
Variable_size_keys_simple
:
public
Variable_size_
keys_descriptor
{
public:
Variable_size_keys_simple
(
uint
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