| 41 | } |
| 42 | |
| 43 | Status CopyStream(const std::shared_ptr<io::InputStream>& src, |
| 44 | const std::shared_ptr<io::OutputStream>& dest, int64_t chunk_size, |
| 45 | const io::IOContext& io_context) { |
| 46 | ARROW_ASSIGN_OR_RAISE(auto chunk, AllocateBuffer(chunk_size, io_context.pool())); |
| 47 | |
| 48 | while (true) { |
| 49 | ARROW_ASSIGN_OR_RAISE(int64_t bytes_read, |
| 50 | src->Read(chunk_size, chunk->mutable_data())); |
| 51 | if (bytes_read == 0) { |
| 52 | // EOF |
| 53 | break; |
| 54 | } |
| 55 | RETURN_NOT_OK(dest->Write(chunk->data(), bytes_read)); |
| 56 | } |
| 57 | |
| 58 | return Status::OK(); |
| 59 | } |
| 60 | |
| 61 | Status PathNotFound(std::string_view path) { |
| 62 | return Status::IOError("Path does not exist '", path, "'") |