24#ifndef _table_column_iterator_h
25#define _table_column_iterator_h
107template <
typename ExclusionFilter = std::function<
bool(TABLE const *,
size_t)>>
133 template <
typename U = ExclusionFilter>
136 typename std::enable_if<std::is_same<
137 U, std::function<
bool(
TABLE const *,
size_t)>>::value>::
type * =
148 template <
typename U = ExclusionFilter>
151 typename std::enable_if<std::is_same<
152 U, std::function<
bool(
TABLE const *,
size_t)>>::value>::
type * =
249 long translation_offset);
469 typename std::enable_if<std::is_same<
470 U, std::function<
bool(
TABLE const *,
size_t)>>::value>::
type *)
480 typename std::enable_if<std::is_same<
481 U, std::function<
bool(
TABLE const *,
size_t)>>::value>::
type *)
495 F filtering_predicate,
524 if (this->
m_table ==
nullptr)
return 0;
566 if (this->
m_table ==
nullptr)
return (*
this);
567 if (source.
bitmap ==
nullptr)
return (*
this);
571 for (
auto it =
begin(); it !=
end(); ++it) {
572 size_t source_pos = it.translated_pos();
573 size_t abs_pos = it.absolute_pos();
574 if (source_pos >=
source.n_bits)
break;
586 return std::find_if(
begin(),
end(), [absolute_pos](
auto it) {
593 for (
auto it =
begin(); it !=
end(); ++it) {
594 size_t abs_pos = it.absolute_pos();
595 if (abs_pos == orig_pos)
return it.translated_pos();
602 if (this->
m_table ==
nullptr)
return (*
this);
614 for (
auto fld = this->
m_table->
vfield; *fld !=
nullptr; ++fld) {
615 auto idx = (*fld)->field_index();
642 long absolute_pos,
long filtered_pos)
644 m_absolute_pos{absolute_pos},
645 m_filtered_pos{filtered_pos},
646 m_translation_offset{0} {}
650 long absolute_pos,
long filtered_pos,
651 long translation_offset)
653 m_absolute_pos{absolute_pos},
654 m_filtered_pos{filtered_pos},
655 m_translation_offset{translation_offset} {}
676 if (this->m_parent->m_table !=
nullptr &&
677 this->m_absolute_pos !=
678 static_cast<long>(this->m_parent->absolute_size())) {
680 ++this->m_absolute_pos;
681 }
while (this->m_absolute_pos !=
682 static_cast<long>(this->m_parent->absolute_size()) &&
683 this->m_parent->is_excluded(this->m_absolute_pos));
684 ++this->m_filtered_pos;
692 if (this->m_parent->m_table !=
nullptr &&
693 this->m_absolute_pos !=
694 static_cast<long>(this->m_parent->absolute_size())) {
695 return this->m_parent->m_table->field[this->m_absolute_pos];
711 return this->operator*();
724 return !((*this) == rhs);
730 if (this->m_parent->m_table !=
nullptr && this->m_absolute_pos != 0) {
732 --this->m_absolute_pos;
733 }
while (this->m_absolute_pos != 0 &&
734 this->m_parent->is_excluded(this->m_absolute_pos));
735 --this->m_filtered_pos;
750 return static_cast<size_t>(this->m_absolute_pos);
755 return static_cast<size_t>(this->m_filtered_pos);
760 return static_cast<size_t>(this->m_filtered_pos + this->m_translation_offset);
Iterator class to allow iterating over the replicatable fields in a TABLE object field set.
Definition: table_column_iterator.h:214
iterator & operator--()
Definition: table_column_iterator.h:729
reference operator*() const
Definition: table_column_iterator.h:691
std::ptrdiff_t difference_type
Definition: table_column_iterator.h:216
long m_filtered_pos
The position, relative to the set of included fields, this instance iterator is pointing to.
Definition: table_column_iterator.h:328
iterator(Table_columns_view &parent, long pos, long col)
Constructor for the iterator.
Definition: table_column_iterator.h:641
bool operator!=(iterator rhs) const
Definition: table_column_iterator.h:722
size_t absolute_pos()
Returns the position this iterator object is pointing to, within the local table field set.
Definition: table_column_iterator.h:749
iterator & operator++()
Definition: table_column_iterator.h:675
bool operator==(iterator rhs) const
Definition: table_column_iterator.h:715
iterator & operator=(const iterator &rhs)
Definition: table_column_iterator.h:664
Table_columns_view const * m_parent
A reference to the instance we wish to iterate over.
Definition: table_column_iterator.h:318
long m_translation_offset
Translation unit used on top of the iterator filtered position, so we can adjust the position to anot...
Definition: table_column_iterator.h:338
std::bidirectional_iterator_tag iterator_category
Definition: table_column_iterator.h:220
pointer operator->() const
Definition: table_column_iterator.h:710
size_t translated_pos()
Returns the position this iterator object is pointing to, within the replicated table field set plus ...
Definition: table_column_iterator.h:759
virtual ~iterator()=default
Default destructor.
long m_absolute_pos
The position, relative to the TABLE object, this instance iterator is pointing to.
Definition: table_column_iterator.h:323
size_t filtered_pos()
Returns the position this iterator relative to the set of table columns which are not excluded by the...
Definition: table_column_iterator.h:754
This template class acts as a container of table columns and encapsulates and abstracts a TABLE objec...
Definition: table_column_iterator.h:108
static constexpr unsigned long VFIELDS_ONLY
Request the view excluding filter to operate TABLE::vfields instead of the full set.
Definition: table_column_iterator.h:123
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.
Definition: table_column_iterator.h:467
MY_BITMAP & get_included_fields_bitmap()
Returns the bitmap for the columns from the local table set that are to be included in the replicated...
Definition: table_column_iterator.h:554
virtual ~Table_columns_view()
Destructor for the class.
Definition: table_column_iterator.h:503
virtual Table_columns_view & set_table(const TABLE *rhs)
Setter which initializes the internal reference to the TABLE object whose field set will be iterated ...
Definition: table_column_iterator.h:509
ExclusionFilter filter_fn_type
Alias for the predicate type, for readability purposes.
Definition: table_column_iterator.h:113
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.
Definition: table_column_iterator.h:549
virtual iterator end()
Creates an iterator object, pointing at the end of the table field set.
Definition: table_column_iterator.h:541
size_t m_filtered_size
Number of columns to include in iteration.
Definition: table_column_iterator.h:443
virtual iterator begin()
Creates an iterator object, pointing at the beginning of the table field set.
Definition: table_column_iterator.h:534
Table_columns_view & translate_bitmap(MY_BITMAP &source, MY_BITMAP &destination)
Takes a bitmap object, as received from the replication channel and translates it to a bitmap that ma...
Definition: table_column_iterator.h:564
virtual Table_columns_view & set_filter(ExclusionFilter rhs)
Setter which initializes the internal filtering predicate of type ExclusionFilter.
Definition: table_column_iterator.h:516
Table_columns_view(Table_columns_view &&rhs)=delete
MY_BITMAP & get_excluded_fields_bitmap()
Returns the bitmap for the columns from the local table set that are to be excluded from the replicat...
Definition: table_column_iterator.h:559
Table_columns_view(ExclusionFilter filtering_predicate, unsigned long options=0)
Constructor which takes a predicate used to filter this container iteration.
MY_BITMAP m_included_fields_bitmap
Bitmap that holds the information about which columns from the local table are to be included in the ...
Definition: table_column_iterator.h:448
iterator find_by_absolute_pos(size_t absolute_pos)
Returns the iterator for the (absolute) position in the table.
Definition: table_column_iterator.h:585
TABLE const * m_table
The TABLE object reference which contains the field set to be iterated over.
Definition: table_column_iterator.h:436
size_t translate_position(size_t source)
For the absolute position on the table that equals the given position given as a parameter,...
Definition: table_column_iterator.h:592
Table_columns_view & operator=(Table_columns_view &&rhs)=delete
Table_columns_view & operator=(const Table_columns_view &rhs)=delete
Table_columns_view & init_fields_bitmaps()
Initializes the internal included and excluded fields bitmaps.
Definition: table_column_iterator.h:601
static bool default_filter(TABLE const *table, size_t column_index)
Default filtering predicate.
Definition: table_column_iterator.h:636
size_t absolute_size() const
Computes the total number of fields in the table.
Definition: table_column_iterator.h:523
static constexpr unsigned long DEFAULTS
Default set of options.
Definition: table_column_iterator.h:118
ExclusionFilter m_filtering_predicate
ExclusionFiltering predicate to be invoked when determining if a column is to be included in the iter...
Definition: table_column_iterator.h:441
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 fil...
MY_BITMAP m_excluded_fields_bitmap
Bitmap that holds the information about which columns from the local table are to be excluded from th...
Definition: table_column_iterator.h:453
unsigned long m_options
Set of options to apply to view behaviour.
Definition: table_column_iterator.h:457
size_t filtered_size() const
Computes the total number of fields after filtering.
Definition: table_column_iterator.h:529
Table_columns_view(const Table_columns_view &rhs)=delete
int field_index(const char *field_name)
Definition: rules_table_service.cc:151
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
static void bitmap_set_all(MY_BITMAP *map)
Definition: my_bitmap.h:127
static bool bitmap_is_set(const MY_BITMAP *map, uint bit)
Definition: my_bitmap.h:94
bool bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits)
Definition: my_bitmap.cc:139
static void bitmap_clear_bit(MY_BITMAP *map, uint bit)
Definition: my_bitmap.h:89
void bitmap_free(MY_BITMAP *map)
Definition: my_bitmap.cc:157
static void bitmap_set_bit(MY_BITMAP *map, uint bit)
Definition: my_bitmap.h:79
static PFS_engine_table_share_proxy table
Definition: pfs.cc:60
Definition: options.cc:56
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:41
required string type
Definition: replication_group_member_actions.proto:33
Definition: my_bitmap.h:42
my_bitmap_map * bitmap
Definition: my_bitmap.h:43
uint fields
Definition: table.h:836
Field ** vfield
Pointer to generated columns.
Definition: table.h:1497
TABLE_SHARE * s
Definition: table.h:1395