diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2009-08-13 02:34:21 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2009-08-13 02:34:21 +0400 |
commit | 854bb82bd81afa6decc436b9ecf6af4954efebe5 (patch) | |
tree | fce26373e6bb62ae4ab4f3e1fc922d53145deb8b /sql/sql_bitmap.h | |
parent | 5ecad03df9eef6e4d68cc7767b684944384e084e (diff) | |
download | mariadb-git-854bb82bd81afa6decc436b9ecf6af4954efebe5.tar.gz |
MWL#17: Table elimination
Address review feedback:
- Change from Wave-based approach (a-la const table detection) to
building and walking functional dependency graph.
- Change from piggy-backing on ref-access code and KEYUSE structures
to using our own expression analyzer.
sql/item.cc:
MWL#17: Table elimination
- Move from C-ish Field_processor_info to C++ ish and generic Field_enumerator
sql/item.h:
MWL#17: Table elimination
- Move from C-ish Field_processor_info to C++ ish and generic Field_enumerator
sql/sql_bitmap.h:
MWL#17: Table elimination
- Backport of Table_map_iterator from 6.0
Diffstat (limited to 'sql/sql_bitmap.h')
-rw-r--r-- | sql/sql_bitmap.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h index 97accefe8aa..e07806a56ab 100644 --- a/sql/sql_bitmap.h +++ b/sql/sql_bitmap.h @@ -93,6 +93,34 @@ public: } }; +/* An iterator to quickly walk over bits in unlonglong bitmap. */ +class Table_map_iterator +{ + ulonglong bmp; + uint no; +public: + Table_map_iterator(ulonglong t) : bmp(t), no(0) {} + int next_bit() + { + static const char last_bit[16]= {32, 0, 1, 0, + 2, 0, 1, 0, + 3, 0, 1, 0, + 2, 0, 1, 0}; + uint bit; + while ((bit= last_bit[bmp & 0xF]) == 32) + { + no += 4; + bmp= bmp >> 4; + if (!bmp) + return BITMAP_END; + } + bmp &= ~(1LL << bit); + return no + bit; + } + int operator++(int) { return next_bit(); } + enum { BITMAP_END= 64 }; +}; + template <> class Bitmap<64> { ulonglong map; @@ -136,5 +164,10 @@ public: my_bool operator==(const Bitmap<64>& map2) const { return map == map2.map; } char *print(char *buf) const { longlong2str(map,buf,16); return buf; } ulonglong to_ulonglong() const { return map; } + class Iterator : public Table_map_iterator + { + public: + Iterator(Bitmap<64> &bmp) : Table_map_iterator(bmp.map) {} + }; }; |