Skip to main content

FieldData

Struct FieldData 

Source
pub struct FieldData<T> { /* private fields */ }
Expand description

Data vector containing the data for a single field (column) of an agnes data store.

To support NA / missing values, a FieldData object is internally represented as a Vec of the appropriate type, along with a bit mask to denote valid / missing values.

Implementations§

Source§

impl<T> FieldData<T>

Source

pub fn len(&self) -> usize

Returns the length of this data vector.

Source

pub fn is_empty(&self) -> bool

Returns true if this field contains no values.

Source

pub fn get(&self, index: usize) -> Option<Value<&T>>

Get the value at the given index. Returns None if index is out of bounds, or a Value enum.

Source

pub fn take(&mut self, index: usize) -> Option<Value<T>>
where T: Default,

Take the value at the given index. Returns None if index is out of bounds, or a Value enum. Replaces the taken value with Value::Na.

Source

pub fn as_vec(&self) -> Vec<Value<&T>>
where FieldData<T>: DataIndex<DType = T>,

Interpret FieldData as a Vec of Value objects.

Source

pub fn from_boxed_slice(orig: Box<[T]>) -> Self

Create a new FieldData from a slice. Does not clone or reallocate the contained data (but does allocate the bit mask). Resulting FieldData struct will have no Value::Na values.

Source§

impl<T> FieldData<T>

Source

pub fn from_vec<U: Into<T>>(v: Vec<U>) -> FieldData<T>

Create a FieldData struct from a vector of non-NA values. Resulting FieldData struct will have no Value::Na values.

Source§

impl<T> FieldData<T>
where T: Debug + Default,

Source

pub fn push_val(&mut self, value: Value<T>)

Add a new value (or an indication of a missing one) to the data vector.

Source§

impl<T> FieldData<T>
where T: Debug + Default + Clone,

Source

pub fn push_ref(&mut self, value: Value<&T>)

Add a new value (passed by reference) to the data vector.

Source

pub fn from_field_vec(v: Vec<Value<T>>) -> FieldData<T>

Create a FieldData struct from a vector of field values.

Trait Implementations§

Source§

impl<T: Clone> Clone for FieldData<T>

Source§

fn clone(&self) -> FieldData<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> DataIndex for FieldData<T>
where T: Debug,

Source§

type DType = T

The data type contained within this field.
Source§

fn get_datum(&self, idx: usize) -> Result<Value<&T>>

Returns the data (possibly NA) at the specified index, if it exists.
Source§

fn len(&self) -> usize

Returns the length of this data field.
Source§

fn is_empty(&self) -> bool

Returns whether or not this field is empty.
Source§

fn iter(&self) -> DataIterator<'_, Self::DType>
where Self: Sized,

Returns an iterator over the values in this field.
Source§

fn permute(self, permutation: &[usize]) -> Framed<Self::DType, Self>
where Self: Sized,

Returns a new DataIndex-implementing object which provides access to the values in this field as permuted by permutation. permutation is a slice of indices into this DataIndex.
Source§

fn to_vec(&self) -> Vec<Self::DType>
where Self: Sized, Self::DType: Clone,

Copies existing values in this field into a new Vec. Read more
Source§

fn to_value_vec(&self) -> Vec<Value<Self::DType>>
where Self: Sized, Self::DType: Clone,

Copies values (missing or existing) in this field into a new Vec.
Source§

impl<T> DataIndexMut for FieldData<T>
where T: Debug + Default,

Source§

fn push(&mut self, value: Value<Self::DType>)

Add a value to this field.
Source§

fn take_datum(&mut self, idx: usize) -> Result<Value<T>>
where T: Default,

Take the value at the specified index from this field, replacing it with an NA.
Source§

fn drain(&mut self) -> DrainIterator<'_, Self::DType>
where Self: Sized,

Returns a draining iterator of the vaules in this DataIndexMut.
Source§

impl<T: Debug> Debug for FieldData<T>

Source§

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

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

impl<T> Default for FieldData<T>

Source§

fn default() -> FieldData<T>

Returns the “default value” for a type. Read more
Source§

impl<T: Eq> Eq for FieldData<T>

Source§

impl<T> From<FieldData<T>> for DataRef<T>

Source§

fn from(orig: FieldData<T>) -> DataRef<T>

Converts to this type from the input type.
Source§

impl<T> From<FieldData<T>> for Framed<T, DataRef<T>>

Source§

