Refactor number pipeline for simple cases
This commit is contained in:
+29
-22
@@ -1,4 +1,4 @@
|
||||
use crate::agg::binnedt4::TBinnerStream;
|
||||
use crate::agg::binnedt4::{TBinnerStream, TimeBinnableType};
|
||||
use crate::agg::streams::{Appendable, StreamItem};
|
||||
use crate::binned::query::{CacheUsage, PreBinnedQuery};
|
||||
use crate::binned::{
|
||||
@@ -9,7 +9,7 @@ use crate::cache::pbvfs::PreBinnedScalarValueFetchedStream;
|
||||
use crate::cache::{write_pb_cache_min_max_avg_scalar, CacheFileDesc, MergedFromRemotes, WrittenPbCache};
|
||||
use crate::decode::{Endianness, EventValueFromBytes, EventValueShape, NumFromBytes};
|
||||
use crate::frame::makeframe::{make_frame, FrameType};
|
||||
use crate::merge::mergefromremote::MergedFromRemotes2;
|
||||
use crate::merge::mergedfromremotes::MergedFromRemotes2;
|
||||
use crate::raw::EventsQuery;
|
||||
use crate::streamlog::Streamlog;
|
||||
use crate::Sitemty;
|
||||
@@ -40,7 +40,9 @@ where
|
||||
query: PreBinnedQuery,
|
||||
node_config: NodeConfigCached,
|
||||
open_check_local_file: Option<Pin<Box<dyn Future<Output = Result<File, io::Error>> + Send>>>,
|
||||
fut2: Option<Pin<Box<dyn Stream<Item = Sitemty<<ETB as EventsTimeBinner>::Output>> + Send>>>,
|
||||
fut2: Option<
|
||||
Pin<Box<dyn Stream<Item = Sitemty<<<ENP as EventsNodeProcessor>::Output as TimeBinnableType>::Output>> + Send>>,
|
||||
>,
|
||||
read_from_cache: bool,
|
||||
cache_written: bool,
|
||||
data_complete: bool,
|
||||
@@ -49,9 +51,15 @@ where
|
||||
errored: bool,
|
||||
completed: bool,
|
||||
streamlog: Streamlog,
|
||||
values: <ETB as EventsTimeBinner>::Output,
|
||||
values: <<ENP as EventsNodeProcessor>::Output as TimeBinnableType>::Output,
|
||||
write_fut: Option<Pin<Box<dyn Future<Output = Result<WrittenPbCache, Error>> + Send>>>,
|
||||
read_cache_fut: Option<Pin<Box<dyn Future<Output = Sitemty<<ETB as EventsTimeBinner>::Output>> + Send>>>,
|
||||
read_cache_fut: Option<
|
||||
Pin<
|
||||
Box<
|
||||
dyn Future<Output = Sitemty<<<ENP as EventsNodeProcessor>::Output as TimeBinnableType>::Output>> + Send,
|
||||
>,
|
||||
>,
|
||||
>,
|
||||
_m1: PhantomData<NTY>,
|
||||
_m2: PhantomData<END>,
|
||||
_m3: PhantomData<EVS>,
|
||||
@@ -84,7 +92,8 @@ where
|
||||
errored: false,
|
||||
completed: false,
|
||||
streamlog: Streamlog::new(node_config.ix as u32),
|
||||
values: <<ETB as EventsTimeBinner>::Output as Appendable>::empty(),
|
||||
// TODO use alias via some trait associated type:
|
||||
values: <<<ENP as EventsNodeProcessor>::Output as TimeBinnableType>::Output as Appendable>::empty(),
|
||||
write_fut: None,
|
||||
read_cache_fut: None,
|
||||
_m1: PhantomData,
|
||||
@@ -97,7 +106,10 @@ where
|
||||
|
||||
fn setup_merged_from_remotes(
|
||||
&mut self,
|
||||
) -> Result<Pin<Box<dyn Stream<Item = Sitemty<<ETB as EventsTimeBinner>::Output>> + Send>>, Error> {
|
||||
) -> Result<
|
||||
Pin<Box<dyn Stream<Item = Sitemty<<<ENP as EventsNodeProcessor>::Output as TimeBinnableType>::Output>> + Send>>,
|
||||
Error,
|
||||
> {
|
||||
let evq = EventsQuery {
|
||||
channel: self.query.channel().clone(),
|
||||
range: self.query.patch().patch_range(),
|
||||
@@ -117,24 +129,18 @@ where
|
||||
let range = BinnedRange::covering_range(evq.range.clone(), count as u32)?
|
||||
.ok_or(Error::with_msg("covering_range returns None"))?;
|
||||
let perf_opts = PerfOpts { inmem_bufcap: 512 };
|
||||
|
||||
// TODO copy the MergedFromRemotes and adapt...
|
||||
let s1 = MergedFromRemotes2::<ENP>::new(evq, perf_opts, self.node_config.node_config.cluster.clone());
|
||||
|
||||
// TODO
|
||||
// Go from ENP values to a T-binned stream...
|
||||
// Most of the algo is static same.
|
||||
// What varies: init aggregator for next T-bin.
|
||||
let ret = TBinnerStream::<_, ETB>::new(s1, range);
|
||||
|
||||
//let s1 = todo_convert_stream_to_tbinned_stream(s1, range);
|
||||
let s = MergedFromRemotes2::<ENP>::new(evq, perf_opts, self.node_config.node_config.cluster.clone());
|
||||
let ret = TBinnerStream::<_, <ENP as EventsNodeProcessor>::Output>::new(s, range);
|
||||
Ok(Box::pin(ret))
|
||||
}
|
||||
|
||||
fn setup_from_higher_res_prebinned(
|
||||
&mut self,
|
||||
range: PreBinnedPatchRange,
|
||||
) -> Result<Pin<Box<dyn Stream<Item = Sitemty<<ETB as EventsTimeBinner>::Output>> + Send>>, Error> {
|
||||
) -> Result<
|
||||
Pin<Box<dyn Stream<Item = Sitemty<<<ENP as EventsNodeProcessor>::Output as TimeBinnableType>::Output>> + Send>>,
|
||||
Error,
|
||||
> {
|
||||
let g = self.query.patch().bin_t_len();
|
||||
let h = range.grid_spec.bin_t_len();
|
||||
trace!(
|
||||
@@ -216,7 +222,7 @@ where
|
||||
Sitemty<<ENP as EventsNodeProcessor>::Output>: FrameType,
|
||||
<ETB as EventsTimeBinner>::Output: Serialize + ReadableFromFile + 'static,
|
||||
{
|
||||
type Item = Sitemty<<ETB as EventsTimeBinner>::Output>;
|
||||
type Item = Sitemty<<<ENP as EventsNodeProcessor>::Output as TimeBinnableType>::Output>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
use Poll::*;
|
||||
@@ -290,7 +296,8 @@ where
|
||||
self.values.len(),
|
||||
);
|
||||
self.streamlog.append(Level::INFO, msg);
|
||||
let emp = <<ETB as EventsTimeBinner>::Output as Appendable>::empty();
|
||||
// TODO use alias vias trait:
|
||||
let emp = <<<ENP as EventsNodeProcessor>::Output as TimeBinnableType>::Output as Appendable>::empty();
|
||||
let values = std::mem::replace(&mut self.values, emp);
|
||||
let fut = write_pb_cache_min_max_avg_scalar(
|
||||
values,
|
||||
@@ -344,7 +351,7 @@ where
|
||||
Ok(file) => {
|
||||
self.read_from_cache = true;
|
||||
let fut =
|
||||
<<ETB as EventsTimeBinner>::Output as ReadableFromFile>::read_from_file(file)?;
|
||||
<<<ENP as EventsNodeProcessor>::Output as TimeBinnableType>::Output as ReadableFromFile>::read_from_file(file)?;
|
||||
self.read_cache_fut = Some(Box::pin(fut));
|
||||
continue 'outer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user