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

Method reader

datafusion/catalog/src/stream.rs:184–204  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

182 }
183
184 fn reader(&self) -> Result<Box<dyn RecordBatchReader>> {
185 let file = File::open(&self.location)?;
186 let schema = Arc::clone(&self.schema);
187 match &self.encoding {
188 StreamEncoding::Csv => {
189 let reader = arrow::csv::ReaderBuilder::new(schema)
190 .with_header(self.header)
191 .with_batch_size(self.batch_size)
192 .build(file)?;
193
194 Ok(Box::new(reader))
195 }
196 StreamEncoding::Json => {
197 let reader = arrow::json::ReaderBuilder::new(schema)
198 .with_batch_size(self.batch_size)
199 .build(BufReader::new(file))?;
200
201 Ok(Box::new(reader))
202 }
203 }
204 }
205
206 fn writer(&self) -> Result<Box<dyn RecordBatchWriter>> {
207 match &self.encoding {

Callers 4

infer_schemaMethod · 0.80
openMethod · 0.80
executeMethod · 0.80

Calls 4

newFunction · 0.85
buildMethod · 0.45
with_batch_sizeMethod · 0.45
with_headerMethod · 0.45

Tested by

no test coverage detected