Simplify filter
This commit is contained in:
@@ -809,6 +809,13 @@ impl Mergeable for ChannelEvents {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn tss(&self) -> Vec<netpod::TsMs> {
|
||||
Events::tss(self)
|
||||
.iter()
|
||||
.map(|x| netpod::TsMs::from_ns_u64(*x))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl RangeOverlapInfo for ChannelEvents {
|
||||
|
||||
@@ -256,6 +256,10 @@ impl Mergeable for EventFull {
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn tss(&self) -> Vec<netpod::TsMs> {
|
||||
self.tss.iter().map(|x| netpod::TsMs::from_ns_u64(*x)).collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, ThisError, Serialize, Deserialize)]
|
||||
|
||||
@@ -112,6 +112,12 @@ impl<STY> EventsDim0<STY> {
|
||||
std::any::type_name::<Self>()
|
||||
}
|
||||
|
||||
pub fn push_back(&mut self, ts: u64, pulse: u64, value: STY) {
|
||||
self.tss.push_back(ts);
|
||||
self.pulses.push_back(pulse);
|
||||
self.values.push_back(value);
|
||||
}
|
||||
|
||||
pub fn push_front(&mut self, ts: u64, pulse: u64, value: STY) {
|
||||
self.tss.push_front(ts);
|
||||
self.pulses.push_front(pulse);
|
||||
@@ -858,11 +864,21 @@ impl<STY: ScalarOps> Events for EventsDim0<STY> {
|
||||
|
||||
fn output_info(&self) -> String {
|
||||
let n2 = self.tss.len().max(1) - 1;
|
||||
let min = if let Some(ts) = self.tss.get(0) {
|
||||
TsNano::from_ns(*ts).fmt().to_string()
|
||||
} else {
|
||||
String::from("None")
|
||||
};
|
||||
let max = if let Some(ts) = self.tss.get(n2) {
|
||||
TsNano::from_ns(*ts).fmt().to_string()
|
||||
} else {
|
||||
String::from("None")
|
||||
};
|
||||
format!(
|
||||
"EventsDim0OutputInfo {{ len {}, ts_min {}, ts_max {} }}",
|
||||
self.tss.len(),
|
||||
self.tss.get(0).map_or(-1i64, |&x| x as i64),
|
||||
self.tss.get(n2).map_or(-1i64, |&x| x as i64),
|
||||
min,
|
||||
max,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -189,6 +189,13 @@ impl Mergeable for Box<dyn Events> {
|
||||
fn find_highest_index_lt(&self, ts: u64) -> Option<usize> {
|
||||
self.as_ref().find_highest_index_lt_evs(ts)
|
||||
}
|
||||
|
||||
fn tss(&self) -> Vec<netpod::TsMs> {
|
||||
Events::tss(self)
|
||||
.iter()
|
||||
.map(|x| netpod::TsMs::from_ns_u64(*x))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO rename to `Typed`
|
||||
|
||||
@@ -15,6 +15,7 @@ use items_0::Events;
|
||||
use items_0::MergeError;
|
||||
use items_0::WithLen;
|
||||
use netpod::log::*;
|
||||
use netpod::TsMs;
|
||||
use std::collections::VecDeque;
|
||||
use std::fmt;
|
||||
use std::ops::ControlFlow;
|
||||
@@ -53,6 +54,8 @@ pub trait Mergeable<Rhs = Self>: fmt::Debug + WithLen + ByteEstimate + Unpin {
|
||||
fn find_lowest_index_gt(&self, ts: u64) -> Option<usize>;
|
||||
fn find_lowest_index_ge(&self, ts: u64) -> Option<usize>;
|
||||
fn find_highest_index_lt(&self, ts: u64) -> Option<usize>;
|
||||
// TODO only for testing:
|
||||
fn tss(&self) -> Vec<TsMs>;
|
||||
}
|
||||
|
||||
type MergeInp<T> = Pin<Box<dyn Stream<Item = Sitemty<T>> + Send>>;
|
||||
|
||||
Reference in New Issue
Block a user