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

impl Decoder[src]

pub fn new(
    schema: SchemaRef,
    batch_size: usize,
    projection: Option<Vec<String>>
) -> Self
[src]

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

pub fn schema(&self) -> SchemaRef[src]

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

pub fn next_batch<I>(&self, value_iter: &mut I) -> Result<Option<RecordBatch>> where
    I: Iterator<Item = Result<Value>>, 
[src]

Read the next batch of records

Trait Implementations

impl Debug for Decoder[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl RefUnwindSafe for Decoder

impl Send for Decoder

impl Sync for Decoder

impl Unpin for Decoder

impl UnwindSafe for Decoder

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V