viirya commented on code in PR #1803:
URL: https://github.com/apache/arrow-rs/pull/1803#discussion_r890453518
##########
parquet/src/arrow/async_reader.rs:
##########
@@ -101,8 +103,63 @@ use crate::file::footer::parse_metadata_buffer;
use crate::file::metadata::ParquetMetaData;
use crate::file::reader::SerializedPageReader;
use crate::file::PARQUET_MAGIC;
-use crate::schema::types::{ColumnDescPtr, SchemaDescPtr};
-use crate::util::memory::ByteBufferPtr;
+use crate::schema::types::{ColumnDescPtr, SchemaDescPtr, SchemaDescriptor};
+
+/// A reader that can asynchronously read a range of bytes
+pub trait AsyncChunkReader: Send + Unpin + 'static {
+ /// Retrieve the bytes in `range`
+ fn get_bytes(&mut self, range: Range<usize>) -> BoxFuture<'_,
Result<Bytes>>;
+
+ /// Retrieve the [`ParquetMetaData`] for this file
+ fn get_metadata(&mut self) -> BoxFuture<'_, Result<Arc<ParquetMetaData>>>;
+}
+
+impl<T: AsyncRead + AsyncSeek + Unpin + Send + 'static> AsyncChunkReader for T
{
+ fn get_bytes(&mut self, range: Range<usize>) -> BoxFuture<'_,
Result<Bytes>> {
+ async move {
+ self.seek(SeekFrom::Start(range.start as u64)).await?;
Review Comment:
Hmm, as `get_bytes` and `get_metadata` both async, and they both call
`seek`. Is any chance there will be race condition between then? For example,
calling `get_bytes` first but the file pos is changed by call `get_metadata`
next?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]