Skip to content

Tracking issues of OpenDAL API changes #356

@Xuanwo

Description

@Xuanwo

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::Reader adopts zero-cost abstraction, no extra bytes copy and allocation happened.
  • opendal::FuturesAsyncReader is 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.

I believe only read side needs to do some changes. write side should be simple to update.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions