-
Notifications
You must be signed in to change notification settings - Fork 344
Description
Hi, iceberger! OpenDAL's coming v0.46 release will have API changes that could affect our project.
New Features
OpenDAL Reader now has concurrent support
OpenDAL Reader now has concurrent support that can read multiple chunks concurrently.
let r = op.reader_with("test.txt").concurrent(4).chunk(4 * 1024 * 1024).await?;
let buf = r.read(0..16 * 1024 * 1024).await?;The buf here will be fetched in 4 concurrent requests.
To read non-contiguous buffers, please use our fetch API:
let r = op.reader_with("test.txt").concurrent(4).chunk(4 * 1024 * 1024).await?;
let bufs = r.fetch(vec![0..1024 * 1024, 1024..3 * 1024 * 1024]).await?;OpenDAL will merge close ranges and read them concurrently.
The detailed upgrade guide could be found here.
OpenDAL v0.46 is not related yet so those changes are still possible to be altered. I will try my best to keep this issue update.
API Changes
I list the major changes that we need to take care:
OpenDAL Reader doens't impl AsyncRead + AsyncSeek anymore
OpenDAL's Reader now transformed into range based read.
let r = op.reader("test.txt").await?;
let buf = r.read(1024..2048).await?;Users can transform into AsyncRead + AsyncSeek by using into_futures_async_read:
let r = op.reader("test.txt").await?;
let reader: FuturesAsyncReader = r.into_futures_async_read(0..4096);But please note:
opendal::Readeradopts zero-cost abstraction, no extra bytes copy and allocation happened.opendal::FuturesAsyncReaderis the same as our old reader, it might have extra bytes copy.
OpenDAL Writer doens't impl AsyncWrite anymore
Just like Reader, opendal::Writer doesn't impl AsyncWrite anymore. Users could use opendal's native Buffer for both contiguous and non-contiguous buffers support.
let w = op.writer("test.txt").await?;
// Buffer can be created from continues bytes.
w.write("hello, world").await?;
// Buffer can also be created from non-continues bytes.
w.write(vec![Bytes::from("hello,"), Bytes::from("world!")]).await?;
// Make sure file has been written completely.
w.close().await?;Users can transform into AsyncWrite by using into_futures_async_write:
let w = op.writer("test.txt").await?;
let writer: FuturesAsyncWriter = r.into_futures_async_write();Tasks
Although it's possible to simply convert opendal's Reader and Writer into AsyncXxx-based structures, I aim to prepare Iceberg for the most efficient IO methods. In the near future, we will support compilation-based IO and vectorization. The AsyncXxx-based traits do not integrate well with these methods.
- feat: Extract FileRead and FileWrite trait #364
- Introduce concurrent read support
- Introduce concurrent write support
I believe only read side needs to do some changes. write side should be simple to update.