Skip to main content

RecordSource

Struct RecordSource 

Source
pub struct RecordSource<I> { /* private fields */ }
Expand description

Rows from a stream of JSON records.

The source reads the first sample records ahead: their keys, in the order first seen, are the columns, and their values decide the schema (integer and float widen to float; disagreeing types become any; a key some records lack, or that holds null, is nullable). A record that is not an object is one value column. Scalars become cells as they are (true/false as text, since Value has no boolean; whole numbers in a float column as floats), and arrays and objects become their compact JSON text.

Keys first seen after the sample have no column; their values are dropped and their names kept in unknown_keys, so a caller can say so: the first MAX_UNKNOWN_KEYS of them, so a stream whose every record has a new key stays bounded (more_unknown_keys says there were more). Read everything at once (the adapters’ read) to sample every record.

Implementations§

Source§

impl<I> RecordSource<I>
where I: Iterator<Item = Result<Value, DataError>>,

Source

pub fn unknown_keys(&self) -> impl Iterator<Item = &str>

Keys seen after the sample, which have no column (so far): the first MAX_UNKNOWN_KEYS seen, sorted.

Source

pub fn more_unknown_keys(&self) -> bool

Whether more keys than unknown_keys holds were seen after the sample.

Trait Implementations§

Source§

impl<I: Debug> Debug for RecordSource<I>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<I> RowSource for RecordSource<I>
where I: Iterator<Item = Result<Value, DataError>>,

Source§

fn columns(&self) -> &[String]

The column names, in order.
Source§

fn schema(&self) -> Option<&Schema>

What the source knows about the columns’ types, if anything. A source’s schema has one field per column, in the same order.
Source§

fn next_row(&mut self) -> Option<Result<Row, DataError>>

The next row, None at the end, or why it could not be read.
Source§

fn collect_rows(self) -> Result<Rows, DataError>
where Self: Sized,

Read every remaining row into memory.

Auto Trait Implementations§

§

impl<I> Freeze for RecordSource<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for RecordSource<I>
where I: RefUnwindSafe,

§

impl<I> Send for RecordSource<I>
where I: Send,

§

impl<I> Sync for RecordSource<I>
where I: Sync,

§

impl<I> Unpin for RecordSource<I>
where I: Unpin,

§

impl<I> UnsafeUnpin for RecordSource<I>
where I: UnsafeUnpin,

§

impl<I> UnwindSafe for RecordSource<I>
where I: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.