Find active channels and deliver values
This commit is contained in:
@@ -12,7 +12,7 @@ use netpod::log::*;
|
||||
use netpod::query::CacheUsage;
|
||||
use netpod::{
|
||||
x_bin_count, AggKind, AppendToUrl, BinnedRange, ByteSize, Channel, NodeConfigCached, PerfOpts,
|
||||
PreBinnedPatchIterator, Shape,
|
||||
PreBinnedPatchIterator, ScalarType, Shape,
|
||||
};
|
||||
use serde::de::DeserializeOwned;
|
||||
use std::future::ready;
|
||||
@@ -164,6 +164,7 @@ where
|
||||
patch_it: PreBinnedPatchIterator,
|
||||
channel: Channel,
|
||||
range: BinnedRange,
|
||||
scalar_type: ScalarType,
|
||||
shape: Shape,
|
||||
agg_kind: AggKind,
|
||||
cache_usage: CacheUsage,
|
||||
@@ -185,12 +186,15 @@ where
|
||||
let pmax = patches.len();
|
||||
let inp = futures_util::stream::iter(patches.into_iter().enumerate())
|
||||
.map({
|
||||
let shape = shape.clone();
|
||||
let agg_kind = agg_kind.clone();
|
||||
let node_config = node_config.clone();
|
||||
move |(pix, patch)| {
|
||||
let query = PreBinnedQuery::new(
|
||||
patch,
|
||||
channel.clone(),
|
||||
scalar_type.clone(),
|
||||
shape.clone(),
|
||||
agg_kind.clone(),
|
||||
cache_usage.clone(),
|
||||
disk_io_buffer_size,
|
||||
|
||||
@@ -17,7 +17,7 @@ use items::{
|
||||
use netpod::log::*;
|
||||
use netpod::query::{CacheUsage, RawEventsQuery};
|
||||
use netpod::{
|
||||
x_bin_count, AggKind, BinnedRange, NodeConfigCached, PerfOpts, PreBinnedPatchIterator, PreBinnedPatchRange, Shape,
|
||||
x_bin_count, AggKind, BinnedRange, NodeConfigCached, PerfOpts, PreBinnedPatchIterator, PreBinnedPatchRange,
|
||||
};
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
@@ -37,7 +37,6 @@ where
|
||||
ENP: EventsNodeProcessor<Input = <EVS as EventValueFromBytes<NTY, END>>::Batch>,
|
||||
{
|
||||
query: PreBinnedQuery,
|
||||
shape: Shape,
|
||||
agg_kind: AggKind,
|
||||
node_config: NodeConfigCached,
|
||||
open_check_local_file: Option<Pin<Box<dyn Future<Output = Result<File, io::Error>> + Send>>>,
|
||||
@@ -71,10 +70,9 @@ where
|
||||
// TODO who exactly needs this DeserializeOwned?
|
||||
Sitemty<<<ENP as EventsNodeProcessor>::Output as TimeBinnableType>::Output>: FrameType + DeserializeOwned,
|
||||
{
|
||||
pub fn new(query: PreBinnedQuery, shape: Shape, agg_kind: AggKind, node_config: &NodeConfigCached) -> Self {
|
||||
pub fn new(query: PreBinnedQuery, agg_kind: AggKind, node_config: &NodeConfigCached) -> Self {
|
||||
Self {
|
||||
query,
|
||||
shape,
|
||||
agg_kind,
|
||||
node_config: node_config.clone(),
|
||||
open_check_local_file: None,
|
||||
@@ -133,7 +131,7 @@ where
|
||||
let ret = TBinnerStream::<_, <ENP as EventsNodeProcessor>::Output>::new(
|
||||
s,
|
||||
range,
|
||||
x_bin_count(&self.shape, &self.agg_kind),
|
||||
x_bin_count(&self.query.shape().clone(), &self.agg_kind),
|
||||
self.agg_kind.do_time_weighted(),
|
||||
);
|
||||
Ok(Box::pin(ret))
|
||||
@@ -180,6 +178,8 @@ where
|
||||
let query = PreBinnedQuery::new(
|
||||
patch,
|
||||
q2.channel().clone(),
|
||||
q2.scalar_type().clone(),
|
||||
q2.shape().clone(),
|
||||
q2.agg_kind().clone(),
|
||||
q2.cache_usage().clone(),
|
||||
disk_io_buffer_size,
|
||||
|
||||
@@ -13,13 +13,13 @@ use items::numops::{BoolNum, NumOps, StringNum};
|
||||
use items::{
|
||||
Appendable, Clearable, EventsNodeProcessor, Framable, FrameType, PushableIndex, Sitemty, TimeBinnableType,
|
||||
};
|
||||
use netpod::{AggKind, ByteOrder, ChannelConfigQuery, NodeConfigCached, ScalarType, Shape};
|
||||
use netpod::{AggKind, ByteOrder, NodeConfigCached, ScalarType, Shape};
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
use std::pin::Pin;
|
||||
|
||||
fn make_num_pipeline_nty_end_evs_enp<NTY, END, EVS, ENP>(
|
||||
shape: Shape,
|
||||
_shape: Shape,
|
||||
agg_kind: AggKind,
|
||||
_event_value_shape: EVS,
|
||||
_events_node_proc: ENP,
|
||||
@@ -36,7 +36,7 @@ where
|
||||
Sitemty<<<ENP as EventsNodeProcessor>::Output as TimeBinnableType>::Output>:
|
||||
Framable + FrameType + DeserializeOwned,
|
||||
{
|
||||
let ret = PreBinnedValueStream::<NTY, END, EVS, ENP>::new(query, shape, agg_kind, node_config);
|
||||
let ret = PreBinnedValueStream::<NTY, END, EVS, ENP>::new(query, agg_kind, node_config);
|
||||
let ret = StreamExt::map(ret, |item| Box::new(item) as Box<dyn Framable>);
|
||||
Box::pin(ret)
|
||||
}
|
||||
@@ -138,9 +138,6 @@ macro_rules! match_end {
|
||||
};
|
||||
}
|
||||
|
||||
// TODO is the distinction on byte order necessary here?
|
||||
// We should rely on the "events" http api to deliver data, and the cache, both
|
||||
// of those have fixed endianness.
|
||||
fn make_num_pipeline(
|
||||
scalar_type: ScalarType,
|
||||
byte_order: ByteOrder,
|
||||
@@ -185,17 +182,11 @@ pub async fn pre_binned_bytes_for_http(
|
||||
));
|
||||
return Err(err);
|
||||
}
|
||||
let q = ChannelConfigQuery {
|
||||
channel: query.channel().clone(),
|
||||
range: query.patch().patch_range(),
|
||||
expand: query.agg_kind().need_expand(),
|
||||
};
|
||||
let conf = httpclient::get_channel_config(&q, node_config).await?;
|
||||
let ret = make_num_pipeline(
|
||||
conf.scalar_type.clone(),
|
||||
query.scalar_type().clone(),
|
||||
// TODO actually, make_num_pipeline should not depend on endianness.
|
||||
conf.byte_order.unwrap_or(ByteOrder::LE).clone(),
|
||||
conf.shape.clone(),
|
||||
ByteOrder::LE,
|
||||
query.shape().clone(),
|
||||
query.agg_kind().clone(),
|
||||
query.clone(),
|
||||
node_config,
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
use err::Error;
|
||||
use http::request::Parts;
|
||||
use netpod::query::{agg_kind_from_binning_scheme, binning_scheme_append_to_url, CacheUsage};
|
||||
use netpod::{channel_from_pairs, AggKind, AppendToUrl, ByteSize, Channel, PreBinnedPatchCoord};
|
||||
use netpod::{
|
||||
channel_append_to_url, channel_from_pairs, AggKind, AppendToUrl, ByteSize, Channel, PreBinnedPatchCoord,
|
||||
ScalarType, Shape,
|
||||
};
|
||||
use std::collections::BTreeMap;
|
||||
use url::Url;
|
||||
|
||||
@@ -10,6 +13,8 @@ pub struct PreBinnedQuery {
|
||||
patch: PreBinnedPatchCoord,
|
||||
agg_kind: AggKind,
|
||||
channel: Channel,
|
||||
scalar_type: ScalarType,
|
||||
shape: Shape,
|
||||
cache_usage: CacheUsage,
|
||||
disk_io_buffer_size: usize,
|
||||
disk_stats_every: ByteSize,
|
||||
@@ -20,6 +25,8 @@ impl PreBinnedQuery {
|
||||
pub fn new(
|
||||
patch: PreBinnedPatchCoord,
|
||||
channel: Channel,
|
||||
scalar_type: ScalarType,
|
||||
shape: Shape,
|
||||
agg_kind: AggKind,
|
||||
cache_usage: CacheUsage,
|
||||
disk_io_buffer_size: usize,
|
||||
@@ -28,8 +35,10 @@ impl PreBinnedQuery {
|
||||
) -> Self {
|
||||
Self {
|
||||
patch,
|
||||
agg_kind,
|
||||
channel,
|
||||
scalar_type,
|
||||
shape,
|
||||
agg_kind,
|
||||
cache_usage,
|
||||
disk_io_buffer_size,
|
||||
disk_stats_every,
|
||||
@@ -45,25 +54,35 @@ impl PreBinnedQuery {
|
||||
let pairs = pairs;
|
||||
let bin_t_len = pairs
|
||||
.get("binTlen")
|
||||
.ok_or(Error::with_msg("missing binTlen"))?
|
||||
.ok_or_else(|| Error::with_msg("missing binTlen"))?
|
||||
.parse()?;
|
||||
let patch_t_len = pairs
|
||||
.get("patchTlen")
|
||||
.ok_or(Error::with_msg("missing patchTlen"))?
|
||||
.ok_or_else(|| Error::with_msg("missing patchTlen"))?
|
||||
.parse()?;
|
||||
let patch_ix = pairs
|
||||
.get("patchIx")
|
||||
.ok_or(Error::with_msg("missing patchIx"))?
|
||||
.ok_or_else(|| Error::with_msg("missing patchIx"))?
|
||||
.parse()?;
|
||||
let disk_stats_every = pairs
|
||||
.get("diskStatsEveryKb")
|
||||
.ok_or(Error::with_msg("missing diskStatsEveryKb"))?;
|
||||
.ok_or_else(|| Error::with_msg("missing diskStatsEveryKb"))?;
|
||||
let disk_stats_every = disk_stats_every
|
||||
.parse()
|
||||
.map_err(|e| Error::with_msg(format!("can not parse diskStatsEveryKb {:?}", e)))?;
|
||||
let scalar_type = pairs
|
||||
.get("scalarType")
|
||||
.ok_or_else(|| Error::with_msg("missing scalarType"))
|
||||
.map(|x| ScalarType::from_url_str(&x))??;
|
||||
let shape = pairs
|
||||
.get("shape")
|
||||
.ok_or_else(|| Error::with_msg("missing shape"))
|
||||
.map(|x| Shape::from_url_str(&x))??;
|
||||
let ret = Self {
|
||||
patch: PreBinnedPatchCoord::new(bin_t_len, patch_t_len, patch_ix),
|
||||
channel: channel_from_pairs(&pairs)?,
|
||||
scalar_type,
|
||||
shape,
|
||||
agg_kind: agg_kind_from_binning_scheme(&pairs).unwrap_or(AggKind::DimXBins1),
|
||||
cache_usage: CacheUsage::from_pairs(&pairs)?,
|
||||
disk_io_buffer_size: pairs
|
||||
@@ -99,6 +118,14 @@ impl PreBinnedQuery {
|
||||
&self.channel
|
||||
}
|
||||
|
||||
pub fn scalar_type(&self) -> &ScalarType {
|
||||
&self.scalar_type
|
||||
}
|
||||
|
||||
pub fn shape(&self) -> &Shape {
|
||||
&self.shape
|
||||
}
|
||||
|
||||
pub fn agg_kind(&self) -> &AggKind {
|
||||
&self.agg_kind
|
||||
}
|
||||
@@ -120,9 +147,10 @@ impl AppendToUrl for PreBinnedQuery {
|
||||
fn append_to_url(&self, url: &mut Url) {
|
||||
self.patch.append_to_url(url);
|
||||
binning_scheme_append_to_url(&self.agg_kind, url);
|
||||
channel_append_to_url(url, &self.channel);
|
||||
let mut g = url.query_pairs_mut();
|
||||
g.append_pair("channelBackend", &self.channel.backend);
|
||||
g.append_pair("channelName", &self.channel.name);
|
||||
g.append_pair("scalarType", &format!("{:?}", self.scalar_type));
|
||||
g.append_pair("shape", &format!("{:?}", self.shape));
|
||||
g.append_pair("cacheUsage", &format!("{}", self.cache_usage.query_param_value()));
|
||||
g.append_pair("diskIoBufferSize", &format!("{}", self.disk_io_buffer_size));
|
||||
g.append_pair("diskStatsEveryKb", &format!("{}", self.disk_stats_every.bytes() / 1024));
|
||||
|
||||
Reference in New Issue
Block a user