This commit is contained in:
Dominik Werder
2024-10-22 16:33:31 +02:00
parent f754c5c962
commit ec425198f0
3 changed files with 33 additions and 14 deletions

View File

@@ -109,6 +109,8 @@ pub trait BinningggContainerBinsDyn: fmt::Debug + Send + fmt::Display + WithLen
pub type BinsBoxed = Box<dyn BinningggContainerBinsDyn>;
pub type EventsBoxed = Box<dyn BinningggContainerEventsDyn>;
pub trait BinningggBinnerTy: fmt::Debug + Send {
type Input: fmt::Debug;
type Output: fmt::Debug;

View File

@@ -12,6 +12,9 @@ use items_0::timebin::BinningggBinnerDyn;
use items_0::timebin::BinningggContainerBinsDyn;
use items_0::timebin::BinningggContainerEventsDyn;
use items_0::timebin::BinningggError;
use items_0::timebin::BinsBoxed;
use items_0::timebin::EventsBoxed;
use netpod::log::*;
use netpod::BinnedRange;
use netpod::TsNano;
use std::arch::x86_64;
@@ -52,7 +55,7 @@ impl<EVT> BinnedEventsTimeweightTrait for BinnedEventsTimeweightDynbox<EVT>
where
EVT: EventValueType,
{
fn ingest(&mut self, evs_all: Box<dyn BinningggContainerEventsDyn>) -> Result<(), BinningggError> {
fn ingest(&mut self, evs_all: EventsBoxed) -> Result<(), BinningggError> {
todo!()
}
@@ -66,7 +69,7 @@ where
todo!()
}
fn output(&mut self) -> Result<Box<dyn BinningggContainerBinsDyn>, BinningggError> {
fn output(&mut self) -> Result<BinsBoxed, BinningggError> {
// self.binner.output()
todo!()
}
@@ -88,21 +91,31 @@ impl BinnedEventsTimeweightLazy {
}
impl BinnedEventsTimeweightTrait for BinnedEventsTimeweightLazy {
fn ingest(&mut self, evs_all: Box<dyn BinningggContainerEventsDyn>) -> Result<(), BinningggError> {
// TODO the container must provide a method to create the dyn binner.
let binned_events = self.binned_events.get_or_insert_with(|| todo!());
todo!()
fn ingest(&mut self, evs_all: EventsBoxed) -> Result<(), BinningggError> {
self.binned_events
.get_or_insert_with(|| evs_all.binned_events_timeweight_traitobj())
.ingest(evs_all)
}
fn input_done_range_final(&mut self) -> Result<(), BinningggError> {
todo!()
debug!("TODO something to do if we miss the binner here?");
self.binned_events
.as_mut()
.map(|x| x.input_done_range_final())
.unwrap_or(Ok(()))
}
fn input_done_range_open(&mut self) -> Result<(), BinningggError> {
todo!()
debug!("TODO something to do if we miss the binner here?");
self.binned_events
.as_mut()
.map(|x| x.input_done_range_open())
.unwrap_or(Ok(()))
}
fn output(&mut self) -> Result<Box<dyn BinningggContainerBinsDyn>, BinningggError> {
fn output(&mut self) -> Result<BinsBoxed, BinningggError> {
debug!("TODO something to do if we miss the binner here?");
// TODO change trait because without binner we can not produce any container here
todo!()
}
}

View File

@@ -1105,11 +1105,15 @@ impl<STY: ScalarOps> Events for EventsDim0<STY> {
}
fn to_container_events(&self) -> Box<dyn ::items_0::timebin::BinningggContainerEventsDyn> {
// let tss = self.tss.iter().map(|&x| TsNano::from_ns(x)).collect();
// let vals = self.values.clone();
// let ret = crate::binning::container_events::ContainerEvents::from_constituents(tss, vals);
// Box::new(ret)
todo!()
use crate::binning::container_events::ContainerEvents;
let tss = self.tss.iter().map(|&x| TsNano::from_ns(x)).collect();
if let Some(evs) = self.as_any_ref().downcast_ref::<EventsDim0<f64>>() {
let vals = evs.values.clone();
let ret = ContainerEvents::<f64>::from_constituents(tss, vals);
Box::new(ret)
} else {
todo!()
}
}
}