Struct hadean_std::dataframe::DataFrame
[−]
[src]
pub struct DataFrame<'a, T> where T: ProcessSendable {
// some fields omitted
}A scalable distributed dataframe datastructure.
DataFrame<T> is a dataframe datastructure that holds a collection of elements of type T.
It enables computation to be performed in parallel across many elements at the same time.
Here's an example showing addition of data to a DataFrame, and map, filter, and reduce being called upon it:
use hadean_std::dataframe::DataFrame; let mut data_frame: DataFrame<String> = DataFrame::new(); data_frame.push(String::from("http://google.com")); data_frame.push(String::from("http://bbc.co.uk")); data_frame.push(String::from("https://hadean.com")); let mut data_frame: DataFrame<String> = data_frame.map(|mut val|{val.push_str("/xyz");val}); data_frame.filter(|val|val.len() > 20); data_frame.reduce(0u64, |acc, val| acc + val.len() as u64);
Methods
impl<'a, T> DataFrame<'a, T> where T: ProcessSendable[src]
fn new() -> DataFrame<'a, T>
Constructs a new, empty DataFrame<T>.
fn with_list(list: &'a mut Leaf<u8>, start: LeafIndex, end: LeafIndex) -> DataFrame<'a, T>
Constructs a new, empty DataFrame<T> in the given List<u8>. list.len(&start, &end) must equal 0.
fn push_front(&mut self, val: T)
Append val to the front of the dataframe.
fn push(&mut self, val: T)
Append val to the dataframe.
fn map<F, T1>(self, f: F) -> DataFrame<'a, T1> where F: Fn(T) -> T1 + ProcessSendable, T1: ProcessSendable
Map each element of the dataframe using f.
fn filter<F>(&mut self, f: F) where F: Fn(&T) -> bool + ProcessSendable
Filter elements of the dataframe, keeping only those that satisfy f.
fn reduce<F, T1>(&mut self, initial: T1, f: F) -> T1 where F: Fn(T1, &T) -> T1 + ProcessSendable, T1: ProcessSendable
Reduce the dataframe into one value.
Examples
fn main() { let mut data_frame: DataFrame<String> = DataFrame::new(); data_frame.push(String::from("http://google.com")); data_frame.push(String::from("http://bbc.co.uk")); data_frame.push(String::from("https://hadean.com")); let total_length = data_frame.reduce(0, |acc, val| acc + val.len() as u64); }let mut data_frame: DataFrame<String> = DataFrame::new(); data_frame.push(String::from("http://google.com")); data_frame.push(String::from("http://bbc.co.uk")); data_frame.push(String::from("https://hadean.com")); let total_length = data_frame.reduce(0, |acc, val| acc + val.len() as u64);
fn iter<'b>(&'b mut self) -> DataFrameIter<'a, 'b, T>
Returns an iterator over the DataFrame.
Examples
fn main() { let mut data_frame: DataFrame<String> = DataFrame::new(); data_frame.push(String::from("http://google.com")); data_frame.push(String::from("http://bbc.co.uk")); data_frame.push(String::from("https://hadean.com")); let mut iterator = x.iter(); assert_eq!(iterator.next(), Some(String::from("http://google.com"))); assert_eq!(iterator.next(), Some(String::from("http://bbc.co.uk"))); assert_eq!(iterator.next(), Some(String::from("https://hadean.com"))); assert_eq!(iterator.next(), None); }let mut data_frame: DataFrame<String> = DataFrame::new(); data_frame.push(String::from("http://google.com")); data_frame.push(String::from("http://bbc.co.uk")); data_frame.push(String::from("https://hadean.com")); let mut iterator = x.iter(); assert_eq!(iterator.next(), Some(String::from("http://google.com"))); assert_eq!(iterator.next(), Some(String::from("http://bbc.co.uk"))); assert_eq!(iterator.next(), Some(String::from("https://hadean.com"))); assert_eq!(iterator.next(), None);