MySQL 8.0.42
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
column_filter_factory.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 2025, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef CS_COLUMN_FILTER_FACTORY_H
25#define CS_COLUMN_FILTER_FACTORY_H
26
30
31namespace cs {
32namespace util {
33/**
34 @class ColumnFilterFactory
35
36 This class allows the developer to create a filter instance given a type
37 */
39 public:
40 /**
41 @brief The different types of filters for column iteration
42 */
43 enum class ColumnFilterType {
44 outbound_func_index, // filter functional indexes when outputting an event
45 inbound_func_index, // filter functional indexes when receiving an event
46 inbound_gipk // Filter GIPK when only present on the replica
47 };
48
49 /**
50 @brief Create a filter object
51
52 @param filter_type the filter to be created
53 @return a unique pointer to a sub class of ColumnFilter
54 */
55 static std::unique_ptr<ColumnFilter> create_filter(
56 ColumnFilterType filter_type) {
57 switch (filter_type) {
59 return std::make_unique<
62 return std::make_unique<ColumnFilterInboundFunctionalIndexes>();
64 return std::make_unique<ColumnFilterInboundGipk>();
65 default:
66 /* This shall never happen. */
67 assert(0); /* purecov: inspected */
68 break;
69 }
70 return nullptr;
71 }
72
73 /**
74 @brief Returns if a filter is needed given the parameters
75
76 @param thd The thread being used in this context
77 @param table The table being filtered
78 @param tabledef The replicated table context if applicable
79 @param filter_type The filter type being tested
80 @return true if the filter should be used
81 @return false if the filter is not needed
82 */
83 static bool is_filter_needed(THD const &thd, TABLE *table,
84 table_def const *tabledef,
85 ColumnFilterType filter_type) {
86 switch (filter_type) {
89 thd, table, tabledef);
92 thd, table, tabledef);
94 return ColumnFilterInboundGipk::is_filter_needed(thd, table, tabledef);
95 default:
96 /* This shall never happen. */
97 assert(0); /* purecov: inspected */
98 break;
99 }
100 return false;
101 }
102};
103} // namespace util
104} // namespace cs
105#endif // CS_COLUMN_FILTER_FACTORY_H
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
This class allows the developer to create a filter instance given a type.
Definition: column_filter_factory.h:38
ColumnFilterType
The different types of filters for column iteration.
Definition: column_filter_factory.h:43
static bool is_filter_needed(THD const &thd, TABLE *table, table_def const *tabledef, ColumnFilterType filter_type)
Returns if a filter is needed given the parameters.
Definition: column_filter_factory.h:83
static std::unique_ptr< ColumnFilter > create_filter(ColumnFilterType filter_type)
Create a filter object.
Definition: column_filter_factory.h:55
static bool is_filter_needed(THD const &thd, TABLE *table, table_def const *tabledef)
Is this filter needed given context passed in the parameters.
Definition: column_filter_inbound_func_indexes.cc:34
static bool is_filter_needed(THD const &thd, TABLE *table, table_def const *tabledef)
Is this filter needed given context passed in the parameters.
Definition: column_filter_inbound_gipk.cc:32
Definition: column_filter_outbound_func_indexes.h:59
static bool is_filter_needed(THD const &thd, TABLE *table, table_def const *tabledef)
Is this filter needed given context passed in the parameters.
Definition: column_filter_outbound_func_indexes.cc:34
A table definition from the master.
Definition: rpl_utility.h:248
Definition: commit_order_queue.h:34
Unique_ptr< T, std::nullptr_t > make_unique(size_t size)
In-place constructs a new unique pointer with no specific allocator and with array type T.
Definition: table.h:1400