MCPcopy Create free account
hub / github.com/apache/datafusion / read_to_delimited_chunks

Method read_to_delimited_chunks

datafusion/datasource-csv/src/file_format.rs:143–169  ·  view source on GitHub ↗

Return a newline delimited stream from the specified file on Stream, decompressing if necessary Each returned `Bytes` has a whole number of newline delimited rows

(
        &self,
        store: &Arc<dyn ObjectStore>,
        object: &ObjectMeta,
    )

Source from the content-addressed store, hash-verified

141 /// Stream, decompressing if necessary
142 /// Each returned `Bytes` has a whole number of newline delimited rows
143 async fn read_to_delimited_chunks<'a>(
144 &self,
145 store: &Arc<dyn ObjectStore>,
146 object: &ObjectMeta,
147 ) -> BoxStream<'a, Result<Bytes>> {
148 // stream to only read as many rows as needed into memory
149 let stream = store
150 .get(&object.location)
151 .await
152 .map_err(|e| DataFusionError::ObjectStore(Box::new(e)));
153 let stream = match stream {
154 Ok(stream) => self
155 .read_to_delimited_chunks_from_stream(
156 stream
157 .into_stream()
158 .map_err(|e| DataFusionError::ObjectStore(Box::new(e)))
159 .boxed(),
160 )
161 .await
162 .map_err(DataFusionError::from)
163 .left_stream(),
164 Err(e) => {
165 futures::stream::once(futures::future::ready(Err(e))).right_stream()
166 }
167 };
168 stream.boxed()
169 }
170
171 /// Convert a stream of bytes into a stream of of [`Bytes`] containing newline
172 /// delimited CSV records, while accounting for `\` and `"`.

Callers 1

infer_schemaMethod · 0.80

Calls 6

newFunction · 0.85
left_streamMethod · 0.80
right_streamMethod · 0.80
getMethod · 0.45
into_streamMethod · 0.45

Tested by

no test coverage detected