bitmap_and

description

Syntax

BITMAP BITMAP_AND(BITMAP lhs, BITMAP rhs, ...)

Compute intersection of two or more input bitmaps, return the new bitmap.

example

  1. mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(2))) cnt;
  2. +------+
  3. | cnt |
  4. +------+
  5. | 0 |
  6. +------+
  7. mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt;
  8. +------+
  9. | cnt |
  10. +------+
  11. | 1 |
  12. +------+
  13. MySQL> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1)));
  14. +----------------------------------------------------------+
  15. | bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))) |
  16. +----------------------------------------------------------+
  17. | 1 |
  18. +----------------------------------------------------------+
  19. MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')));
  20. +-----------------------------------------------------------------------------------------------------------------------+
  21. | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) |
  22. +-----------------------------------------------------------------------------------------------------------------------+
  23. | 1,2 |
  24. +-----------------------------------------------------------------------------------------------------------------------+
  25. MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()));
  26. +---------------------------------------------------------------------------------------------------------------------------------------+
  27. | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) |
  28. +---------------------------------------------------------------------------------------------------------------------------------------+
  29. | |
  30. +---------------------------------------------------------------------------------------------------------------------------------------+
  31. MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL));
  32. +-----------------------------------------------------------------------------------------------------------------------------+
  33. | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) |
  34. +-----------------------------------------------------------------------------------------------------------------------------+
  35. | NULL |
  36. +-----------------------------------------------------------------------------------------------------------------------------+

keyword

  1. BITMAP_AND,BITMAP