Skip to content

Commit 5d9f49b

Browse files
committed
feat(core/types): change oio::BlockingReader to Arc<dyn oio::BlockingRead>
1 parent 63e061a commit 5d9f49b

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

core/src/layers/type_eraser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<A: Access> LayeredAccess for TypeEraseAccessor<A> {
8888
fn blocking_read(&self, path: &str, args: OpRead) -> Result<(RpRead, Self::BlockingReader)> {
8989
self.inner
9090
.blocking_read(path, args)
91-
.map(|(rp, r)| (rp, Box::new(r) as oio::BlockingReader))
91+
.map(|(rp, r)| (rp, Arc::new(r) as oio::BlockingReader))
9292
}
9393

9494
fn blocking_write(&self, path: &str, args: OpWrite) -> Result<(RpWrite, Self::BlockingWriter)> {

core/src/raw/oio/read/api.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ impl<T: ReadDyn + ?Sized> Read for Arc<T> {
155155
}
156156
}
157157

158-
/// BlockingReader is a boxed dyn `BlockingRead`.
159-
pub type BlockingReader = Box<dyn BlockingRead>;
158+
/// BlockingReader is a arc dyn `BlockingRead`.
159+
pub type BlockingReader = Arc<dyn BlockingRead>;
160160

161161
/// Read is the trait that OpenDAL returns to callers.
162162
pub trait BlockingRead: Send + Sync {
@@ -199,9 +199,9 @@ impl BlockingRead for Buffer {
199199
}
200200
}
201201

202-
/// `Box<dyn BlockingRead>` won't implement `BlockingRead` automatically.
202+
/// `Arc<dyn BlockingRead>` won't implement `BlockingRead` automatically.
203203
/// To make BlockingReader work as expected, we must add this impl.
204-
impl<T: BlockingRead + ?Sized> BlockingRead for Box<T> {
204+
impl<T: BlockingRead + ?Sized> BlockingRead for Arc<T> {
205205
fn read_at(&self, offset: u64, limit: usize) -> Result<Buffer> {
206206
(**self).read_at(offset, limit)
207207
}

core/src/types/blocking_read/blocking_reader.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use std::ops::RangeBounds;
2222
use bytes::Buf;
2323
use bytes::BufMut;
2424

25-
use crate::raw::oio::BlockingRead;
2625
use crate::raw::*;
2726
use crate::*;
2827

0 commit comments

Comments
 (0)