[][src]Trait tsxlib::index::SampleableIndex

pub trait SampleableIndex<TIndex: Serialize + Hash + Copy + Eq + Ord, TInterval> {
    pub fn sample_rates(&self) -> Vec<(usize, TInterval)>;
pub fn is_mono_intervaled(&self) -> bool; }

This trait represents an index that has a notion of sampleability. i.e. the semantic meaning of differenencces in the index

Required methods

pub fn sample_rates(&self) -> Vec<(usize, TInterval)>[src]

pub fn is_mono_intervaled(&self) -> bool[src]

Loading content...

Implementors

impl SampleableIndex<NaiveDateTime, Duration> for HashableIndex<NaiveDateTime>[src]

Implementation of SampleableIndex for HashableIndex

pub fn sample_rates(&self) -> Vec<(usize, Duration)>[src]

Infer index sample rate, returns a vector that represtest (number of times a sample rate is observed, the sample rate)

Example

use tsxlib::index::HashableIndex;
use tsxlib::index::SampleableIndex;
use tsxlib::timeutils;
use chrono::{NaiveDateTime,Duration};
 
let index = HashableIndex::new(vec![ timeutils::naive_datetime_from_millis(0), timeutils::naive_datetime_from_millis(5),timeutils::naive_datetime_from_millis(10), timeutils::naive_datetime_from_millis(15), timeutils::naive_datetime_from_millis(20), timeutils::naive_datetime_from_millis(25), timeutils::naive_datetime_from_millis(75)]);
let exp =  vec![(5,Duration::milliseconds(5)),(1,Duration::milliseconds(50))];
assert_eq!(index.sample_rates(), exp);

pub fn is_mono_intervaled(&self) -> bool[src]

returns true if the index is spaced at equal itervals

Example

use tsxlib::index::HashableIndex;
use tsxlib::index::SampleableIndex;
use tsxlib::timeutils;
use chrono::{NaiveDateTime,Duration};
 
let index = HashableIndex::new(vec![ timeutils::naive_datetime_from_millis(0), timeutils::naive_datetime_from_millis(5),timeutils::naive_datetime_from_millis(10), timeutils::naive_datetime_from_millis(15), timeutils::naive_datetime_from_millis(20), timeutils::naive_datetime_from_millis(25), timeutils::naive_datetime_from_millis(75)]);
let index_mono = HashableIndex::new(vec![ timeutils::naive_datetime_from_millis(0), timeutils::naive_datetime_from_millis(5),timeutils::naive_datetime_from_millis(10), timeutils::naive_datetime_from_millis(15), timeutils::naive_datetime_from_millis(20), timeutils::naive_datetime_from_millis(25)]);
assert_eq!(index.is_mono_intervaled(), false);
assert_eq!(index_mono.is_mono_intervaled(), true);
Loading content...