From 27bc094b360f66b8a6027458f3f7082f8aaa0a2e Mon Sep 17 00:00:00 2001 From: Dominik Werder Date: Wed, 9 Jun 2021 20:09:05 +0200 Subject: [PATCH] Remove some unused --- disk/src/agg/streams.rs | 24 ------- disk/src/binned.rs | 142 +--------------------------------------- 2 files changed, 3 insertions(+), 163 deletions(-) diff --git a/disk/src/agg/streams.rs b/disk/src/agg/streams.rs index 06d52cb..537db04 100644 --- a/disk/src/agg/streams.rs +++ b/disk/src/agg/streams.rs @@ -22,12 +22,6 @@ pub trait Bins { fn bin_count(&self) -> u32; } -// TODO remove: -pub trait Collected { - fn new(bin_count_exp: u32) -> Self; - fn timed_out(&mut self, k: bool); -} - pub trait Collector { type Input: Collectable; type Output: Serialize; @@ -42,24 +36,6 @@ pub trait Collectable { fn new_collector(bin_count_exp: u32) -> Self::Collector; } -// TODO can be removed? -pub trait Collectable2: Any { - fn as_any_ref(&self) -> &dyn Any; - fn append(&mut self, src: &dyn Any); -} - -// TODO remove -pub trait CollectionSpec2 { - // TODO Can I use here associated types and return concrete types? - // Probably not object safe. - fn empty(&self) -> Box; -} - -// TODO rmove -pub trait CollectionSpecMaker2 { - fn spec(bin_count_exp: u32) -> Box; -} - pub trait ToJsonBytes { fn to_json_bytes(&self) -> Result, Error>; } diff --git a/disk/src/binned.rs b/disk/src/binned.rs index 93c3045..3e08be4 100644 --- a/disk/src/binned.rs +++ b/disk/src/binned.rs @@ -8,10 +8,7 @@ use crate::agg::binnedt4::{ use crate::agg::enp::{Identity, WaveXBinner, XBinnedScalarEvents}; use crate::agg::eventbatch::MinMaxAvgScalarEventBatch; use crate::agg::scalarbinbatch::MinMaxAvgScalarBinBatch; -use crate::agg::streams::{ - Appendable, Collectable, Collectable2, Collected, CollectionSpec2, CollectionSpecMaker2, Collector, StreamItem, - ToJsonBytes, ToJsonResult, -}; +use crate::agg::streams::{Appendable, Collectable, Collector, StreamItem, ToJsonBytes, ToJsonResult}; use crate::agg::{Fits, FitsInside}; use crate::binned::binnedfrompbv::BinnedFromPreBinned; use crate::binned::query::{BinnedQuery, PreBinnedQuery}; @@ -61,104 +58,6 @@ pub struct BinnedStreamRes { pub range: BinnedRange, } -pub struct MinMaxAvgScalarBinBatchCollected { - batch: MinMaxAvgScalarBinBatch, - timed_out: bool, - finalised_range: bool, - bin_count_exp: u32, -} - -impl MinMaxAvgScalarBinBatchCollected { - pub fn empty(bin_count_exp: u32) -> Self { - Self { - batch: MinMaxAvgScalarBinBatch::empty(), - timed_out: false, - finalised_range: false, - bin_count_exp, - } - } -} - -impl Collected for MinMaxAvgScalarBinBatchCollected { - fn new(bin_count_exp: u32) -> Self { - Self::empty(bin_count_exp) - } - - fn timed_out(&mut self, k: bool) { - self.timed_out = k; - } -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct MinMaxAvgScalarBinBatchCollectedJsonResult { - #[serde(rename = "tsBinEdges")] - ts_bin_edges: Vec, - counts: Vec, - mins: Vec, - maxs: Vec, - avgs: Vec, - #[serde(skip_serializing_if = "Bool::is_false", rename = "finalisedRange")] - finalised_range: bool, - #[serde(skip_serializing_if = "Zero::is_zero", rename = "missingBins")] - missing_bins: u32, - #[serde(skip_serializing_if = "Option::is_none", rename = "continueAt")] - continue_at: Option, -} - -impl ToJsonBytes for MinMaxAvgScalarBinBatchCollectedJsonResult { - fn to_json_bytes(&self) -> Result, Error> { - Ok(serde_json::to_vec(self)?) - } -} - -impl ToJsonResult for MinMaxAvgScalarBinBatchCollected { - fn to_json_result(&self) -> Result, Error> { - let mut tsa: Vec<_> = self - .batch - .ts1s - .iter() - .map(|&k| IsoDateTime(Utc.timestamp_nanos(k as i64))) - .collect(); - if let Some(&z) = self.batch.ts2s.last() { - tsa.push(IsoDateTime(Utc.timestamp_nanos(z as i64))); - } - let continue_at = if self.batch.ts1s.len() < self.bin_count_exp as usize { - match tsa.last() { - Some(k) => Some(k.clone()), - None => Err(Error::with_msg("partial_content but no bin in result"))?, - } - } else { - None - }; - let ret = MinMaxAvgScalarBinBatchCollectedJsonResult { - counts: self.batch.counts.clone(), - mins: self.batch.mins.clone(), - maxs: self.batch.maxs.clone(), - avgs: self.batch.avgs.clone(), - missing_bins: self.bin_count_exp - self.batch.ts1s.len() as u32, - finalised_range: self.finalised_range, - ts_bin_edges: tsa, - continue_at, - }; - Ok(Box::new(ret)) - } -} - -impl ToJsonResult for MinMaxAvgScalarBinBatch { - fn to_json_result(&self) -> Result, Error> { - err::todo(); - let ret = MinMaxAvgScalarBinBatch { - ts1s: self.ts1s.clone(), - ts2s: self.ts2s.clone(), - counts: self.counts.clone(), - mins: self.mins.clone(), - maxs: self.maxs.clone(), - avgs: self.avgs.clone(), - }; - Ok(Box::new(ret)) - } -} - pub struct BinnedResponseStat { stream: Pin> + Send>>, bin_count: u32, @@ -616,7 +515,6 @@ where let mut i1 = 0; let mut stream = stream; loop { - // TODO use the trait instead to check if we have already at least one bin in the result: let item = if i1 == 0 { stream.next().await } else { @@ -677,7 +575,7 @@ where buf: Vec, all: Vec, file: Option, - _marker: std::marker::PhantomData, + _m1: PhantomData, } impl ReadPbv @@ -690,7 +588,7 @@ where buf: vec![0; 1024 * 32], all: vec![], file: Some(file), - _marker: std::marker::PhantomData::default(), + _m1: PhantomData, } } } @@ -1087,45 +985,11 @@ impl MinMaxAvgBinsCollected { } } -impl Collectable2 for MinMaxAvgBins -where - NTY: 'static, -{ - fn as_any_ref(&self) -> &dyn Any { - self - } - - fn append(&mut self, src: &dyn Any) { - todo!() - } -} - pub struct MinMaxAvgBinsCollectionSpec { bin_count_exp: u32, _m1: PhantomData, } -impl CollectionSpec2 for MinMaxAvgBinsCollectionSpec -where - NTY: 'static, -{ - fn empty(&self) -> Box { - Box::new(MinMaxAvgBins::::empty()) - } -} - -impl CollectionSpecMaker2 for MinMaxAvgBins -where - NTY: 'static, -{ - fn spec(bin_count_exp: u32) -> Box { - Box::new(MinMaxAvgBinsCollectionSpec:: { - bin_count_exp, - _m1: PhantomData, - }) - } -} - #[derive(Serialize)] pub struct MinMaxAvgBinsCollectedResult { ts_bin_edges: Vec,