MySQL 9.0.0
Source Code Documentation
cs::util::ReplicatedColumnsView Class Reference

Since it's not mandatory that all fields in a TABLE object are replicated, this class extends Table_columns_view container and adds logic to filter out not needed columns. More...

#include <replicated_columns_view.h>

Inheritance diagram for cs::util::ReplicatedColumnsView:
[legend]

Public Member Functions

 ReplicatedColumnsView (THD const *thd=nullptr)
 Constructor for table iteration where a table and filters can be configured. More...
 
 ReplicatedColumnsView (TABLE const *table, THD const *thd=nullptr)
 Constructor which takes the TABLE object whose field set will be iterated. More...
 
 ~ReplicatedColumnsView () override=default
 Destructor for the class. More...
 
ReplicatedColumnsViewset_thd (THD const *thd)
 Setter to initialize the THD object instance to be used to determine if filtering is enabled. More...
 
virtual bool execute_filtering (TABLE const *table, size_t column_index)
 Returns whether or not the field of table table at column_index is to be filtered from this container iteration, according to the list of filters. More...
 
void add_filter (cs::util::ColumnFilterFactory::ColumnFilterType filter_type)
 Adds a new filter according to the given type. More...
 
void add_filter_if_needed (THD const &thd, TABLE *table, table_def const *tabledef, cs::util::ColumnFilterFactory::ColumnFilterType filter_type)
 adds a new filter if the filter's static member function is_filter_needed returns true More...
 
 ReplicatedColumnsView (const ReplicatedColumnsView &rhs)=delete
 
 ReplicatedColumnsView (ReplicatedColumnsView &&rhs)=delete
 
ReplicatedColumnsViewoperator= (const ReplicatedColumnsView &rhs)=delete
 
ReplicatedColumnsViewoperator= (ReplicatedColumnsView &&rhs)=delete
 
- Public Member Functions inherited from Table_columns_view< ExclusionFilter >
template<typename U = ExclusionFilter>
 Table_columns_view (unsigned long options=0, typename std::enable_if< std::is_same< U, std::function< bool(TABLE const *, size_t)> >::value >::type *=nullptr)
 Empty constructor, only available when the predicate type is a lambda function. More...
 
template<typename U = ExclusionFilter>
 Table_columns_view (TABLE const *table, unsigned long options=0, typename std::enable_if< std::is_same< U, std::function< bool(TABLE const *, size_t)> >::value >::type *=nullptr)
 Constructor that takes the target TABLE object, only available when the predicate type is a lambda function. More...
 
 Table_columns_view (ExclusionFilter filtering_predicate, unsigned long options=0)
 Constructor which takes a predicate used to filter this container iteration. More...
 
 Table_columns_view (TABLE const *table, ExclusionFilter filtering_predicate, unsigned long options=0)
 Constructor which takes the TABLE object whose field set will be iterated and a predicate used to filter this container iteration. More...
 
virtual ~Table_columns_view ()
 Destructor for the class. More...
 
virtual Table_columns_viewset_table (const TABLE *rhs)
 Setter which initializes the internal reference to the TABLE object whose field set will be iterated over. More...
 
virtual Table_columns_viewset_filter (ExclusionFilter rhs)
 Setter which initializes the internal filtering predicate of type ExclusionFilter. More...
 
 Table_columns_view (const Table_columns_view &rhs)=delete
 
 Table_columns_view (Table_columns_view &&rhs)=delete
 
Table_columns_viewoperator= (const Table_columns_view &rhs)=delete
 
Table_columns_viewoperator= (Table_columns_view &&rhs)=delete
 
size_t absolute_size () const
 Computes the total number of fields in the table. More...
 
size_t filtered_size () const
 Computes the total number of fields after filtering. More...
 
virtual iterator begin ()
 Creates an iterator object, pointing at the beginning of the table field set. More...
 
virtual iterator end ()
 Creates an iterator object, pointing at the end of the table field set. More...
 
bool is_excluded (size_t index) const
 Returns whether or not the field at index is to be excluded from the field set iteration process. More...
 
MY_BITMAPget_included_fields_bitmap ()
 Returns the bitmap for the columns from the local table set that are to be included in the replicated row. More...
 
MY_BITMAPget_excluded_fields_bitmap ()
 Returns the bitmap for the columns from the local table set that are to be excluded from the replicated row. More...
 
Table_columns_viewtranslate_bitmap (MY_BITMAP &source, MY_BITMAP &destination)
 Takes a bitmap object, as received from the replication channel and translates it to a bitmap that matches the local TABLE object. More...
 
size_t translate_position (size_t source)
 For the absolute position on the table that equals the given position given as a parameter, return the translated position. More...
 
iterator find_by_absolute_pos (size_t absolute_pos)
 Returns the iterator for the (absolute) position in the table. More...
 
template<typename F >
 Table_columns_view (F filtering_predicate, unsigned long options)
 
template<typename F >
 Table_columns_view (TABLE const *target, F filtering_predicate, unsigned long options)
 

Private Attributes

THD const * m_thd
 Instance of THD class to be used to determine if filtering is to be enabled. More...
 
