diff --git a/core/src/types/blocking_read/blocking_reader.rs b/core/src/types/blocking_read/blocking_reader.rs index 49a5ee2dcdbc..5ac8d6969e8d 100644 --- a/core/src/types/blocking_read/blocking_reader.rs +++ b/core/src/types/blocking_read/blocking_reader.rs @@ -18,18 +18,18 @@ use std::collections::Bound; use std::ops::Range; use std::ops::RangeBounds; +use std::sync::Arc; use bytes::Buf; use bytes::BufMut; -use crate::raw::oio::BlockingRead; use crate::raw::*; use crate::*; /// BlockingReader is designed to read data from given path in an blocking /// manner. pub struct BlockingReader { - pub(crate) inner: oio::BlockingReader, + pub(crate) inner: Arc, } impl BlockingReader { @@ -43,7 +43,7 @@ impl BlockingReader { pub(crate) fn create(acc: Accessor, path: &str, op: OpRead) -> crate::Result { let (_, r) = acc.blocking_read(path, op)?; - Ok(BlockingReader { inner: r }) + Ok(BlockingReader { inner: Arc::new(r) }) } /// Read give range from reader into [`Buffer`]. diff --git a/core/src/types/blocking_read/std_bytes_iterator.rs b/core/src/types/blocking_read/std_bytes_iterator.rs index dba05ae734f2..dc9e75a5a00a 100644 --- a/core/src/types/blocking_read/std_bytes_iterator.rs +++ b/core/src/types/blocking_read/std_bytes_iterator.rs @@ -16,6 +16,7 @@ // under the License. use std::io; +use std::sync::Arc; use bytes::Buf; use bytes::Bytes; @@ -28,7 +29,7 @@ use crate::raw::*; /// /// StdIterator also implements [`Send`] and [`Sync`]. pub struct StdBytesIterator { - inner: oio::BlockingReader, + inner: Arc, offset: u64, size: u64, cap: usize, @@ -39,7 +40,7 @@ pub struct StdBytesIterator { impl StdBytesIterator { /// NOTE: don't allow users to create StdIterator directly. #[inline] - pub(crate) fn new(r: oio::BlockingReader, range: std::ops::Range) -> Self { + pub(crate) fn new(r: Arc, range: std::ops::Range) -> Self { StdBytesIterator { inner: r, offset: range.start, diff --git a/core/src/types/blocking_read/std_reader.rs b/core/src/types/blocking_read/std_reader.rs index 191eeb1fbbc3..b7d4f439b3e5 100644 --- a/core/src/types/blocking_read/std_reader.rs +++ b/core/src/types/blocking_read/std_reader.rs @@ -21,6 +21,7 @@ use std::io::Read; use std::io::Seek; use std::io::SeekFrom; use std::ops::Range; +use std::sync::Arc; use bytes::Buf; @@ -33,7 +34,7 @@ use crate::*; /// /// StdReader also implements [`Send`] and [`Sync`]. pub struct StdReader { - inner: oio::BlockingReader, + inner: Arc, offset: u64, size: u64, cap: usize, @@ -45,7 +46,7 @@ pub struct StdReader { impl StdReader { /// NOTE: don't allow users to create StdReader directly. #[inline] - pub(super) fn new(r: oio::BlockingReader, range: Range) -> Self { + pub(super) fn new(r: Arc, range: Range) -> Self { StdReader { inner: r, offset: range.start,