diff --git a/core/src/layers/type_eraser.rs b/core/src/layers/type_eraser.rs index aa7e0ea8741..72eee9d0e58 100644 --- a/core/src/layers/type_eraser.rs +++ b/core/src/layers/type_eraser.rs @@ -88,7 +88,7 @@ impl LayeredAccess for TypeEraseAccessor { fn blocking_read(&self, path: &str, args: OpRead) -> Result<(RpRead, Self::BlockingReader)> { self.inner .blocking_read(path, args) - .map(|(rp, r)| (rp, Box::new(r) as oio::BlockingReader)) + .map(|(rp, r)| (rp, Arc::new(r) as oio::BlockingReader)) } fn blocking_write(&self, path: &str, args: OpWrite) -> Result<(RpWrite, Self::BlockingWriter)> { diff --git a/core/src/raw/oio/read/api.rs b/core/src/raw/oio/read/api.rs index 01d2d0c9d3f..99123a8dd5e 100644 --- a/core/src/raw/oio/read/api.rs +++ b/core/src/raw/oio/read/api.rs @@ -155,8 +155,8 @@ impl Read for Arc { } } -/// BlockingReader is a boxed dyn `BlockingRead`. -pub type BlockingReader = Box; +/// BlockingReader is a arc dyn `BlockingRead`. +pub type BlockingReader = Arc; /// Read is the trait that OpenDAL returns to callers. pub trait BlockingRead: Send + Sync { @@ -199,9 +199,9 @@ impl BlockingRead for Buffer { } } -/// `Box` won't implement `BlockingRead` automatically. +/// `Arc` won't implement `BlockingRead` automatically. /// To make BlockingReader work as expected, we must add this impl. -impl BlockingRead for Box { +impl BlockingRead for Arc { fn read_at(&self, offset: u64, limit: usize) -> Result { (**self).read_at(offset, limit) } diff --git a/core/src/types/blocking_read/blocking_reader.rs b/core/src/types/blocking_read/blocking_reader.rs index 49a5ee2dcdb..e87528fceab 100644 --- a/core/src/types/blocking_read/blocking_reader.rs +++ b/core/src/types/blocking_read/blocking_reader.rs @@ -22,7 +22,6 @@ use std::ops::RangeBounds; use bytes::Buf; use bytes::BufMut; -use crate::raw::oio::BlockingRead; use crate::raw::*; use crate::*;