MySQL 8.1.0
Source Code Documentation
column_statistics.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 2023, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef DD__COLUMN_STATISTIC_INCLUDED
24#define DD__COLUMN_STATISTIC_INCLUDED
25
26#include "my_alloc.h" // MEM_ROOT
27#include "sql/dd/sdi_fwd.h" // RJ_Document
28#include "sql/dd/types/entity_object.h" // dd::Entity_object
29
30class THD;
31struct MDL_key;
32
33namespace histograms {
34class Histogram;
35}
36
37namespace dd {
38
39///////////////////////////////////////////////////////////////////////////
40
41class Column_statistics_impl;
42class Item_name_key;
43class Primary_id_key;
44class Void_key;
45
46namespace tables {
47class Column_statistics;
48}
49
50///////////////////////////////////////////////////////////////////////////
51
52class Column_statistics : virtual public Entity_object {
53 protected:
54 /// MEM_ROOT on which the histogram data is allocated.
56
57 public:
64
65 // We need a set of functions to update a preallocated key.
66 bool update_id_key(Id_key *key) const { return update_id_key(key, id()); }
67
68 static bool update_id_key(Id_key *key, Object_id id);
69
71 return update_name_key(key, name());
72 }
73
74 static bool update_name_key(Name_key *key, const String_type &name);
75
76 bool update_aux_key(Aux_key *) const { return true; }
77
78 ~Column_statistics() override = default;
79
80 virtual const String_type &schema_name() const = 0;
81 virtual void set_schema_name(const String_type &schema_name) = 0;
82
83 virtual const String_type &table_name() const = 0;
84 virtual void set_table_name(const String_type &table_name) = 0;
85
86 virtual const String_type &column_name() const = 0;
87 virtual void set_column_name(const String_type &column_name) = 0;
88
89 virtual const histograms::Histogram *histogram() const = 0;
91
92 /**
93 Converts *this into json.
94
95 Converts all member variables that are to be included in the sdi
96 into json by transforming them appropriately and passing them to
97 the rapidjson writer provided.
98
99 @param wctx opaque context for data needed by serialization
100 @param w rapidjson writer which will perform conversion to json
101
102 */
103 virtual void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const = 0;
104
105 /**
106 Re-establishes the state of *this by reading sdi information from
107 the rapidjson DOM subobject provided.
108
109 Cross-references encountered within this object are tracked in
110 sdictx, so that they can be updated when the entire object graph
111 has been established.
112
113 @param rctx stores book-keeping information for the
114 deserialization process
115 @param val subobject of rapidjson DOM containing json
116 representation of this object
117 */
118 virtual bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val) = 0;
119
120 /*
121 Create a unique name for a column statistic object based on the triplet
122 SCHEMA_NAME TABLE_NAME COLUMN_NAME separated with the 'Unit Separator'
123 character.
124 */
126 const String_type &table_name,
127 const String_type &column_name);
128
131 column_name());
132 }
133
134 static void create_mdl_key(const String_type &schema_name,
135 const String_type &table_name,
137
140 column_name(), key);
141 }
142
143 virtual Column_statistics *clone() const = 0;
144
145 /**
146 Allocate a new object which can serve as a placeholder for the original
147 object in the Dictionary_client's dropped registry. Such object has the
148 same keys as the original but has no other info and as result occupies
149 less memory.
150 */
152};
153
154///////////////////////////////////////////////////////////////////////////
155
156} // namespace dd
157
158#endif // DD__COLUMN_STATISTIC_INCLUDED
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
Definition: column_statistics_impl.h:57
Definition: column_statistics.h:52
virtual const String_type & table_name() const =0
virtual const histograms::Histogram * histogram() const =0
~Column_statistics() override=default
bool update_aux_key(Aux_key *) const
Definition: column_statistics.h:76
virtual void set_schema_name(const String_type &schema_name)=0
bool update_name_key(Name_key *key) const
Definition: column_statistics.h:70
MEM_ROOT m_mem_root
MEM_ROOT on which the histogram data is allocated.
Definition: column_statistics.h:55
bool update_id_key(Id_key *key) const
Definition: column_statistics.h:66
Column_statistics_impl Impl
Definition: column_statistics.h:58
Item_name_key Name_key
Definition: column_statistics.h:62
virtual void set_column_name(const String_type &column_name)=0
tables::Column_statistics DD_table
Definition: column_statistics.h:60
Void_key Aux_key
Definition: column_statistics.h:63
virtual bool deserialize(Sdi_rcontext *rctx, const RJ_Value &val)=0
Re-establishes the state of *this by reading sdi information from the rapidjson DOM subobject provide...
Column_statistics Cache_partition
Definition: column_statistics.h:59
virtual Column_statistics * clone_dropped_object_placeholder() const =0
Allocate a new object which can serve as a placeholder for the original object in the Dictionary_clie...
virtual void serialize(Sdi_wcontext *wctx, Sdi_writer *w) const =0
Converts *this into json.
void create_mdl_key(MDL_key *key) const
Definition: column_statistics.h:138
virtual void set_table_name(const String_type &table_name)=0
virtual const String_type & column_name() const =0
static void create_mdl_key(const String_type &schema_name, const String_type &table_name, const String_type &column_name, MDL_key *key)
Definition: column_statistics_impl.cc:80
virtual const String_type & schema_name() const =0
String_type create_name() const
Definition: column_statistics.h:129
virtual Column_statistics * clone() const =0
Primary_id_key Id_key
Definition: column_statistics.h:61
virtual void set_histogram(const histograms::Histogram *histogram)=0
Base class for dictionary objects which has single column integer primary key.
Definition: entity_object.h:47
virtual const String_type & name() const =0
Definition: object_keys.h:165
Definition: object_keys.h:76
Opaque context which keeps reusable resoureces needed during deserialization.
Definition: sdi.cc:230
Opaque context which keeps reusable resources needed during serialization.
Definition: sdi.cc:128
Definition: object_keys.h:53
Definition: column_statistics.h:42
Histogram base class.
Definition: histogram.h:291
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
RJ_Writer Sdi_writer
Alias for the rapidjson Writer type to use in serialization.
Definition: sdi_fwd.h:63
unsigned long long Object_id
Definition: object_id.h:30
rapidjson::GenericValue< RJ_Encoding, RJ_Allocator > RJ_Value
Definition: sdi_fwd.h:48
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
Definition: column_statistics.h:33
required string key
Definition: replication_asynchronous_connection_failover.proto:59
This header provides Rapidjson Type Aliases.
Metadata lock object key.
Definition: mdl.h:364
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82