vortex_datafusion/persistent/
reader.rs1use std::fmt::Debug;
8use std::sync::Arc;
9
10use datafusion_common::Result as DFResult;
11use datafusion_datasource::PartitionedFile;
12use object_store::ObjectStore;
13use vortex::io::VortexReadAt;
14use vortex::io::object_store::ObjectStoreReadAt;
15use vortex::io::session::RuntimeSessionExt;
16use vortex::session::VortexSession;
17
18pub trait VortexReaderFactory: Debug + Send + Sync + 'static {
20 fn create_reader(
22 &self,
23 file: &PartitionedFile,
24 session: &VortexSession,
25 ) -> DFResult<Arc<dyn VortexReadAt>>;
26}
27
28#[derive(Debug)]
31pub struct DefaultVortexReaderFactory {
32 object_store: Arc<dyn ObjectStore>,
33}
34
35impl DefaultVortexReaderFactory {
36 pub fn new(object_store: Arc<dyn ObjectStore>) -> Self {
38 Self { object_store }
39 }
40}
41
42impl VortexReaderFactory for DefaultVortexReaderFactory {
43 fn create_reader(
44 &self,
45 file: &PartitionedFile,
46 session: &VortexSession,
47 ) -> DFResult<Arc<dyn VortexReadAt>> {
48 Ok(Arc::new(ObjectStoreReadAt::new(
49 self.object_store.clone(),
50 file.path().as_ref().into(),
51 session.handle(),
52 )) as _)
53 }
54}