| 386 | } |
| 387 | |
| 388 | Result<int64_t> Read(int64_t nbytes, void* out) { |
| 389 | auto* out_data = reinterpret_cast<uint8_t*>(out); |
| 390 | |
| 391 | int64_t total_read = 0; |
| 392 | bool decompressor_has_data = true; |
| 393 | |
| 394 | while (nbytes - total_read > 0 && decompressor_has_data) { |
| 395 | total_read += ReadFromDecompressed(nbytes - total_read, out_data + total_read); |
| 396 | |
| 397 | if (nbytes == total_read) { |
| 398 | break; |
| 399 | } |
| 400 | |
| 401 | // At this point, no more decompressed data remains, so we need to |
| 402 | // decompress more |
| 403 | ARROW_ASSIGN_OR_RAISE(decompressor_has_data, RefillDecompressed()); |
| 404 | } |
| 405 | |
| 406 | total_pos_ += total_read; |
| 407 | return total_read; |
| 408 | } |
| 409 | |
| 410 | Result<std::shared_ptr<Buffer>> Read(int64_t nbytes) { |
| 411 | ARROW_ASSIGN_OR_RAISE(auto buf, AllocateResizableBuffer(nbytes, pool_)); |
no test coverage detected