WIP pulse diff
This commit is contained in:
@@ -11,6 +11,7 @@ use items_0::AsAnyMut;
|
||||
use items_0::AsAnyRef;
|
||||
use items_0::Empty;
|
||||
use items_0::Events;
|
||||
use items_0::EventsNonObj;
|
||||
use items_0::WithLen;
|
||||
use netpod::log::*;
|
||||
use netpod::timeunits::SEC;
|
||||
@@ -713,7 +714,18 @@ impl<STY> items_0::TypeName for EventsDim0<STY> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<NTY: ScalarOps> Events for EventsDim0<NTY> {
|
||||
impl<STY: ScalarOps> EventsNonObj for EventsDim0<STY> {
|
||||
fn into_tss_pulses(self: Box<Self>) -> (VecDeque<u64>, VecDeque<u64>) {
|
||||
info!(
|
||||
"EventsDim0::into_tss_pulses len {} len {}",
|
||||
self.tss.len(),
|
||||
self.pulses.len()
|
||||
);
|
||||
(self.tss, self.pulses)
|
||||
}
|
||||
}
|
||||
|
||||
impl<STY: ScalarOps> Events for EventsDim0<STY> {
|
||||
fn as_time_binnable(&self) -> &dyn TimeBinnable {
|
||||
self as &dyn TimeBinnable
|
||||
}
|
||||
@@ -780,7 +792,7 @@ impl<NTY: ScalarOps> Events for EventsDim0<NTY> {
|
||||
Box::new(Self::empty())
|
||||
}
|
||||
|
||||
fn drain_into(&mut self, dst: &mut Box<dyn Events>, range: (usize, usize)) -> Result<(), ()> {
|
||||
fn drain_into(&mut self, dst: &mut Box<dyn Events>, range: (usize, usize)) -> Result<(), items_0::MergeError> {
|
||||
// TODO as_any and as_any_mut are declared on unrelated traits. Simplify.
|
||||
if let Some(dst) = dst.as_mut().as_any_mut().downcast_mut::<Self>() {
|
||||
// TODO make it harder to forget new members when the struct may get modified in the future
|
||||
@@ -791,7 +803,7 @@ impl<NTY: ScalarOps> Events for EventsDim0<NTY> {
|
||||
Ok(())
|
||||
} else {
|
||||
error!("downcast to EventsDim0 FAILED");
|
||||
Err(())
|
||||
Err(items_0::MergeError::NotCompatible)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -843,7 +855,7 @@ impl<NTY: ScalarOps> Events for EventsDim0<NTY> {
|
||||
}
|
||||
|
||||
fn nty_id(&self) -> u32 {
|
||||
NTY::SUB
|
||||
STY::SUB
|
||||
}
|
||||
|
||||
fn clone_dyn(&self) -> Box<dyn Events> {
|
||||
|
||||
@@ -11,6 +11,7 @@ use items_0::AsAnyMut;
|
||||
use items_0::AsAnyRef;
|
||||
use items_0::Empty;
|
||||
use items_0::Events;
|
||||
use items_0::EventsNonObj;
|
||||
use items_0::WithLen;
|
||||
use netpod::log::*;
|
||||
use netpod::timeunits::SEC;
|
||||
@@ -667,7 +668,18 @@ impl<STY> items_0::TypeName for EventsDim1<STY> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<NTY: ScalarOps> Events for EventsDim1<NTY> {
|
||||
impl<STY: ScalarOps> EventsNonObj for EventsDim1<STY> {
|
||||
fn into_tss_pulses(self: Box<Self>) -> (VecDeque<u64>, VecDeque<u64>) {
|
||||
info!(
|
||||
"EventsDim1::into_tss_pulses len {} len {}",
|
||||
self.tss.len(),
|
||||
self.pulses.len()
|
||||
);
|
||||
(self.tss, self.pulses)
|
||||
}
|
||||
}
|
||||
|
||||
impl<STY: ScalarOps> Events for EventsDim1<STY> {
|
||||
fn as_time_binnable(&self) -> &dyn TimeBinnable {
|
||||
self as &dyn TimeBinnable
|
||||
}
|
||||
@@ -734,7 +746,7 @@ impl<NTY: ScalarOps> Events for EventsDim1<NTY> {
|
||||
Box::new(Self::empty())
|
||||
}
|
||||
|
||||
fn drain_into(&mut self, dst: &mut Box<dyn Events>, range: (usize, usize)) -> Result<(), ()> {
|
||||
fn drain_into(&mut self, dst: &mut Box<dyn Events>, range: (usize, usize)) -> Result<(), items_0::MergeError> {
|
||||
// TODO as_any and as_any_mut are declared on unrelated traits. Simplify.
|
||||
if let Some(dst) = dst.as_mut().as_any_mut().downcast_mut::<Self>() {
|
||||
// TODO make it harder to forget new members when the struct may get modified in the future
|
||||
@@ -745,7 +757,7 @@ impl<NTY: ScalarOps> Events for EventsDim1<NTY> {
|
||||
Ok(())
|
||||
} else {
|
||||
error!("downcast to EventsDim0 FAILED");
|
||||
Err(())
|
||||
Err(items_0::MergeError::NotCompatible)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -797,7 +809,7 @@ impl<NTY: ScalarOps> Events for EventsDim1<NTY> {
|
||||
}
|
||||
|
||||
fn nty_id(&self) -> u32 {
|
||||
NTY::SUB
|
||||
STY::SUB
|
||||
}
|
||||
|
||||
fn clone_dyn(&self) -> Box<dyn Events> {
|
||||
|
||||
@@ -188,9 +188,7 @@ impl crate::merger::Mergeable for Box<dyn Events> {
|
||||
}
|
||||
|
||||
fn drain_into(&mut self, dst: &mut Self, range: (usize, usize)) -> Result<(), merger::MergeError> {
|
||||
self.as_mut()
|
||||
.drain_into(dst, range)
|
||||
.map_err(|()| merger::MergeError::NotCompatible)
|
||||
self.as_mut().drain_into(dst, range)
|
||||
}
|
||||
|
||||
fn find_lowest_index_gt(&self, ts: u64) -> Option<usize> {
|
||||
@@ -246,8 +244,9 @@ pub fn empty_events_dyn_ev(
|
||||
STRING => Box::new(K::<String>::empty()),
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
error!("TODO empty_events_dyn_2 {scalar_type:?} {shape:?} {agg_kind:?}");
|
||||
AggKind::PulseIdDiff => Box::new(eventsdim0::EventsDim0::<i64>::empty()),
|
||||
AggKind::DimXBins1 | AggKind::DimXBinsN(..) | AggKind::EventBlobs => {
|
||||
error!("TODO empty_events_dyn_ev {agg_kind:?} {scalar_type:?} {shape:?}");
|
||||
err::todoval()
|
||||
}
|
||||
},
|
||||
@@ -270,13 +269,14 @@ pub fn empty_events_dyn_ev(
|
||||
STRING => Box::new(K::<String>::empty()),
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
error!("TODO empty_events_dyn_2 {scalar_type:?} {shape:?} {agg_kind:?}");
|
||||
AggKind::PulseIdDiff => Box::new(eventsdim0::EventsDim0::<i64>::empty()),
|
||||
AggKind::DimXBins1 | AggKind::DimXBinsN(..) | AggKind::EventBlobs => {
|
||||
error!("TODO empty_events_dyn_ev {agg_kind:?} {scalar_type:?} {shape:?}");
|
||||
err::todoval()
|
||||
}
|
||||
},
|
||||
Shape::Image(..) => {
|
||||
error!("TODO empty_events_dyn_2 {scalar_type:?} {shape:?} {agg_kind:?}");
|
||||
error!("TODO empty_events_dyn_ev {agg_kind:?} {scalar_type:?} {shape:?}");
|
||||
err::todoval()
|
||||
}
|
||||
};
|
||||
@@ -300,14 +300,18 @@ pub fn empty_binned_dyn_tb(scalar_type: &ScalarType, shape: &Shape, agg_kind: &A
|
||||
I64 => Box::new(K::<i64>::empty()),
|
||||
F32 => Box::new(K::<f32>::empty()),
|
||||
F64 => Box::new(K::<f64>::empty()),
|
||||
_ => {
|
||||
error!("TODO empty_binned_dyn");
|
||||
BOOL | STRING => {
|
||||
error!("TODO empty_binned_dyn_tb {agg_kind:?} {scalar_type:?} {shape:?}");
|
||||
err::todoval()
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
error!("TODO empty_binned_dyn");
|
||||
AggKind::Plain
|
||||
| AggKind::DimXBins1
|
||||
| AggKind::DimXBinsN(..)
|
||||
| AggKind::EventBlobs
|
||||
| AggKind::PulseIdDiff => {
|
||||
error!("TODO empty_binned_dyn_tb {agg_kind:?} {scalar_type:?} {shape:?}");
|
||||
err::todoval()
|
||||
}
|
||||
},
|
||||
@@ -317,21 +321,32 @@ pub fn empty_binned_dyn_tb(scalar_type: &ScalarType, shape: &Shape, agg_kind: &A
|
||||
type K<T> = binsdim0::BinsDim0<T>;
|
||||
match scalar_type {
|
||||
U8 => Box::new(K::<u8>::empty()),
|
||||
U16 => Box::new(K::<u16>::empty()),
|
||||
U32 => Box::new(K::<u32>::empty()),
|
||||
U64 => Box::new(K::<u64>::empty()),
|
||||
I8 => Box::new(K::<i8>::empty()),
|
||||
I16 => Box::new(K::<i16>::empty()),
|
||||
I32 => Box::new(K::<i32>::empty()),
|
||||
I64 => Box::new(K::<i64>::empty()),
|
||||
F32 => Box::new(K::<f32>::empty()),
|
||||
F64 => Box::new(K::<f64>::empty()),
|
||||
_ => {
|
||||
error!("TODO empty_binned_dyn");
|
||||
BOOL | STRING => {
|
||||
error!("TODO empty_binned_dyn_tb {agg_kind:?} {scalar_type:?} {shape:?}");
|
||||
err::todoval()
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
error!("TODO empty_binned_dyn");
|
||||
AggKind::EventBlobs
|
||||
| AggKind::DimXBinsN(..)
|
||||
| AggKind::Plain
|
||||
| AggKind::TimeWeightedScalar
|
||||
| AggKind::PulseIdDiff => {
|
||||
error!("TODO empty_binned_dyn_tb {agg_kind:?} {scalar_type:?} {shape:?}");
|
||||
err::todoval()
|
||||
}
|
||||
},
|
||||
Shape::Image(..) => {
|
||||
error!("TODO empty_binned_dyn");
|
||||
error!("TODO empty_binned_dyn_tb {agg_kind:?} {scalar_type:?} {shape:?}");
|
||||
err::todoval()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,17 +31,8 @@ macro_rules! trace4 {
|
||||
($($arg:tt)*) => (trace!($($arg)*));
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum MergeError {
|
||||
NotCompatible,
|
||||
Full,
|
||||
}
|
||||
|
||||
impl From<MergeError> for err::Error {
|
||||
fn from(e: MergeError) -> Self {
|
||||
format!("{e:?}").into()
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
pub use items_0::MergeError;
|
||||
|
||||
pub trait Mergeable<Rhs = Self>: fmt::Debug + Unpin {
|
||||
fn len(&self) -> usize;
|
||||
@@ -204,7 +195,8 @@ where
|
||||
// Take only up to the lowest ts of the second-lowest input
|
||||
let mut item = self.items[il0].take().unwrap();
|
||||
trace3!("Take up to {tl1} from item {item:?}");
|
||||
match self.take_into_output_upto(&mut item, tl1) {
|
||||
let res = self.take_into_output_upto(&mut item, tl1);
|
||||
match res {
|
||||
Ok(()) => {
|
||||
if item.len() == 0 {
|
||||
// TODO should never be here because we should have taken the whole item
|
||||
@@ -216,7 +208,7 @@ where
|
||||
}
|
||||
Err(MergeError::Full) | Err(MergeError::NotCompatible) => {
|
||||
// TODO count for stats
|
||||
trace3!("Put item back");
|
||||
info!("Put item back because {res:?}");
|
||||
self.items[il0] = Some(item);
|
||||
self.do_clear_out = true;
|
||||
Ok(Break(()))
|
||||
|
||||
Reference in New Issue
Block a user