Factor more

This commit is contained in:
Dominik Werder
2021-05-20 13:27:46 +02:00
parent 2b1e68a222
commit 72006fbf17
7 changed files with 190 additions and 145 deletions

View File

@@ -1,5 +1,5 @@
use crate::agg::binnedt::{AggregatableTdim, AggregatorTdim};
use crate::agg::streams::{Batchable, Bins};
use crate::agg::streams::Bins;
use crate::agg::{AggregatableXdim1Bin, Fits, FitsInside};
use crate::binned::MakeBytesFrame;
use crate::frame::makeframe::make_frame;
@@ -234,17 +234,6 @@ impl AggregatableTdim for MinMaxAvgScalarBinBatch {
}
}
impl Batchable for MinMaxAvgScalarBinBatch {
fn append(&mut self, k: &mut Self) {
self.ts1s.append(&mut k.ts1s);
self.ts2s.append(&mut k.ts2s);
self.counts.append(&mut k.counts);
self.mins.append(&mut k.mins);
self.maxs.append(&mut k.maxs);
self.avgs.append(&mut k.avgs);
}
}
impl Bins for MinMaxAvgScalarBinBatch {
fn bin_count(&self) -> u32 {
self.ts1s.len() as u32
@@ -425,7 +414,7 @@ impl AggregatableXdim1Bin for MinMaxAvgScalarBinBatchStreamItem {
impl MakeBytesFrame for Result<MinMaxAvgScalarBinBatchStreamItem, Error> {
fn make_bytes_frame(&self) -> Result<Bytes, Error> {
Ok(make_frame::<Self>(self)?.freeze())
Ok(make_frame(self)?.freeze())
}
}

View File

@@ -1,4 +1,5 @@
use crate::streamlog::LogItem;
use err::Error;
use netpod::EventDataReadStats;
use serde::{Deserialize, Serialize};
@@ -18,6 +19,17 @@ pub trait Bins {
fn bin_count(&self) -> u32;
}
pub trait Batchable {
fn append(&mut self, k: &mut Self);
pub trait Collected {
fn new(bin_count_exp: u32) -> Self;
fn timed_out(&mut self, k: bool);
}
pub trait Collectable {
type Collected: Collected;
fn append_to(&mut self, collected: &mut Self::Collected);
}
pub trait ToJsonResult {
type Output;
fn to_json_result(&self) -> Result<Self::Output, Error>;
}