| 378 | } |
| 379 | |
| 380 | BitBlockCount NextOrNotBlock() { |
| 381 | static constexpr int64_t kMaxBlockSize = std::numeric_limits<int16_t>::max(); |
| 382 | switch (has_bitmap_) { |
| 383 | case HasBitmap::BOTH: { |
| 384 | BitBlockCount block = binary_counter_.NextOrNotWord(); |
| 385 | position_ += block.length; |
| 386 | return block; |
| 387 | } |
| 388 | case HasBitmap::ONE: { |
| 389 | BitBlockCount block = unary_counter_.NextWord(); |
| 390 | position_ += block.length; |
| 391 | return block; |
| 392 | } |
| 393 | case HasBitmap::NONE: |
| 394 | default: { |
| 395 | const int16_t block_size = |
| 396 | static_cast<int16_t>(std::min(kMaxBlockSize, length_ - position_)); |
| 397 | position_ += block_size; |
| 398 | // All values are non-null |
| 399 | return {block_size, block_size}; |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | private: |
| 405 | enum class HasBitmap : int { BOTH, ONE, NONE }; |