std::vector< std::unique_ptr< cs::util::ColumnFilter > > m_filters
 List of filters to be used against the list of fields. More...
 

Additional Inherited Members

- Public Types inherited from Table_columns_view< ExclusionFilter >
using filter_fn_type = ExclusionFilter
 Alias for the predicate type, for readability purposes. More...
 
- Static Public Attributes inherited from Table_columns_view< ExclusionFilter >
static constexpr unsigned long DEFAULTS = 0
 Default set of options. More...
 
static constexpr unsigned long VFIELDS_ONLY = 1
 Request the view excluding filter to operate TABLE::vfields instead of the full set. More...
 
- Protected Member Functions inherited from Table_columns_view< ExclusionFilter >
Table_columns_viewinit_fields_bitmaps ()
 Initializes the internal included and excluded fields bitmaps. More...
 

Detailed Description

Since it's not mandatory that all fields in a TABLE object are replicated, this class extends Table_columns_view container and adds logic to filter out not needed columns.

One active use-case relates to hidden generated columns. These type of columns are used to support functional indexes and are not meant to be replicated nor included in the serialization/deserialization of binlog events.

See also
ColumnFilterInboundFunctionalIndexes
ColumnFilterOutboundFunctionalIndexes

Another case relates to GIPKs, where the source or replica might contain a generated primary key that does not exist on the other side of the stream. In cases of differences in GIPK, the columns should be filtered out

See also
ColumnFilterInboundGipk

This class allows for the use of other filters that can be added at any point.

Constructor & Destructor Documentation

◆ ReplicatedColumnsView() [1/4]

cs::util::ReplicatedColumnsView::ReplicatedColumnsView ( THD const *  thd = nullptr)

Constructor for table iteration where a table and filters can be configured.

Parameters
thdinstance of THD class to be used to determine if filtering is to be enabled in some cases. It may be nullptr.

◆ ReplicatedColumnsView() [2/4]

cs::util::ReplicatedColumnsView::ReplicatedColumnsView ( TABLE const *  table,
THD const *  thd = nullptr 
)

Constructor which takes the TABLE object whose field set will be iterated.

Parameters
tablereference to the target TABLE object.
thdinstance of THD class to be used to determine if filtering is to be enabled. It may be nullptr.

◆ ~ReplicatedColumnsView()

cs::util::ReplicatedColumnsView::~ReplicatedColumnsView ( )
overridedefault

Destructor for the class.

◆ ReplicatedColumnsView() [3/4]

cs::util::ReplicatedColumnsView::ReplicatedColumnsView ( const ReplicatedColumnsView rhs)
delete

◆ ReplicatedColumnsView() [4/4]

cs::util::ReplicatedColumnsView::ReplicatedColumnsView ( ReplicatedColumnsView &&  rhs)
delete

Member Function Documentation

◆ add_filter()

void cs::util::ReplicatedColumnsView::add_filter ( cs::util::ColumnFilterFactory::ColumnFilterType  filter_type)

Adds a new filter according to the given type.

Parameters
filter_typethe filter type to be added to this column view

◆ add_filter_if_needed()

void cs::util::ReplicatedColumnsView::add_filter_if_needed ( THD const &  thd,
TABLE table,
table_def const *  tabledef,
cs::util::ColumnFilterFactory::ColumnFilterType  filter_type 
)

adds a new filter if the filter's static member function is_filter_needed returns true

Parameters
thdthe THD with context on the situation
tablethe table being iterated
tabledefthe replicated table context if applicable
filter_typethe filter type to be added

◆ execute_filtering()

bool cs::util::ReplicatedColumnsView::execute_filtering ( TABLE const *  table,
size_t  column_index 
)
virtual

Returns whether or not the field of table table at column_index is to be filtered from this container iteration, according to the list of filters.

Parameters
tablereference to the target TABLE object.
column_indexindex for the column to be tested for filtering,
Returns
true if the field is to be filtered out and false otherwise.

◆ operator=() [1/2]

ReplicatedColumnsView & cs::util::ReplicatedColumnsView::operator= ( const ReplicatedColumnsView rhs)
delete

◆ operator=() [2/2]

ReplicatedColumnsView & cs::util::ReplicatedColumnsView::operator= ( ReplicatedColumnsView &&  rhs)
delete

◆ set_thd()

cs::util::ReplicatedColumnsView & cs::util::ReplicatedColumnsView::set_thd ( THD const *  thd)

Setter to initialize the THD object instance to be used to determine if filtering is enabled.

Parameters
thdinstance of THD class to be used to determine if filtering is to be enabled. It may be nullptr.
Returns
this object reference (for chaining purposes).

Member Data Documentation

◆ m_filters

std::vector<std::unique_ptr<cs::util::ColumnFilter> > cs::util::ReplicatedColumnsView::m_filters
private

List of filters to be used against the list of fields.

◆ m_thd

THD const* cs::util::ReplicatedColumnsView::m_thd
private

Instance of THD class to be used to determine if filtering is to be enabled.


The documentation for this class was generated from the following files: