Adapt empty generator
This commit is contained in:
@@ -156,7 +156,7 @@ impl<NTY> Appendable for EventValues<NTY>
|
||||
where
|
||||
NTY: NumOps,
|
||||
{
|
||||
fn empty() -> Self {
|
||||
fn empty_like_self(&self) -> Self {
|
||||
Self::empty()
|
||||
}
|
||||
|
||||
@@ -482,8 +482,10 @@ where
|
||||
{
|
||||
type Value = NTY;
|
||||
|
||||
fn append_event(&mut self, ts: u64, value: Self::Value) {
|
||||
self.tss.push(ts);
|
||||
self.values.push(value);
|
||||
fn append_event(ret: Option<Self>, ts: u64, value: Self::Value) -> Self {
|
||||
let mut ret = if let Some(ret) = ret { ret } else { Self::empty() };
|
||||
ret.tss.push(ts);
|
||||
ret.values.push(value);
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ use bytes::BytesMut;
|
||||
use chrono::{TimeZone, Utc};
|
||||
use err::Error;
|
||||
use netpod::timeunits::{MS, SEC};
|
||||
use netpod::RangeFilterStats;
|
||||
use netpod::{log::Level, AggKind, EventDataReadStats, EventQueryJsonStringFrame, NanoRange, Shape};
|
||||
use serde::de::{self, DeserializeOwned, Visitor};
|
||||
use serde::{Deserialize, Serialize, Serializer};
|
||||
@@ -50,6 +51,7 @@ pub enum RangeCompletableItem<T> {
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum StatsItem {
|
||||
EventDataReadStats(EventDataReadStats),
|
||||
RangeFilterStats(RangeFilterStats),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
@@ -243,6 +245,18 @@ pub trait EventsNodeProcessor: Send + Unpin {
|
||||
fn process(&self, inp: Self::Input) -> Self::Output;
|
||||
}
|
||||
|
||||
pub trait EventsTypeAliases {
|
||||
type TimeBinOutput;
|
||||
}
|
||||
|
||||
impl<ENP> EventsTypeAliases for ENP
|
||||
where
|
||||
ENP: EventsNodeProcessor,
|
||||
<ENP as EventsNodeProcessor>::Output: TimeBinnableType,
|
||||
{
|
||||
type TimeBinOutput = <<ENP as EventsNodeProcessor>::Output as TimeBinnableType>::Output;
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub struct IsoDateTime(chrono::DateTime<Utc>);
|
||||
|
||||
@@ -303,7 +317,7 @@ pub trait PushableIndex {
|
||||
}
|
||||
|
||||
pub trait Appendable: WithLen {
|
||||
fn empty() -> Self;
|
||||
fn empty_like_self(&self) -> Self;
|
||||
fn append(&mut self, src: &Self);
|
||||
}
|
||||
|
||||
@@ -311,9 +325,12 @@ pub trait Clearable {
|
||||
fn clear(&mut self);
|
||||
}
|
||||
|
||||
pub trait EventAppendable {
|
||||
pub trait EventAppendable
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
type Value;
|
||||
fn append_event(&mut self, ts: u64, value: Self::Value);
|
||||
fn append_event(ret: Option<Self>, ts: u64, value: Self::Value) -> Self;
|
||||
}
|
||||
|
||||
pub trait TimeBins: Send + Unpin + WithLen + Appendable + FilterFittingInside {
|
||||
|
||||
@@ -144,7 +144,7 @@ impl<NTY> Appendable for MinMaxAvgBins<NTY>
|
||||
where
|
||||
NTY: NumOps,
|
||||
{
|
||||
fn empty() -> Self {
|
||||
fn empty_like_self(&self) -> Self {
|
||||
Self::empty()
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ impl<NTY> Appendable for MinMaxAvgDim1Bins<NTY>
|
||||
where
|
||||
NTY: NumOps,
|
||||
{
|
||||
fn empty() -> Self {
|
||||
fn empty_like_self(&self) -> Self {
|
||||
Self::empty()
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ impl<NTY> Appendable for MinMaxAvgWaveBins<NTY>
|
||||
where
|
||||
NTY: NumOps,
|
||||
{
|
||||
fn empty() -> Self {
|
||||
fn empty_like_self(&self) -> Self {
|
||||
Self::empty()
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ impl<NTY> Appendable for WaveEvents<NTY>
|
||||
where
|
||||
NTY: NumOps,
|
||||
{
|
||||
fn empty() -> Self {
|
||||
fn empty_like_self(&self) -> Self {
|
||||
Self::empty()
|
||||
}
|
||||
|
||||
@@ -304,9 +304,11 @@ where
|
||||
{
|
||||
type Value = Vec<NTY>;
|
||||
|
||||
fn append_event(&mut self, ts: u64, value: Self::Value) {
|
||||
self.tss.push(ts);
|
||||
self.vals.push(value);
|
||||
fn append_event(ret: Option<Self>, ts: u64, value: Self::Value) -> Self {
|
||||
let mut ret = if let Some(ret) = ret { ret } else { Self::empty() };
|
||||
ret.tss.push(ts);
|
||||
ret.vals.push(value);
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ impl<NTY> Appendable for XBinnedScalarEvents<NTY>
|
||||
where
|
||||
NTY: NumOps,
|
||||
{
|
||||
fn empty() -> Self {
|
||||
fn empty_like_self(&self) -> Self {
|
||||
Self::empty()
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ impl<NTY> Appendable for XBinnedWaveEvents<NTY>
|
||||
where
|
||||
NTY: NumOps,
|
||||
{
|
||||
fn empty() -> Self {
|
||||
fn empty_like_self(&self) -> Self {
|
||||
Self::empty()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user