fn from(orig: FieldData<T>) -> Framed<T, DataRef<T>>

Converts to this type from the input type.
Source§

impl<T> From<Vec<T>> for FieldData<T>

Source§

fn from(other: Vec<T>) -> FieldData<T>

Converts to this type from the input type.
Source§

impl<T> FromIterator<T> for FieldData<T>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<'a, T> FromIterator<Value<&'a T>> for FieldData<T>
where T: 'a + Debug + Default + Clone,

Source§

fn from_iter<I: IntoIterator<Item = Value<&'a T>>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T> FromIterator<Value<T>> for FieldData<T>
where T: Debug + Default,

Source§

fn from_iter<I: IntoIterator<Item = Value<T>>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: Hash> Hash for FieldData<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Label, T> IntoStore<Label> for FieldData<T>
where Label: Debug, T: Default + Debug,

Source§

type Output = DataStore<<DataStore<Nil> as PushFrontFromValueIter<Label, T>>::OutputFields>

The reulting DataStore object.
Source§

fn into_store(self) -> Self::Output

Wraps this field data in a DataStore and returns it.
Source§

impl<T: PartialEq> PartialEq for FieldData<T>

Source§

fn eq(&self, other: &FieldData<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> SelfValued for FieldData<T>

Source§

impl<T> Serialize for FieldData<T>
where T: Serialize,

Available on crate feature serialize only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for FieldData<T>

Source§

impl<T> Typed for FieldData<T>

Source§

type DType = T

Associated data type with this type.

Auto Trait Implementations§

§

impl<T> Freeze for FieldData<T>

§

impl<T> RefUnwindSafe for FieldData<T>
where T: RefUnwindSafe,

§

impl<T> Send for FieldData<T>
where T: Send,

§

impl<T> Sync for FieldData<T>
where T: Sync,

§

impl<T> Unpin for FieldData<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for FieldData<T>

§

impl<T> UnwindSafe for FieldData<T>
where T: 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<Frames> AssocDataIndexCons<Nil> for Frames

Source§

type Output = Nil

Type of associated data index cons-list.
Source§

fn assoc_data(&self) -> Nil

Returns the associated DataIndexCons.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<DI, P> FilterPerm<P> for DI
where DI: DataIndex, P: FnMut(Value<&<DI as DataIndex>::DType>) -> bool,

Source§

fn filter_perm(&self, predicate: P) -> Vec<usize>

Returns the permutation indices of this field which match the specified predicate.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HasLabels<Nil> for T

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> IntoLabeled for T

Source§

fn label<Label>(self) -> Labeled<Label, T>

Label this object with label Label.
Source§

impl<Frames, Store> JoinIntoStore<Nil, Store> for Frames

Source§

type Output = Store

The output type after augmenting Store.
Source§

fn join_into_store( &self, store: Store, _permutation: &[usize], ) -> Result<Store, AgnesError>

Augments store with data from self (as specified with Labels), using the provided permutation indices.
Source§

impl<DI> NRows for DI
where DI: DataIndex,

Source§

fn nrows(&self) -> usize

Return the number of rows in this data structure.
Source§

impl<DI> NaCount for DI
where DI: DataIndex,

Source§

fn num_na(&self) -> usize

Returns the number of NA (missing) values in this field.
Source§

fn num_exists(&self) -> usize

Returns the number of existing (non-missing) values in this field.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<DI, F> SortOrderComparator<F> for DI
where DI: DataIndex, F: FnMut(Value<&<DI as DataIndex>::DType>, Value<&<DI as DataIndex>::DType>) -> Ordering,

Source§

fn sort_order_by(&self, compare: F) -> Vec<usize>

Returns the stable sorted permutation order (Vec<usize>) using the specified comparator.
Source§

impl<DI, F> SortOrderUnstableComparator<F> for DI
where DI: DataIndex, F: FnMut(Value<&<DI as DataIndex>::DType>, Value<&<DI as DataIndex>::DType>) -> Ordering,

Source§

fn sort_order_unstable_by(&self, compare: F) -> Vec<usize>

Returns the unstable sorted permutation order (Vec<usize>) using the specified comparator.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> Valued for T
where T: SelfValued,

Source§

type Value = T

The associated value.
Source§

fn value_ref(&self) -> &T

Read-only reference to the value.
Source§

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

Mutable reference to the value.
Source§

fn value(self) -> <T as Valued>::Value

Take ownership of the value.