Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
Description
We should eventually remove DTCollation from non-string items, as it's always initialized to DTCollation_numeric() and therefore wastes memory.
As a step to this, let's move the following members from Type_std_attributes:
- max_length
- decimals
- unsigned_flag
into a new class Type_numeric_attributes and derive Type_std_attributes from it.
Let's also add a new virtual method in Field:
virtual Type_numeric_attributes type_numeric_attributes() const; |
and turn Field::type_std_attributes() from a virtual to a non-virtual method like this:
Type_std_attributes type_std_attributes() const |
{
|
return Type_std_attributes(type_numeric_attributes(), dtcollation()); |
}
|
All former Type_std_attributes methods that operate on only the moved members should also move to class Type_numeric_attributes.
As a result, the classes will look about like this:
class Type_numeric_attributes |
{
|
public: |
static uint count_unsigned(Item **item, uint nitems); |
static uint32 find_max_char_length(Item **item, uint nitems); |
static uint32 find_max_octet_length(Item **item, uint nitems); |
static int find_max_decimal_int_part(Item **item, uint nitems); |
static uint find_max_decimals(Item **item, uint nitems); |
public: |
/* |
The maximum value length in characters multiplied by collation->mbmaxlen.
|
Almost always it's the maximum value length in bytes.
|
*/
|
uint32 max_length;
|
uint decimals;
|
bool unsigned_flag; |
public: |
Type_numeric_attributes()
|
:max_length(0), decimals(0), unsigned_flag(false) |
{ }
|
Type_numeric_attributes(uint32 max_length_arg, uint decimals_arg,
|
bool unsigned_flag_arg) |
:max_length(max_length_arg),
|
decimals(decimals_arg),
|
unsigned_flag(unsigned_flag_arg)
|
{ }
|
protected: |
void aggregate_numeric_attributes_real(Item **item, uint nitems); |
void aggregate_numeric_attributes_decimal(Item **item, uint nitems, |
bool unsigned_arg); |
};
|
class Type_std_attributes: public Type_numeric_attributes |
{
|
public: |
DTCollation collation;
|
Type_std_attributes()
|
:collation(&my_charset_bin, DERIVATION_COERCIBLE)
|
{ }
|
Type_std_attributes(const Type_numeric_attributes &nattr, |
const DTCollation &dtc) |
:Type_numeric_attributes(nattr), collation(dtc)
|
{ }
|
...
|
};
|
Attachments
Activity
Field | Original Value | New Value |
---|---|---|
Rank | Ranked higher |
Description |
We should eventually remove DTCollation from non-string items, as it's always initialized to DTCollation_numeric() and therefore wastes memory.
As a step to this, let's move the following members from Type_std_attributes: - max_length - decimals - unsigned_flag into a new class Type_numeric_attributes and derive Type_std_attributes from it. Let's also add a new virtual method in Field: {code:cpp} virtual Type_numeric_attributes type_numeric_attributes() const; {code} and turn Field::type_std_attributes() from a virtual to a non-virtual method like this: {code:cpp} Type_std_attributes type_std_attributes() const { return Type_std_attributes(type_numeric_attributes(), dtcollation()); } {code} All former Type_std_attributes methods that operate on only the moved members should also move to class Type_numeric_attributes. As a result, the classes will look about like this: {code:cpp} class Type_numeric_attributes { public: static uint count_unsigned(Item **item, uint nitems); static uint32 find_max_char_length(Item **item, uint nitems); static uint32 find_max_octet_length(Item **item, uint nitems); static int find_max_decimal_int_part(Item **item, uint nitems); static uint find_max_decimals(Item **item, uint nitems); public: /* The maximum value length in characters multiplied by collation->mbmaxlen. Almost always it's the maximum value length in bytes. */ uint32 max_length; uint decimals; bool unsigned_flag; public: Type_numeric_attributes() :max_length(0), decimals(0), unsigned_flag(false) { } Type_numeric_attributes(uint32 max_length_arg, uint decimals_arg, bool unsigned_flag_arg) :max_length(max_length_arg), decimals(decimals_arg), unsigned_flag(unsigned_flag_arg) { } protected: void aggregate_numeric_attributes_real(Item **item, uint nitems); void aggregate_numeric_attributes_decimal(Item **item, uint nitems, bool unsigned_arg); }; {code} {code:cpp} class Type_std_attributes: public Type_numeric_attributes { public: DTCollation collation; Type_std_attributes() :collation(&my_charset_bin, DERIVATION_COERCIBLE) { } Type_std_attributes(const Type_numeric_attributes &nattr, const DTCollation &dtc) :Type_numeric_attributes(nattr), collation(dtc) { } ... }; {code} |
We should eventually remove DTCollation from non-string items, as it's always initialized to DTCollation_numeric() and therefore wastes memory.
As a step to this, let's move the following members from Type_std_attributes: - max_length - decimals - unsigned_flag into a new class Type_numeric_attributes and derive Type_std_attributes from it. Let's also add a new virtual method in Field: {code:cpp} virtual Type_numeric_attributes type_numeric_attributes() const; {code} and turn Field::type_std_attributes() from a virtual to a non-virtual method like this: {code:cpp} Type_std_attributes type_std_attributes() const { return Type_std_attributes(type_numeric_attributes(), dtcollation()); } {code} All former Type_std_attributes methods that operate on only the moved members should also move to class Type_numeric_attributes. As a result, the classes will look about like this: {code:cpp} class Type_numeric_attributes { public: static uint count_unsigned(Item **item, uint nitems); static uint32 find_max_char_length(Item **item, uint nitems); static uint32 find_max_octet_length(Item **item, uint nitems); static int find_max_decimal_int_part(Item **item, uint nitems); static uint find_max_decimals(Item **item, uint nitems); public: /* The maximum value length in characters multiplied by collation->mbmaxlen. Almost always it's the maximum value length in bytes. */ uint32 max_length; uint decimals; bool unsigned_flag; public: Type_numeric_attributes() :max_length(0), decimals(0), unsigned_flag(false) { } Type_numeric_attributes(uint32 max_length_arg, uint decimals_arg, bool unsigned_flag_arg) :max_length(max_length_arg), decimals(decimals_arg), unsigned_flag(unsigned_flag_arg) { } protected: void aggregate_numeric_attributes_real(Item **item, uint nitems); void aggregate_numeric_attributes_decimal(Item **item, uint nitems, bool unsigned_arg); }; {code} {code:cpp} class Type_std_attributes: public Type_numeric_attributes { public: DTCollation collation; Type_std_attributes() :collation(&my_charset_bin, DERIVATION_COERCIBLE) { } Type_std_attributes(const Type_numeric_attributes &nattr, const DTCollation &dtc) :Type_numeric_attributes(nattr), collation(dtc) { } ... }; {code} |
Fix Version/s | 10.5.0 [ 23709 ] | |
Fix Version/s | 10.5 [ 23123 ] |
issue.field.resolutiondate | 2019-08-12 17:46:57.0 | 2019-08-12 17:46:57.294 |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Workflow | MariaDB v3 [ 98892 ] | MariaDB v4 [ 134063 ] |