| 71 | |
| 72 | impl FileOpener for ArrowStreamFileOpener { |
| 73 | fn open(&self, partitioned_file: PartitionedFile) -> Result<FileOpenFuture> { |
| 74 | if partitioned_file.range.is_some() { |
| 75 | return Err(exec_datafusion_err!( |
| 76 | "ArrowStreamFileOpener does not support range-based reading" |
| 77 | )); |
| 78 | } |
| 79 | let object_store = Arc::clone(&self.object_store); |
| 80 | let projection = self.projection.clone(); |
| 81 | |
| 82 | Ok(Box::pin(async move { |
| 83 | let r = object_store |
| 84 | .get(&partitioned_file.object_meta.location) |
| 85 | .await?; |
| 86 | |
| 87 | let stream = match r.payload { |
| 88 | #[cfg(not(target_arch = "wasm32"))] |
| 89 | GetResultPayload::File(file, _) => futures::stream::iter( |
| 90 | StreamReader::try_new(file.try_clone()?, projection.clone())?, |
| 91 | ) |
| 92 | .map(|r| r.map_err(Into::into)) |
| 93 | .boxed(), |
| 94 | GetResultPayload::Stream(_) => { |
| 95 | let bytes = r.bytes().await?; |
| 96 | let cursor = Cursor::new(bytes); |
| 97 | futures::stream::iter(StreamReader::try_new( |
| 98 | cursor, |
| 99 | projection.clone(), |
| 100 | )?) |
| 101 | .map(|r| r.map_err(Into::into)) |
| 102 | .boxed() |
| 103 | } |
| 104 | }; |
| 105 | |
| 106 | Ok(stream) |
| 107 | })) |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | /// `FileOpener` for Arrow IPC file format. Supports range-based parallel reading. |