Struct arrow::json::reader::Decoder[][src]

pub struct Decoder { /* fields omitted */ }
Expand description

JSON values to Arrow record batch decoder. Decoder’s next_batch method takes a JSON Value iterator as input and outputs Arrow record batch.

Examples

use arrow::json::reader::{Decoder, ValueIter, infer_json_schema};
use std::fs::File;
use std::io::{BufReader, Seek, SeekFrom};
use std::sync::Arc;

let mut reader =
    BufReader::new(File::open("test/data/mixed_arrays.json").unwrap());
let inferred_schema = infer_json_schema(&mut reader, None).unwrap();
let batch_size = 1024;
let decoder = Decoder::new(Arc::new(inferred_schema), batch_size, None);

// seek back to start so that the original file is usable again
reader.seek(SeekFrom::Start(0)).unwrap();
let mut value_reader = ValueIter::new(&mut reader, None);
let batch = decoder.next_batch(&mut value_reader).unwrap().unwrap();
assert_eq!(4, batch.num_rows());
assert_eq!(4, batch.num_columns());

Implementations

Create a new JSON decoder from any value that implements the Iterator<Item=Result<Value>> trait.

Returns the schema of the reader, useful for getting the schema without reading record batches

Read the next batch of records

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.