| 1570 | } |
| 1571 | |
| 1572 | Result<int64_t> ReadAt(int64_t position, int64_t nbytes, void* out) override { |
| 1573 | RETURN_NOT_OK(CheckClosed()); |
| 1574 | RETURN_NOT_OK(CheckPosition(position, "read")); |
| 1575 | |
| 1576 | nbytes = std::min(nbytes, content_length_ - position); |
| 1577 | if (nbytes == 0) { |
| 1578 | return 0; |
| 1579 | } |
| 1580 | |
| 1581 | // Read the desired range of bytes |
| 1582 | ARROW_ASSIGN_OR_RAISE(auto client_lock, holder_->Lock()); |
| 1583 | ARROW_ASSIGN_OR_RAISE(S3Model::GetObjectResult result, |
| 1584 | GetObjectRange(client_lock.get(), path_, sse_customer_key_, |
| 1585 | position, nbytes, out)); |
| 1586 | |
| 1587 | auto& stream = result.GetBody(); |
| 1588 | stream.ignore(nbytes); |
| 1589 | // NOTE: the stream is a stringstream by default, there is no actual error |
| 1590 | // to check for. However, stream.fail() may return true if EOF is reached. |
| 1591 | return stream.gcount(); |
| 1592 | } |
| 1593 | |
| 1594 | Result<std::shared_ptr<Buffer>> ReadAt(int64_t position, int64_t nbytes) override { |
| 1595 | RETURN_NOT_OK(CheckClosed()); |