WIP on pulse id handling
This commit is contained in:
@@ -5,7 +5,7 @@ use crate::AsAnyRef;
|
||||
use crate::Events;
|
||||
use crate::WithLen;
|
||||
use err::Error;
|
||||
use netpod::BinnedRange;
|
||||
use netpod::BinnedRangeEnum;
|
||||
use netpod::NanoRange;
|
||||
use std::fmt;
|
||||
|
||||
@@ -14,7 +14,11 @@ pub trait Collector: fmt::Debug + Send {
|
||||
fn ingest(&mut self, item: &mut dyn Collectable);
|
||||
fn set_range_complete(&mut self);
|
||||
fn set_timed_out(&mut self);
|
||||
fn result(&mut self, range: Option<NanoRange>, binrange: Option<BinnedRange>) -> Result<Box<dyn Collected>, Error>;
|
||||
fn result(
|
||||
&mut self,
|
||||
range: Option<NanoRange>,
|
||||
binrange: Option<BinnedRangeEnum>,
|
||||
) -> Result<Box<dyn Collected>, Error>;
|
||||
}
|
||||
|
||||
pub trait Collectable: fmt::Debug + AsAnyMut + crate::WithLen {
|
||||
@@ -46,7 +50,11 @@ pub trait CollectorDyn: fmt::Debug + Send {
|
||||
|
||||
fn set_timed_out(&mut self);
|
||||
|
||||
fn result(&mut self, range: Option<NanoRange>, binrange: Option<BinnedRange>) -> Result<Box<dyn Collected>, Error>;
|
||||
fn result(
|
||||
&mut self,
|
||||
range: Option<NanoRange>,
|
||||
binrange: Option<BinnedRangeEnum>,
|
||||
) -> Result<Box<dyn Collected>, Error>;
|
||||
}
|
||||
|
||||
pub trait CollectableWithDefault: AsAnyMut {
|
||||
@@ -88,7 +96,7 @@ impl Collector for TimeBinnedCollector {
|
||||
fn result(
|
||||
&mut self,
|
||||
_range: Option<NanoRange>,
|
||||
_binrange: Option<BinnedRange>,
|
||||
_binrange: Option<BinnedRangeEnum>,
|
||||
) -> Result<Box<dyn Collected>, Error> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::AsAnyMut;
|
||||
use crate::AsAnyRef;
|
||||
use crate::WithLen;
|
||||
use err::Error;
|
||||
use netpod::BinnedRange;
|
||||
use netpod::BinnedRangeEnum;
|
||||
use netpod::NanoRange;
|
||||
use serde::Serialize;
|
||||
use std::any::Any;
|
||||
@@ -19,17 +19,18 @@ pub trait CollectorType: Send + Unpin + WithLen {
|
||||
fn set_timed_out(&mut self);
|
||||
|
||||
// TODO use this crate's Error instead:
|
||||
fn result(&mut self, range: Option<NanoRange>, binrange: Option<BinnedRange>) -> Result<Self::Output, Error>;
|
||||
fn result(&mut self, range: Option<NanoRange>, binrange: Option<BinnedRangeEnum>) -> Result<Self::Output, Error>;
|
||||
}
|
||||
|
||||
pub trait Collector: Send + Unpin + WithLen {
|
||||
fn ingest(&mut self, src: &mut dyn Collectable);
|
||||
fn set_range_complete(&mut self);
|
||||
fn set_timed_out(&mut self);
|
||||
// TODO factor the required parameters into new struct? Generic over events or binned?
|
||||
fn result(
|
||||
&mut self,
|
||||
range: Option<NanoRange>,
|
||||
binrange: Option<BinnedRange>,
|
||||
binrange: Option<BinnedRangeEnum>,
|
||||
) -> Result<Box<dyn ToJsonResult>, Error>;
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ impl<T: CollectorType + 'static> Collector for T {
|
||||
fn result(
|
||||
&mut self,
|
||||
range: Option<NanoRange>,
|
||||
binrange: Option<BinnedRange>,
|
||||
binrange: Option<BinnedRangeEnum>,
|
||||
) -> Result<Box<dyn ToJsonResult>, Error> {
|
||||
let ret = T::result(self, range, binrange)?;
|
||||
Ok(Box::new(ret) as _)
|
||||
|
||||
@@ -5,6 +5,7 @@ pub mod isodate;
|
||||
pub mod scalar_ops;
|
||||
pub mod streamitem;
|
||||
pub mod subfr;
|
||||
pub mod transform;
|
||||
|
||||
pub mod bincode {
|
||||
pub use bincode::*;
|
||||
@@ -13,8 +14,10 @@ pub mod bincode {
|
||||
use collect_c::CollectableWithDefault;
|
||||
use collect_s::Collectable;
|
||||
use collect_s::ToJsonResult;
|
||||
use netpod::BinnedRangeEnum;
|
||||
use netpod::NanoRange;
|
||||
use netpod::ScalarType;
|
||||
use netpod::SeriesRange;
|
||||
use netpod::Shape;
|
||||
use std::any::Any;
|
||||
use std::collections::VecDeque;
|
||||
@@ -42,9 +45,9 @@ pub enum Fits {
|
||||
}
|
||||
|
||||
pub trait RangeOverlapInfo {
|
||||
fn ends_before(&self, range: NanoRange) -> bool;
|
||||
fn ends_after(&self, range: NanoRange) -> bool;
|
||||
fn starts_after(&self, range: NanoRange) -> bool;
|
||||
fn ends_before(&self, range: &SeriesRange) -> bool;
|
||||
fn ends_after(&self, range: &SeriesRange) -> bool;
|
||||
fn starts_after(&self, range: &SeriesRange) -> bool;
|
||||
}
|
||||
|
||||
pub trait EmptyForScalarTypeShape {
|
||||
@@ -134,7 +137,7 @@ pub trait TimeBinner: Send {
|
||||
/// In contrast to `TimeBinnableType` this is meant for trait objects.
|
||||
pub trait TimeBinnable: fmt::Debug + WithLen + RangeOverlapInfo + Any + AsAnyRef + AsAnyMut + Send {
|
||||
// TODO implementors may fail if edges contain not at least 2 entries.
|
||||
fn time_binner_new(&self, edges: Vec<u64>, do_time_weight: bool) -> Box<dyn TimeBinner>;
|
||||
fn time_binner_new(&self, binrange: BinnedRangeEnum, do_time_weight: bool) -> Box<dyn TimeBinner>;
|
||||
// TODO just a helper for the empty result.
|
||||
fn to_box_to_json_result(&self) -> Box<dyn ToJsonResult>;
|
||||
}
|
||||
@@ -202,9 +205,28 @@ impl PartialEq for Box<dyn Events> {
|
||||
}
|
||||
|
||||
pub struct TransformProperties {
|
||||
pub needs_one_before_range: bool,
|
||||
pub needs_value: bool,
|
||||
}
|
||||
|
||||
pub trait TransformStage {
|
||||
pub trait Transformer {
|
||||
fn query_transform_properties(&self) -> TransformProperties;
|
||||
}
|
||||
|
||||
impl<T> Transformer for Box<T>
|
||||
where
|
||||
T: Transformer,
|
||||
{
|
||||
fn query_transform_properties(&self) -> TransformProperties {
|
||||
self.as_ref().query_transform_properties()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Transformer for std::pin::Pin<Box<T>>
|
||||
where
|
||||
T: Transformer,
|
||||
{
|
||||
fn query_transform_properties(&self) -> TransformProperties {
|
||||
self.as_ref().query_transform_properties()
|
||||
}
|
||||
}
|
||||
|
||||
0
items_0/src/transform.rs
Normal file
0
items_0/src/transform.rs
Normal file
Reference in New Issue
Block a user