Use unweighted binning as default
This commit is contained in:
@@ -78,6 +78,29 @@ fn time_weighted_json_02() {
|
||||
super::run_test(inner());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn time_weighted_json_03() {
|
||||
async fn inner() -> Result<(), Error> {
|
||||
let rh = require_test_hosts_running()?;
|
||||
let cluster = &rh.cluster;
|
||||
let res = get_json_common(
|
||||
"const-regular-scalar-i32-be",
|
||||
"1970-01-01T00:20:11.000Z",
|
||||
"1970-01-01T00:30:20.000Z",
|
||||
10,
|
||||
AggKind::TimeWeightedScalar,
|
||||
cluster,
|
||||
11,
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
let v = res.avgs[0];
|
||||
assert!(v > 41.9999 && v < 42.0001);
|
||||
Ok(())
|
||||
}
|
||||
super::run_test(inner());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn time_weighted_json_10() {
|
||||
async fn inner() -> Result<(), Error> {
|
||||
|
||||
@@ -69,7 +69,7 @@ impl PreBinnedQuery {
|
||||
let ret = Self {
|
||||
patch: PreBinnedPatchCoord::new(bin_t_len, patch_t_len, patch_ix),
|
||||
channel: channel_from_pairs(&pairs)?,
|
||||
agg_kind: agg_kind_from_binning_scheme(&pairs).unwrap_or(AggKind::TimeWeightedScalar),
|
||||
agg_kind: agg_kind_from_binning_scheme(&pairs).unwrap_or(AggKind::DimXBins1),
|
||||
cache_usage: CacheUsage::from_pairs(&pairs)?,
|
||||
disk_io_buffer_size: pairs
|
||||
.get("diskIoBufferSize")
|
||||
@@ -312,7 +312,7 @@ impl FromUrl for BinnedQuery {
|
||||
.ok_or(Error::with_msg("missing binCount"))?
|
||||
.parse()
|
||||
.map_err(|e| Error::with_msg(format!("can not parse binCount {:?}", e)))?,
|
||||
agg_kind: agg_kind_from_binning_scheme(&pairs).unwrap_or(AggKind::TimeWeightedScalar),
|
||||
agg_kind: agg_kind_from_binning_scheme(&pairs).unwrap_or(AggKind::DimXBins1),
|
||||
cache_usage: CacheUsage::from_pairs(&pairs)?,
|
||||
disk_io_buffer_size: pairs
|
||||
.get("diskIoBufferSize")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::api1::{channel_search_configs_v1, channel_search_list_v1, gather_json_2_v1, proxy_distribute_v1};
|
||||
use crate::gather::{gather_get_json_generic, SubRes};
|
||||
use crate::{api_4_docs, response, Cont};
|
||||
use crate::{api_1_docs, api_4_docs, response, Cont};
|
||||
use disk::binned::query::BinnedQuery;
|
||||
use disk::events::PlainEventsJsonQuery;
|
||||
use err::Error;
|
||||
@@ -86,7 +86,7 @@ async fn proxy_http_service_try(req: Request<Body>, proxy_config: &ProxyConfig)
|
||||
proxy_distribute_v1(req).await
|
||||
} else if path.starts_with("/api/1/documentation/") {
|
||||
if req.method() == Method::GET {
|
||||
Ok(response(StatusCode::NOT_FOUND).body(Body::empty())?)
|
||||
api_1_docs(path)
|
||||
} else {
|
||||
Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?)
|
||||
}
|
||||
|
||||
@@ -194,12 +194,12 @@ curl -H 'Accept: application/json' 'https://data-api.psi.ch/api/4/events?channel
|
||||
<li>channelName (e.g. "SLAAR-LSCP4-LAS6891:CH7:1")</li>
|
||||
<li>begDate (e.g. "2021-05-26T07:10:00.000Z")</li>
|
||||
<li>endDate (e.g. "2021-05-26T07:16:00.000Z")</li>
|
||||
<li>binCount (number of requested bins in time-dimension, e.g. "6")</li>
|
||||
<li>binCount (number of requested bins in time-dimension, e.g. "6". The actual number of returned bins depends on bin-cache-grid-resolution. The server tries to find the best match.)</li>
|
||||
<li>binningScheme (optional)</li>
|
||||
<ul>
|
||||
<li>if not specified: default is "binningScheme=timeWeightedScalar".</li>
|
||||
<li>"binningScheme=timeWeightedScalar": time-weighted binning, waveform gets first averaged to a scalar.</li>
|
||||
<li>if not specified: default is "binningScheme=unweightedScalar".</li>
|
||||
<li>"binningScheme=unweightedScalar": non-weighted binning, waveform gets first averaged to a scalar.</li>
|
||||
<li>"binningScheme=timeWeightedScalar": time-weighted binning, waveform gets first averaged to a scalar.</li>
|
||||
<li>"binningScheme=binnedX&binnedXcount=13": waveform gets first binned to 13 bins in X-dimension (waveform-dimension).</li>
|
||||
<li>"binningScheme=binnedX&binnedXcount=0": waveform is not binned in X-dimension but kept at full length.</li>
|
||||
</ul>
|
||||
|
||||
@@ -7,7 +7,6 @@ use crate::{
|
||||
WithLen, WithTimestamps,
|
||||
};
|
||||
use err::Error;
|
||||
use netpod::log::*;
|
||||
use netpod::timeunits::*;
|
||||
use netpod::NanoRange;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -365,7 +364,6 @@ where
|
||||
self.last_ts = ts;
|
||||
self.last_val = Some(val);
|
||||
} else if ts >= self.range.end {
|
||||
info!("event after {}", ts / MS);
|
||||
return;
|
||||
} else {
|
||||
self.count += 1;
|
||||
|
||||
@@ -180,8 +180,8 @@ where
|
||||
type Output = MinMaxAvgBins<NTY>;
|
||||
type Aggregator = MinMaxAvgBinsAggregator<NTY>;
|
||||
|
||||
fn aggregator(range: NanoRange, _x_bin_count: usize, _do_time_weight: bool) -> Self::Aggregator {
|
||||
Self::Aggregator::new(range)
|
||||
fn aggregator(range: NanoRange, _x_bin_count: usize, do_time_weight: bool) -> Self::Aggregator {
|
||||
Self::Aggregator::new(range, do_time_weight)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ pub struct MinMaxAvgBinsAggregator<NTY> {
|
||||
}
|
||||
|
||||
impl<NTY> MinMaxAvgBinsAggregator<NTY> {
|
||||
pub fn new(range: NanoRange) -> Self {
|
||||
pub fn new(range: NanoRange, _do_time_weight: bool) -> Self {
|
||||
Self {
|
||||
range,
|
||||
count: 0,
|
||||
@@ -357,9 +357,7 @@ where
|
||||
fn ingest(&mut self, item: &Self::Input) {
|
||||
for i1 in 0..item.ts1s.len() {
|
||||
if item.ts2s[i1] <= self.range.beg {
|
||||
continue;
|
||||
} else if item.ts1s[i1] >= self.range.end {
|
||||
continue;
|
||||
} else {
|
||||
self.min = match self.min {
|
||||
None => item.mins[i1],
|
||||
|
||||
@@ -181,8 +181,8 @@ where
|
||||
type Output = MinMaxAvgDim1Bins<NTY>;
|
||||
type Aggregator = MinMaxAvgDim1BinsAggregator<NTY>;
|
||||
|
||||
fn aggregator(range: NanoRange, x_bin_count: usize, _do_time_weight: bool) -> Self::Aggregator {
|
||||
Self::Aggregator::new(range, x_bin_count)
|
||||
fn aggregator(range: NanoRange, x_bin_count: usize, do_time_weight: bool) -> Self::Aggregator {
|
||||
Self::Aggregator::new(range, x_bin_count, do_time_weight)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +325,10 @@ pub struct MinMaxAvgDim1BinsAggregator<NTY> {
|
||||
}
|
||||
|
||||
impl<NTY> MinMaxAvgDim1BinsAggregator<NTY> {
|
||||
pub fn new(range: NanoRange, _x_bin_count: usize) -> Self {
|
||||
pub fn new(range: NanoRange, _x_bin_count: usize, do_time_weight: bool) -> Self {
|
||||
if do_time_weight {
|
||||
err::todo();
|
||||
}
|
||||
Self {
|
||||
range,
|
||||
count: 0,
|
||||
|
||||
@@ -179,8 +179,8 @@ where
|
||||
type Output = MinMaxAvgWaveBins<NTY>;
|
||||
type Aggregator = MinMaxAvgWaveBinsAggregator<NTY>;
|
||||
|
||||
fn aggregator(range: NanoRange, x_bin_count: usize, _do_time_weight: bool) -> Self::Aggregator {
|
||||
Self::Aggregator::new(range, x_bin_count)
|
||||
fn aggregator(range: NanoRange, x_bin_count: usize, do_time_weight: bool) -> Self::Aggregator {
|
||||
Self::Aggregator::new(range, x_bin_count, do_time_weight)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,10 @@ impl<NTY> MinMaxAvgWaveBinsAggregator<NTY>
|
||||
where
|
||||
NTY: NumOps,
|
||||
{
|
||||
pub fn new(range: NanoRange, x_bin_count: usize) -> Self {
|
||||
pub fn new(range: NanoRange, x_bin_count: usize, do_time_weight: bool) -> Self {
|
||||
if do_time_weight {
|
||||
err::todo();
|
||||
}
|
||||
Self {
|
||||
range,
|
||||
count: 0,
|
||||
|
||||
@@ -171,7 +171,10 @@ impl<NTY> WaveEventsAggregator<NTY>
|
||||
where
|
||||
NTY: NumOps,
|
||||
{
|
||||
pub fn new(range: NanoRange, _x_bin_count: usize, _do_time_weight: bool) -> Self {
|
||||
pub fn new(range: NanoRange, _x_bin_count: usize, do_time_weight: bool) -> Self {
|
||||
if do_time_weight {
|
||||
err::todo();
|
||||
}
|
||||
Self {
|
||||
range,
|
||||
count: 0,
|
||||
|
||||
@@ -178,7 +178,10 @@ impl<NTY> XBinnedWaveEventsAggregator<NTY>
|
||||
where
|
||||
NTY: NumOps,
|
||||
{
|
||||
pub fn new(range: NanoRange, bin_count: usize, _do_time_weight: bool) -> Self {
|
||||
pub fn new(range: NanoRange, bin_count: usize, do_time_weight: bool) -> Self {
|
||||
if do_time_weight {
|
||||
err::todo();
|
||||
}
|
||||
if bin_count == 0 {
|
||||
panic!("bin_count == 0");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user