DatasetBuilder

Struct DatasetBuilder 

Source
pub struct DatasetBuilder<S: Schema> { /* private fields */ }
Expand description

Builder for a dataset in flat.

// Note, explicit type annotation included for clarity.
// We encourage consumers to allow the compiler to infer the type implicitly.
let builder: DatasetBuilder<Schema1<f64>> = DatasetBuilder::new(Schemas::one("dim1"));

Implementations§

Source§

impl<S: Schema> DatasetBuilder<S>

Source

pub fn new(schema: S) -> DatasetBuilder<S>

Build a dataset based for the provided schema.

Source

pub fn update(&mut self, vector: S::Dimensions)

Update this dataset with a data point vector. Use this method to add data via mutation.

See also: DatasetBuilder::add.

§Example
use flat::*;

let schema = Schemas::one("Things");
let mut builder = DatasetBuilder::new(schema);
builder.update((0, ));
builder.update((0, ));
builder.update((1, ));
let dataset = builder.build();
let view = dataset.count();

let flat = DagChart::new(&view)
    .render(Render::default());
assert_eq!(
    format!("\n{}", flat.to_string()),
    r#"
Things  |Sum(Count)
0       |**
1       |*"#);

let flat = Histogram::new(&view, 2)
    .render(Render::default());
assert_eq!(
    format!("\n{}", flat.to_string()),
    r#"
Things  |Sum(Count)
[0, 1)  |**
[1, 2]  |*"#);
Source

pub fn add(self, vector: S::Dimensions) -> Self

Add a data point vector to this dataset. Use this method to add via method chaining.

See also: DatasetBuilder::update.

§Example
use flat::*;

let schema = Schemas::one("Things");
let dataset = DatasetBuilder::new(schema)
    .add((0, ))
    .add((0, ))
    .add((1, ))
    .build();
let view = dataset.count();

let flat = DagChart::new(&view)
    .render(Render::default());
assert_eq!(
    format!("\n{}", flat.to_string()),
    r#"
Things  |Sum(Count)
0       |**
1       |*"#);

let flat = Histogram::new(&view, 2)
    .render(Render::default());
assert_eq!(
    format!("\n{}", flat.to_string()),
    r#"
Things  |Sum(Count)
[0, 1)  |**
[1, 2]  |*"#);
Source

pub fn build(self) -> Dataset<S>

Finalize the builder into a Dataset.

Auto Trait Implementations§

§

impl<S> Freeze for DatasetBuilder<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for DatasetBuilder<S>
where S: RefUnwindSafe, <S as Schema>::Dimensions: RefUnwindSafe,

§

impl<S> Send for DatasetBuilder<S>
where S: Send, <S as Schema>::Dimensions: Send,

§

impl<S> Sync for DatasetBuilder<S>
where S: Sync, <S as Schema>::Dimensions: Sync,

§

impl<S> Unpin for DatasetBuilder<S>
where S: Unpin, <S as Schema>::Dimensions: Unpin,

§

impl<S> UnwindSafe for DatasetBuilder<S>
where S: UnwindSafe, <S as Schema>::Dimensions: UnwindSafe,

Blanket Implementations§

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

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

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.