| 1510 | } |
| 1511 | |
| 1512 | Result<int64_t> ReadAt(int64_t position, int64_t nbytes, void* out) override { |
| 1513 | RETURN_NOT_OK(CheckClosed()); |
| 1514 | RETURN_NOT_OK(CheckPosition(position, "read")); |
| 1515 | |
| 1516 | nbytes = std::min(nbytes, content_length_ - position); |
| 1517 | if (nbytes == 0) { |
| 1518 | return 0; |
| 1519 | } |
| 1520 | |
| 1521 | // Read the desired range of bytes |
| 1522 | ARROW_ASSIGN_OR_RAISE(auto client_lock, holder_->Lock()); |
| 1523 | ARROW_ASSIGN_OR_RAISE(S3Model::GetObjectResult result, |
| 1524 | GetObjectRange(client_lock.get(), path_, sse_customer_key_, |
| 1525 | position, nbytes, out)); |
| 1526 | |
| 1527 | auto& stream = result.GetBody(); |
| 1528 | stream.ignore(nbytes); |
| 1529 | // NOTE: the stream is a stringstream by default, there is no actual error |
| 1530 | // to check for. However, stream.fail() may return true if EOF is reached. |
| 1531 | return stream.gcount(); |
| 1532 | } |
| 1533 | |
| 1534 | Result<std::shared_ptr<Buffer>> ReadAt(int64_t position, int64_t nbytes) override { |
| 1535 | RETURN_NOT_OK(CheckClosed()); |