WIP on sf databuffer channel config decision

This commit is contained in:
Dominik Werder
2023-06-23 16:31:55 +02:00
parent 0260f4b4d6
commit 64d2996c48
26 changed files with 249 additions and 127 deletions
+29 -19
View File
@@ -960,7 +960,20 @@ mod serde_shape {
}
impl Shape {
pub fn from_bsread_jsval(v: &JsVal) -> Result<Shape, Error> {
pub fn from_sf_databuffer_raw(v: &Option<Vec<u32>>) -> Result<Self, Error> {
let ret = match v {
Some(a) => match a.len() {
0 => Shape::Scalar,
1 => Shape::Wave(a[0]),
2 => Shape::Image(a[0], a[1]),
_ => return Err(Error::with_msg_no_trace("can not understand sf databuffer shape spec")),
},
None => Shape::Scalar,
};
Ok(ret)
}
pub fn from_bsread_jsval(v: &JsVal) -> Result<Self, Error> {
match v {
JsVal::Array(v) => match v.len() {
0 => Ok(Shape::Scalar),
@@ -991,7 +1004,7 @@ impl Shape {
}
// TODO use simply a list to represent all shapes: empty, or with 1 or 2 entries.
pub fn from_db_jsval(v: &JsVal) -> Result<Shape, Error> {
pub fn from_db_jsval(v: &JsVal) -> Result<Self, Error> {
match v {
JsVal::String(s) => {
if s == "Scalar" {
@@ -1636,6 +1649,13 @@ impl PreBinnedPatchCoordEnum {
todo!()
}
pub fn patch_range(&self) -> SeriesRange {
match self {
PreBinnedPatchCoordEnum::Time(k) => k.series_range(),
PreBinnedPatchCoordEnum::Pulse(k) => k.series_range(),
}
}
pub fn span_desc(&self) -> String {
match self {
PreBinnedPatchCoordEnum::Time(k) => {
@@ -2228,32 +2248,22 @@ impl ReadExactStats {
}
}
#[derive(Clone, Debug)]
pub struct PerfOpts {
pub inmem_bufcap: usize,
}
impl PerfOpts {
pub fn default() -> Self {
Self {
inmem_bufcap: 1024 * 512,
}
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ByteSize(pub u32);
impl ByteSize {
pub fn b(b: u32) -> Self {
pub fn from_bytes(b: u32) -> Self {
Self(b)
}
pub fn kb(kb: u32) -> Self {
pub fn from_kb(kb: u32) -> Self {
Self(1024 * kb)
}
pub fn mb(mb: u32) -> Self {
pub fn from_mb(mb: u32) -> Self {
Self(1024 * 1024 * mb)
}
pub fn bytes(&self) -> u32 {
self.0
}
@@ -2454,7 +2464,7 @@ pub fn get_url_query_pairs(url: &Url) -> BTreeMap<String, String> {
// At least on some backends the channel configuration may change depending on the queried range.
// Therefore, the query includes the range.
// The presence of a configuration in some range does not imply that there is any data available.
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChannelConfigQuery {
pub channel: SfDbChannel,
pub range: NanoRange,
+12
View File
@@ -3,6 +3,7 @@ use crate::{DiskIoTune, FileIoBufferSize, ReadSys};
use err::Error;
use serde::{Deserialize, Serialize};
use std::fmt;
use std::time::Duration;
fn bool_true() -> bool {
true
@@ -225,6 +226,8 @@ mod serde_channel_tuple {
pub struct Api1Query {
range: Api1Range,
channels: Vec<ChannelTuple>,
#[serde(default, skip_serializing_if = "Option::is_none")]
timeout: Option<Duration>,
// All following parameters are private and not to be used
#[serde(default, skip_serializing_if = "Option::is_none")]
file_io_buffer_size: Option<FileIoBufferSize>,
@@ -245,6 +248,7 @@ impl Api1Query {
Self {
range,
channels,
timeout: None,
decompress: true,
events_max: None,
file_io_buffer_size: None,
@@ -275,6 +279,14 @@ impl Api1Query {
&self.channels
}
pub fn timeout(&self) -> Option<Duration> {
self.timeout
}
pub fn timeout_or_default(&self) -> Duration {
Duration::from_secs(60 * 30)
}
pub fn log_level(&self) -> &str {
&self.log_level
}
+1 -1
View File
@@ -76,7 +76,7 @@ impl PreBinnedQuery {
.get("diskStatsEveryKb")
.map(|k| k.parse().ok())
.unwrap_or(None)
.map(ByteSize::kb),
.map(ByteSize::from_kb),
};
Ok(ret)
}