houqp commented on a change in pull request #1556:
URL: https://github.com/apache/arrow-datafusion/pull/1556#discussion_r785403949



##########
File path: datafusion/src/datasource/object_store/mod.rs
##########
@@ -33,6 +33,12 @@ use local::LocalFileSystem;
 
 use crate::error::{DataFusionError, Result};
 
+/// Both Read and Seek
+pub trait ReadSeek: Read + Seek {}
+
+impl<R: Read + Seek> ReadSeek for std::io::BufReader<R> {}
+impl<R: AsRef<[u8]>> ReadSeek for std::io::Cursor<R> {}

Review comment:
       Nice tip on the generic approach. @Igosuki is right that this is not 
needed for BufRead and Cursor, It's only needed for `std::fs::File`, so I will 
keep the generic form. Here is the build error I got without it:
   
   ```
   error[E0277]: the trait bound `std::fs::File: 
datasource::object_store::ReadSeek` is not satisfied
     --> datafusion/src/datasource/object_store/local.rs:82:12
      |
   82 |         Ok(Box::new(File::open(&self.file.path)?))
      |         -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait 
`datasource::object_store::ReadSeek` is not implemented for `std::fs::File`
      |         |
      |         required by a bound introduced by this call
      |
      = note: required for the cast to the object type `dyn 
datasource::object_store::ReadSeek + std::marker::Send + std::marker::Sync`
   
   ```




-- 
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]


Reply via email to