pub struct DataSet {
pub schema: Schema,
pub rows: Vec<Vec<Value>>,
}Expand description
In-memory tabular dataset.
Rows are stored as Vec<Vec<Value>> in the same order as the Schema fields.
Fields§
§schema: SchemaSchema describing row shape.
rows: Vec<Vec<Value>>Row-major value storage.
Implementations§
Source§impl DataSet
impl DataSet
Sourcepub fn new(schema: Schema, rows: Vec<Vec<Value>>) -> Self
pub fn new(schema: Schema, rows: Vec<Vec<Value>>) -> Self
Create a dataset from schema and rows.
Sourcepub fn filter_rows<F>(&self, predicate: F) -> Self
pub fn filter_rows<F>(&self, predicate: F) -> Self
Create a new dataset containing only rows that match predicate.
The returned dataset preserves the original schema.
Sourcepub fn map_rows<F>(&self, mapper: F) -> Self
pub fn map_rows<F>(&self, mapper: F) -> Self
Create a new dataset by applying mapper to every row.
The returned dataset preserves the original schema.
§Panics
Panics if mapper returns a row with a different length than the schema field count.
Sourcepub fn reduce_rows<A, F>(&self, init: A, reducer: F) -> A
pub fn reduce_rows<A, F>(&self, init: A, reducer: F) -> A
Reduce (fold) all rows into an accumulator value.
This is similar to Iterator::fold, but provides each row as &[Value].
Trait Implementations§
Source§impl<'de> Deserialize<'de> for DataSet
impl<'de> Deserialize<'de> for DataSet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for DataSet
Auto Trait Implementations§
impl Freeze for DataSet
impl RefUnwindSafe for DataSet
impl Send for DataSet
impl Sync for DataSet
impl Unpin for DataSet
impl UnwindSafe for DataSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more