-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up for version bump, add all window
- Loading branch information
Showing
12 changed files
with
339 additions
and
201 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
name = "renoir" | ||
description = "Reactive Network of Operators In Rust" | ||
version = "0.3.0" | ||
version = "0.4.0" | ||
edition = "2021" | ||
authors = [ | ||
"Luca De Martini <[email protected]>", | ||
|
@@ -26,7 +26,7 @@ rdkafka = ["dep:rdkafka", "tokio"] | |
|
||
[dependencies] | ||
# for logging to the console | ||
log = { version = "0.4.22", features = ["release_max_level_info"] } | ||
log = { version = "0.4.25", features = ["release_max_level_info"] } | ||
|
||
# used by the network for storing type-generic structures | ||
typemap_rev = "0.3.0" | ||
|
@@ -38,12 +38,12 @@ nanorand = "0.7.0" | |
derivative = "2.2.0" | ||
|
||
# serialization | ||
serde = { version = "1.0.215", features = ["derive"] } | ||
serde_json = "1.0.133" | ||
serde = { version = "1.0.217", features = ["derive"] } | ||
serde_json = "1.0.137" | ||
bincode = "1.3.3" | ||
toml = "0.8.19" | ||
|
||
thiserror = "2.0.3" | ||
thiserror = "2.0.11" | ||
|
||
# handy iterators functions | ||
|
||
|
@@ -54,7 +54,7 @@ once_cell = "1.20.2" | |
ssh2 = { version = "0.9.4", optional = true } | ||
whoami = { version = "1.5.2", optional = true } | ||
shell-escape = { version = "0.1.5", optional = true } | ||
clap = { version = "4.5.21", features = ["derive"], optional = true } | ||
clap = { version = "4.5.27", features = ["derive"], optional = true } | ||
sha2 = { version = "0.10.8", optional = true } | ||
base64 = { version = "0.22.1", optional = true } | ||
|
||
|
@@ -68,34 +68,34 @@ csv = "1.3.1" | |
lazy-init = "0.5.1" | ||
|
||
# Faster monotonic clock using libc's CLOCK_MONOTONIC_COARSE | ||
coarsetime = "0.1.34" | ||
coarsetime = "0.1.35" | ||
|
||
tokio = { version = "1.41.1", features = ["rt"], default-features = false, optional = true } | ||
tokio = { version = "1.43.0", features = ["rt"], default-features = false, optional = true } | ||
futures = { version = "0.3.31", optional = true } | ||
|
||
parking_lot = "0.12.3" | ||
|
||
wyhash = "0.5.0" | ||
fxhash = "0.2.1" | ||
glidesort = "0.1.2" | ||
indexmap = "2.7.0" | ||
indexmap = "2.7.1" | ||
tracing = { version = "0.1.41", features = ["log"] } | ||
quick_cache = "0.6.9" | ||
dashmap = "6.1.0" | ||
dyn-clone = "1.0.17" | ||
|
||
apache-avro = { version = "0.17.0", features = ["derive"], optional = true } | ||
parquet = { version = "53.3.0", optional = true } | ||
arrow = { version = "53.3.0", optional = true } | ||
parquet = { version = "53.4.0", optional = true } | ||
arrow = { version = "53.4.0", optional = true } | ||
rdkafka = { version = "0.37.0", optional = true } | ||
|
||
[dev-dependencies] | ||
# for the tests | ||
env_logger = "0.11.5" | ||
env_logger = "0.11.6" | ||
rand = { version = "0.8.5", features = ["small_rng"] } | ||
tempfile = "3.14.0" | ||
tempfile = "3.15.0" | ||
criterion = { version = "0.5.1", features = ["html_reports"] } | ||
fake = "3.0.1" | ||
fake = "3.1.0" | ||
mimalloc = { version = "0.1.43", default-features = false } | ||
tracing-subscriber = "0.3.19" | ||
itertools = "0.13.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
//! The types related to the windowed streams. | ||
use crate::operator::{Data, StreamElement, Timestamp}; | ||
|
||
use super::super::*; | ||
|
||
#[derive(Clone)] | ||
pub struct AllWindowManager<A> { | ||
init: A, | ||
accumulator: Option<A>, | ||
tsmin: Option<Timestamp>, | ||
} | ||
|
||
impl<A: WindowAccumulator> WindowManager for AllWindowManager<A> | ||
where | ||
A::In: Data, | ||
A::Out: Data, | ||
{ | ||
type In = A::In; | ||
type Out = A::Out; | ||
type Output = Option<WindowResult<A::Out>>; | ||
|
||
#[inline] | ||
fn process(&mut self, el: StreamElement<A::In>) -> Self::Output { | ||
let ts = el.timestamp().cloned(); | ||
self.tsmin = match (ts, self.tsmin.take()) { | ||
(Some(a), Some(b)) => Some(a.min(b)), | ||
(Some(a), None) | (None, Some(a)) => Some(a), | ||
(None, None) => None, | ||
}; | ||
match el { | ||
StreamElement::Item(item) | StreamElement::Timestamped(item, _) => { | ||
self.accumulator | ||
.get_or_insert_with(|| self.init.clone()) | ||
.process(item); | ||
None | ||
} | ||
StreamElement::FlushAndRestart => Some(WindowResult::new( | ||
self.accumulator.take().unwrap().output(), | ||
self.tsmin.take(), | ||
)), | ||
StreamElement::Terminate => self | ||
.accumulator | ||
.take() | ||
.map(|a| WindowResult::new(a.output(), self.tsmin.take())), | ||
_ => None, | ||
} | ||
} | ||
} | ||
|
||
/// Window of fixed count of elements | ||
#[derive(Clone, Default)] | ||
pub struct AllWindow; | ||
|
||
impl AllWindow { | ||
/// Windows that contains all elements until the stream is flushed and restarted or terminated. | ||
#[inline] | ||
pub fn new() -> Self { | ||
Self | ||
} | ||
} | ||
|
||
impl<T: Data> WindowDescription<T> for AllWindow { | ||
type Manager<A: WindowAccumulator<In = T>> = AllWindowManager<A>; | ||
|
||
#[inline] | ||
fn build<A: WindowAccumulator<In = T>>(&self, accumulator: A) -> Self::Manager<A> { | ||
AllWindowManager { | ||
init: accumulator, | ||
accumulator: None, | ||
tsmin: None, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crate::operator::window::aggr::Fold; | ||
|
||
macro_rules! check_return { | ||
($ret:expr, $v:expr) => {{ | ||
let mut ia = $ret.into_iter(); | ||
let mut ib = $v.into_iter(); | ||
loop { | ||
let (a, b) = (ia.next(), ib.next()); | ||
assert_eq!(a, b); | ||
|
||
if let (None, None) = (a, b) { | ||
break; | ||
} | ||
} | ||
}}; | ||
} | ||
|
||
#[test] | ||
fn all_window() { | ||
let window = AllWindow::new(); | ||
|
||
let fold: Fold<isize, Vec<isize>, _> = Fold::new(Vec::new(), |v, el| v.push(el)); | ||
let mut manager = window.build(fold); | ||
|
||
for i in 1..100 { | ||
check_return!(manager.process(StreamElement::Item(i)), None); | ||
} | ||
|
||
check_return!( | ||
manager.process(StreamElement::FlushAndRestart), | ||
Some(WindowResult::Item((1..100).collect())) | ||
); | ||
check_return!(manager.process(StreamElement::Terminate), None); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters