From 7977c3c6b748f4f6c74aed8d67d72f33ba830367 Mon Sep 17 00:00:00 2001 From: Dominik Werder Date: Fri, 7 Mar 2025 11:41:44 +0100 Subject: [PATCH] Change byte estimate --- Cargo.toml | 11 ++++------- src/container.rs | 16 +++++++++++++++- src/event_value_type.rs | 1 + src/lib.rs | 1 + src/merge.rs | 18 ++++++++++-------- src/scalar_ops.rs | 10 +++------- 6 files changed, 34 insertions(+), 23 deletions(-) create mode 100644 src/event_value_type.rs diff --git a/Cargo.toml b/Cargo.toml index 3810506..fca8244 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "daqbuf-items-0" -version = "0.0.3" +version = "0.0.4" authors = ["Dominik Werder "] -edition = "2021" +edition = "2024" [lib] path = "src/lib.rs" @@ -14,12 +14,9 @@ typetag = "0.2" serde_json = "1" ciborium = "0.2.1" bincode = "1.3.3" -bytes = "1.8.0" +bytes = "1.10.0" futures-util = "0.3.24" -thiserror = "=0.0.1" +autoerr = "0.0.3" chrono = { version = "0.4.19", features = ["serde"] } netpod = { path = "../daqbuf-netpod", package = "daqbuf-netpod" } daqbuf-err = { path = "../daqbuf-err" } - -[patch.crates-io] -thiserror = { git = "https://github.com/dominikwerder/thiserror.git", branch = "cstm" } diff --git a/src/container.rs b/src/container.rs index 480af42..8a8b928 100644 --- a/src/container.rs +++ b/src/container.rs @@ -1,3 +1,17 @@ +use netpod::UnsupEvt; + pub trait ByteEstimate { - fn byte_estimate(&self) -> u64; + fn byte_estimate(&self) -> u32; +} + +impl ByteEstimate for UnsupEvt { + fn byte_estimate(&self) -> u32 { + 200 + } +} + +impl ByteEstimate for Vec { + fn byte_estimate(&self) -> u32 { + 200 + } } diff --git a/src/event_value_type.rs b/src/event_value_type.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/event_value_type.rs @@ -0,0 +1 @@ + diff --git a/src/lib.rs b/src/lib.rs index b55a413..85d3546 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ pub mod apitypes; pub mod collect_s; pub mod container; +pub mod event_value_type; pub mod events; pub mod framable; pub mod isodate; diff --git a/src/merge.rs b/src/merge.rs index dd70b7a..2195246 100644 --- a/src/merge.rs +++ b/src/merge.rs @@ -1,16 +1,18 @@ -use crate::container::ByteEstimate; -use crate::timebin::BinningggContainerEventsDyn; use crate::AsAnyMut; use crate::WithLen; -use core::ops::Range; -use netpod::TsMs; +use crate::container::ByteEstimate; +use crate::timebin::BinningggContainerEventsDyn; use netpod::TsNano; use std::collections::VecDeque; use std::fmt; +use std::ops::Range; -#[derive(Debug, thiserror::Error)] -#[cstm(name = "MergeError")] -pub enum Error {} +autoerr::create_error_v1!( + name(Error, "MergeError"), + enum variants { + Logic, + }, +); impl From for daqbuf_err::Error { fn from(e: Error) -> Self { @@ -59,7 +61,7 @@ pub trait MergeableDyn: fmt::Debug + WithLen + ByteEstimate + Unpin + AsAnyMut { fn find_highest_index_lt(&self, ts: TsNano) -> Option; fn tss_for_testing(&self) -> VecDeque; fn drain_into(&mut self, dst: &mut dyn MergeableDyn, range: Range) - -> DrainIntoDstResult; + -> DrainIntoDstResult; fn drain_into_new(&mut self, range: Range) -> DrainIntoNewDynResult; fn is_consistent(&self) -> bool; } diff --git a/src/scalar_ops.rs b/src/scalar_ops.rs index 058c493..dba41cc 100644 --- a/src/scalar_ops.rs +++ b/src/scalar_ops.rs @@ -48,11 +48,7 @@ impl_as_prim_f32!(f64); impl AsPrimF32 for bool { fn as_prim_f32_b(&self) -> f32 { - if *self { - 1. - } else { - 0. - } + if *self { 1. } else { 0. } } } @@ -87,7 +83,7 @@ pub trait ScalarOps: macro_rules! impl_scalar_ops { ($ty:ident, $zero:expr, $equal_slack:ident, $mac_add:ident, $mac_div:ident, $sty_name:expr, $byte_estimate:expr) => { impl ByteEstimate for $ty { - fn byte_estimate(&self) -> u64 { + fn byte_estimate(&self) -> u32 { $byte_estimate } } @@ -216,7 +212,7 @@ impl_scalar_ops!( ); impl ByteEstimate for EnumVariant { - fn byte_estimate(&self) -> u64 { + fn byte_estimate(&self) -> u32 { 12 } }