Getting Started with Ropendal

Ropendal presents one central object, OpendalFs, and an explicit rule: every operation is expressed as a call that returns plain values and explicit errors.

A local filesystem handle is the simplest entry point. Paths are normalized to be relative to root at the handle level.

library(Ropendal)

root <- file.path(tempdir(), "ropendal-quickstart")
unlink(root, recursive = TRUE)
dir.create(root, recursive = TRUE)

fs <- opendal("fs", root = root)

fs_write(fs, "message.txt", charToRaw("hello ropendal\n"))
#> [1] TRUE
raw <- fs_read(fs, "message.txt")
rawToChar(raw)
#> [1] "hello ropendal\n"

stat <- fs_stat(fs, "message.txt")
stat[c("path", "type", "size")]
#> $path
#> [1] "message.txt"
#> 
#> $type
#> [1] "file"
#> 
#> $size
#> [1] 15

listing <- fs_ls(fs)
vapply(listing, `[[`, character(1), "path")
#> [1] "message.txt"

Aio pattern with the same API

Async operations reuse the same shape (path, mode, config, etc.) and return an OpendalAio handle that you can wait for or poll.

aio <- fs_read_aio(fs, "message.txt")
call_aio(aio)
aio$value
#>  [1] 68 65 6c 6c 6f 20 72 6f 70 65 6e 64 61 6c 0a

collect_aio() waits and returns a value, while the active binding contract means the Aio object is also inspectable while pending.

io <- fs_stat_aio(fs, "message.txt")
unresolved(io$value)
#> [1] FALSE
res <- collect_aio(io)
res$size
#> [1] 15