| 233 | } |
| 234 | |
| 235 | arrow::Result<int64_t> Tell() const override { |
| 236 | if (closed()) { |
| 237 | return arrow::Status::IOError("R connection is closed"); |
| 238 | } |
| 239 | |
| 240 | // R connections use seek() with no additional arguments as a tell() |
| 241 | // implementation; however, non-seekable connections will error if you |
| 242 | // do this. This heuristic allows Tell() to return a reasonable value |
| 243 | // (used by at least the IPC writer). |
| 244 | if (!seekable_ && bytes_written_ > 0) { |
| 245 | return bytes_written_; |
| 246 | } else if (!seekable_) { |
| 247 | return bytes_read_; |
| 248 | } |
| 249 | |
| 250 | return SafeCallIntoR<int64_t>( |
| 251 | [&]() { |
| 252 | cpp11::sexp result = cpp11::package("base")["seek"](connection_sexp_); |
| 253 | return cpp11::as_cpp<int64_t>(result); |
| 254 | }, |
| 255 | "tell() on R connection"); |
| 256 | } |
| 257 | |
| 258 | bool closed() const override { return closed_; } |
| 259 |
no test coverage detected