Remove crate items
This commit is contained in:
@@ -40,7 +40,6 @@ query = { path = "../query" }
|
||||
bitshuffle = { path = "../bitshuffle" }
|
||||
dbconn = { path = "../dbconn" }
|
||||
parse = { path = "../parse" }
|
||||
items = { path = "../items" }
|
||||
items_0 = { path = "../items_0" }
|
||||
items_2 = { path = "../items_2" }
|
||||
streams = { path = "../streams" }
|
||||
|
||||
@@ -5,6 +5,7 @@ use netpod::ChannelConfig;
|
||||
use netpod::NodeConfigCached;
|
||||
use parse::channelconfig::extract_matching_config_entry;
|
||||
use parse::channelconfig::read_local_config;
|
||||
use parse::channelconfig::ChannelConfigs;
|
||||
use parse::channelconfig::MatchingConfigEntry;
|
||||
|
||||
pub async fn config(
|
||||
@@ -12,14 +13,24 @@ pub async fn config(
|
||||
channel: Channel,
|
||||
node_config: &NodeConfigCached,
|
||||
) -> Result<ChannelConfig, Error> {
|
||||
let channel_config = read_local_config(channel.clone(), node_config.node.clone()).await?;
|
||||
let entry_res = match extract_matching_config_entry(&range, &channel_config) {
|
||||
let channel_configs = read_local_config(channel.clone(), node_config.node.clone()).await?;
|
||||
let entry_res = match extract_matching_config_entry(&range, &channel_configs) {
|
||||
Ok(k) => k,
|
||||
Err(e) => return Err(e)?,
|
||||
};
|
||||
let entry = match entry_res {
|
||||
MatchingConfigEntry::None => return Err(Error::with_public_msg("no config entry found"))?,
|
||||
MatchingConfigEntry::Multiple => return Err(Error::with_public_msg("multiple config entries found"))?,
|
||||
MatchingConfigEntry::None => {
|
||||
return Err(Error::with_public_msg(format!(
|
||||
"disk::channelconfig no config entry found for {:?}",
|
||||
channel
|
||||
)))?
|
||||
}
|
||||
MatchingConfigEntry::Multiple => {
|
||||
return Err(Error::with_public_msg(format!(
|
||||
"disk::channelconfig multiple config entries in range found for {:?}",
|
||||
channel
|
||||
)))?
|
||||
}
|
||||
MatchingConfigEntry::Entry(entry) => entry,
|
||||
};
|
||||
let shape = match entry.to_shape() {
|
||||
@@ -30,7 +41,7 @@ pub async fn config(
|
||||
channel: channel.clone(),
|
||||
keyspace: entry.ks as u8,
|
||||
time_bin_size: entry.bs.clone(),
|
||||
shape: shape,
|
||||
shape,
|
||||
scalar_type: entry.scalar_type.clone(),
|
||||
byte_order: entry.byte_order.clone(),
|
||||
array: entry.is_array,
|
||||
@@ -38,3 +49,7 @@ pub async fn config(
|
||||
};
|
||||
Ok(channel_config)
|
||||
}
|
||||
|
||||
pub async fn configs(channel: Channel, node_config: &NodeConfigCached) -> Result<ChannelConfigs, Error> {
|
||||
read_local_config(channel.clone(), node_config.node.clone()).await
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use items_0::streamitem::LogItem;
|
||||
use items_0::streamitem::RangeCompletableItem;
|
||||
use items_0::streamitem::Sitemty;
|
||||
use items_0::streamitem::StreamItem;
|
||||
use items_0::WithLen;
|
||||
use items_2::eventfull::EventFull;
|
||||
use items_2::merger::Merger;
|
||||
use netpod::log::*;
|
||||
@@ -93,9 +94,7 @@ impl Stream for EventChunkerMultifile {
|
||||
type Item = Result<StreamItem<RangeCompletableItem<EventFull>>, Error>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
//tracing::field::DebugValue;
|
||||
let span1 = span!(Level::INFO, "EvChMul", node_ix = self.node_ix);
|
||||
//span1.record("node_ix", &self.node_ix);
|
||||
let _spg = span1.enter();
|
||||
use Poll::*;
|
||||
'outer: loop {
|
||||
@@ -117,7 +116,7 @@ impl Stream for EventChunkerMultifile {
|
||||
Ready(Some(Ok(k))) => {
|
||||
let k = if let StreamItem::DataItem(RangeCompletableItem::Data(h)) = k {
|
||||
let mut h: EventFull = h;
|
||||
if h.tss.len() > 0 {
|
||||
if h.len() > 0 {
|
||||
let min = h.tss.iter().fold(u64::MAX, |a, &x| a.min(x));
|
||||
let max = h.tss.iter().fold(u64::MIN, |a, &x| a.max(x));
|
||||
if min <= self.max_ts {
|
||||
@@ -131,7 +130,7 @@ impl Stream for EventChunkerMultifile {
|
||||
"EventChunkerMultifile emit {}/{} events {}",
|
||||
self.emit_count,
|
||||
after,
|
||||
h.tss.len()
|
||||
h.len()
|
||||
);
|
||||
self.emit_count += 1;
|
||||
}
|
||||
@@ -224,9 +223,6 @@ impl Stream for EventChunkerMultifile {
|
||||
self.expand,
|
||||
self.do_decompress,
|
||||
);
|
||||
let chunker = chunker
|
||||
//.map(|x| Ok(StreamItem::DataItem(RangeCompletableItem::Data(x))))
|
||||
;
|
||||
chunkers.push(Box::pin(chunker) as _);
|
||||
}
|
||||
}
|
||||
@@ -270,6 +266,7 @@ mod test {
|
||||
use futures_util::StreamExt;
|
||||
use items_0::streamitem::RangeCompletableItem;
|
||||
use items_0::streamitem::StreamItem;
|
||||
use items_0::WithLen;
|
||||
use netpod::log::*;
|
||||
use netpod::range::evrange::NanoRange;
|
||||
use netpod::timeunits::DAY;
|
||||
@@ -328,7 +325,7 @@ mod test {
|
||||
RangeCompletableItem::Data(item) => {
|
||||
// TODO assert more
|
||||
debug!("item: {:?}", item.tss.iter().map(|x| x / MS).collect::<Vec<_>>());
|
||||
event_count += item.tss.len();
|
||||
event_count += item.len();
|
||||
for ts in item.tss {
|
||||
tss.push(ts);
|
||||
}
|
||||
|
||||
@@ -64,11 +64,13 @@ pub async fn make_event_pipe(
|
||||
}
|
||||
}
|
||||
let range = evq.range().clone();
|
||||
let channel_config = match read_local_config(evq.channel().clone(), node_config.node.clone()).await {
|
||||
Ok(k) => k,
|
||||
let channel_config =
|
||||
crate::channelconfig::config(evq.range().try_into()?, evq.channel().clone(), node_config).await;
|
||||
let channel_config = match channel_config {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
// TODO introduce detailed error type
|
||||
if e.msg().contains("ErrorKind::NotFound") {
|
||||
warn!("{e}");
|
||||
let s = futures_util::stream::empty();
|
||||
return Ok(Box::pin(s));
|
||||
} else {
|
||||
@@ -76,29 +78,6 @@ pub async fn make_event_pipe(
|
||||
}
|
||||
}
|
||||
};
|
||||
let entry_res = match extract_matching_config_entry(&(&range).try_into()?, &channel_config) {
|
||||
Ok(k) => k,
|
||||
Err(e) => return Err(e)?,
|
||||
};
|
||||
let entry = match entry_res {
|
||||
MatchingConfigEntry::None => return Err(Error::with_public_msg("no config entry found"))?,
|
||||
MatchingConfigEntry::Multiple => return Err(Error::with_public_msg("multiple config entries found"))?,
|
||||
MatchingConfigEntry::Entry(entry) => entry,
|
||||
};
|
||||
let shape = match entry.to_shape() {
|
||||
Ok(k) => k,
|
||||
Err(e) => return Err(e)?,
|
||||
};
|
||||
let channel_config = netpod::ChannelConfig {
|
||||
channel: evq.channel().clone(),
|
||||
keyspace: entry.ks as u8,
|
||||
time_bin_size: entry.bs.clone(),
|
||||
shape,
|
||||
scalar_type: entry.scalar_type.clone(),
|
||||
byte_order: entry.byte_order.clone(),
|
||||
array: entry.is_array,
|
||||
compression: entry.is_compressed,
|
||||
};
|
||||
trace!(
|
||||
"make_event_pipe need_expand {need_expand} {evq:?}",
|
||||
need_expand = evq.one_before_range()
|
||||
@@ -122,14 +101,10 @@ pub async fn make_event_pipe(
|
||||
true,
|
||||
out_max_len,
|
||||
);
|
||||
let shape = entry.to_shape()?;
|
||||
let scalar_type = channel_config.scalar_type.clone();
|
||||
let shape = channel_config.shape.clone();
|
||||
error!("TODO replace AggKind in the called code");
|
||||
let pipe = make_num_pipeline_stream_evs(
|
||||
entry.scalar_type.clone(),
|
||||
shape.clone(),
|
||||
AggKind::TimeWeightedScalar,
|
||||
event_blobs,
|
||||
);
|
||||
let pipe = make_num_pipeline_stream_evs(scalar_type, shape.clone(), AggKind::TimeWeightedScalar, event_blobs);
|
||||
Ok(pipe)
|
||||
}
|
||||
|
||||
@@ -138,14 +113,24 @@ pub async fn get_applicable_entry(
|
||||
channel: Channel,
|
||||
node_config: &NodeConfigCached,
|
||||
) -> Result<ConfigEntry, Error> {
|
||||
let channel_config = read_local_config(channel, node_config.node.clone()).await?;
|
||||
let channel_config = read_local_config(channel.clone(), node_config.node.clone()).await?;
|
||||
let entry_res = match extract_matching_config_entry(range, &channel_config) {
|
||||
Ok(k) => k,
|
||||
Err(e) => return Err(e)?,
|
||||
};
|
||||
let entry = match entry_res {
|
||||
MatchingConfigEntry::None => return Err(Error::with_public_msg("no config entry found"))?,
|
||||
MatchingConfigEntry::Multiple => return Err(Error::with_public_msg("multiple config entries found"))?,
|
||||
MatchingConfigEntry::None => {
|
||||
return Err(Error::with_public_msg(format!(
|
||||
"get_applicable_entry no config entry found {:?}",
|
||||
channel
|
||||
)))?
|
||||
}
|
||||
MatchingConfigEntry::Multiple => {
|
||||
return Err(Error::with_public_msg(format!(
|
||||
"get_applicable_entry multiple config entries found for {:?}",
|
||||
channel
|
||||
)))?
|
||||
}
|
||||
MatchingConfigEntry::Entry(entry) => entry,
|
||||
};
|
||||
Ok(entry.clone())
|
||||
@@ -259,7 +244,21 @@ pub async fn make_event_blobs_pipe(
|
||||
}
|
||||
let expand = evq.one_before_range();
|
||||
let range = evq.range();
|
||||
let entry = get_applicable_entry(&evq.range().try_into()?, evq.channel().clone(), node_config).await?;
|
||||
let entry = match get_applicable_entry(&evq.range().try_into()?, evq.channel().clone(), node_config).await {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
if e.to_public_error().msg().contains("no config entry found") {
|
||||
let item = items_0::streamitem::LogItem {
|
||||
node_ix: node_config.ix as _,
|
||||
level: Level::WARN,
|
||||
msg: format!("{} {}", node_config.node.host, e),
|
||||
};
|
||||
return Ok(Box::pin(stream::iter([Ok(StreamItem::Log(item))])));
|
||||
} else {
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
let event_chunker_conf = EventChunkerConf::new(ByteSize::kb(1024));
|
||||
type ItemType = Sitemty<EventFull>;
|
||||
// TODO should depend on host config
|
||||
|
||||
Reference in New Issue
Block a user