| 408 | } |
| 409 | |
| 410 | Result<std::shared_ptr<Buffer>> OptionalBitmapAnd(MemoryPool* pool, |
| 411 | const std::shared_ptr<Buffer>& left, |
| 412 | int64_t left_offset, |
| 413 | const std::shared_ptr<Buffer>& right, |
| 414 | int64_t right_offset, int64_t length, |
| 415 | int64_t out_offset) { |
| 416 | if (left == nullptr && right == nullptr) { |
| 417 | return nullptr; |
| 418 | } |
| 419 | if (left == nullptr) { |
| 420 | if (right_offset >= out_offset && (right_offset - out_offset) % 8 == 0) { |
| 421 | int64_t byte_shift = (right_offset - out_offset) / 8; |
| 422 | int64_t byte_length = bit_util::BytesForBits(out_offset + length); |
| 423 | return SliceBuffer(right, byte_shift, byte_length); |
| 424 | } |
| 425 | return CopyBitmap(pool, right->data(), right_offset, length, out_offset); |
| 426 | } |
| 427 | if (right == nullptr) { |
| 428 | if (left_offset >= out_offset && (left_offset - out_offset) % 8 == 0) { |
| 429 | int64_t byte_shift = (left_offset - out_offset) / 8; |
| 430 | int64_t byte_length = bit_util::BytesForBits(out_offset + length); |
| 431 | return SliceBuffer(left, byte_shift, byte_length); |
| 432 | } |
| 433 | return CopyBitmap(pool, left->data(), left_offset, length, out_offset); |
| 434 | } |
| 435 | |
| 436 | return BitmapAnd(pool, left->data(), left_offset, right->data(), right_offset, length, |
| 437 | out_offset); |
| 438 | } |
| 439 | |
| 440 | namespace { |
| 441 |
no test coverage detected