From d9634f242a97c06bdb53011bf3d75256425a1598 Mon Sep 17 00:00:00 2001 From: Shadaj Laddad Date: Tue, 5 Nov 2024 10:18:49 -0800 Subject: [PATCH] refactor(hydroflow_plus): split up location module and store locations directly in streams (#1523) --- hydroflow_plus/src/builder/deploy.rs | 6 +- hydroflow_plus/src/builder/mod.rs | 75 +- hydroflow_plus/src/cycle.rs | 12 +- hydroflow_plus/src/lib.rs | 4 +- hydroflow_plus/src/location.rs | 702 ------------------ hydroflow_plus/src/location/can_send.rs | 76 ++ hydroflow_plus/src/location/cluster.rs | 227 ++++++ .../src/location/external_process.rs | 139 ++++ hydroflow_plus/src/location/mod.rs | 332 +++++++++ hydroflow_plus/src/location/process.rs | 41 + hydroflow_plus/src/location/tick.rs | 34 + hydroflow_plus/src/singleton.rs | 318 +++----- hydroflow_plus/src/stream.rs | 236 ++---- ...ter__compute_pi__tests__compute_pi_ir.snap | 8 +- ..._tests__compute_pi_ir@surface_graph_1.snap | 6 +- ...er__many_to_many__tests__many_to_many.snap | 4 +- ...ter__map_reduce__tests__map_reduce_ir.snap | 4 +- ..._tests__map_reduce_ir@surface_graph_0.snap | 4 +- ...cluster__paxos_bench__tests__paxos_ir.snap | 166 ++--- ...simple_cluster__tests__simple_cluster.snap | 16 +- .../src/distributed/first_ten.rs | 3 +- 21 files changed, 1168 insertions(+), 1245 deletions(-) delete mode 100644 hydroflow_plus/src/location.rs create mode 100644 hydroflow_plus/src/location/can_send.rs create mode 100644 hydroflow_plus/src/location/cluster.rs create mode 100644 hydroflow_plus/src/location/external_process.rs create mode 100644 hydroflow_plus/src/location/mod.rs create mode 100644 hydroflow_plus/src/location/process.rs create mode 100644 hydroflow_plus/src/location/tick.rs diff --git a/hydroflow_plus/src/builder/deploy.rs b/hydroflow_plus/src/builder/deploy.rs index bc70ab3a2aa9..c345d7f7bf43 100644 --- a/hydroflow_plus/src/builder/deploy.rs +++ b/hydroflow_plus/src/builder/deploy.rs @@ -13,10 +13,10 @@ use stageleft::Quoted; use super::built::build_inner; use crate::deploy::{ExternalSpec, LocalDeploy, Node, RegisterPort}; use crate::ir::HfPlusLeaf; -use crate::location::{ - ExternalBincodeSink, ExternalBincodeStream, ExternalBytesPort, ExternalProcess, Location, - LocationId, +use crate::location::external_process::{ + ExternalBincodeSink, ExternalBincodeStream, ExternalBytesPort, }; +use crate::location::{ExternalProcess, Location, LocationId}; use crate::{Cluster, ClusterSpec, Deploy, HfCompiled, Process, ProcessSpec}; pub struct DeployFlow<'a, D: LocalDeploy<'a>> { diff --git a/hydroflow_plus/src/builder/mod.rs b/hydroflow_plus/src/builder/mod.rs index 593b7fb23ffc..e4c65a069a95 100644 --- a/hydroflow_plus/src/builder/mod.rs +++ b/hydroflow_plus/src/builder/mod.rs @@ -3,16 +3,11 @@ use std::collections::HashMap; use std::marker::PhantomData; use std::rc::Rc; -use internal::TokenStream; -use proc_macro2::Span; -use quote::quote; -use runtime_support::FreeVariable; use stageleft::*; -use super::staging_util::get_this_crate; use crate::ir::HfPlusLeaf; use crate::location::{Cluster, ExternalProcess, Process}; -use crate::{ClusterId, RuntimeContext}; +use crate::RuntimeContext; pub mod built; pub mod deploy; @@ -32,74 +27,6 @@ pub struct FlowStateInner { pub type FlowState = Rc>; -pub struct ClusterIds<'a, C> { - pub(crate) id: usize, - pub(crate) _phantom: PhantomData<&'a mut &'a C>, -} - -impl Clone for ClusterIds<'_, C> { - fn clone(&self) -> Self { - *self - } -} - -impl Copy for ClusterIds<'_, C> {} - -impl<'a, C> FreeVariable<&'a Vec>> for ClusterIds<'a, C> { - fn to_tokens(self) -> (Option, Option) - where - Self: Sized, - { - let ident = syn::Ident::new( - &format!("__hydroflow_plus_cluster_ids_{}", self.id), - Span::call_site(), - ); - let root = get_this_crate(); - let c_type = quote_type::(); - ( - None, - Some( - quote! { unsafe { ::std::mem::transmute::<_, &::std::vec::Vec<#root::ClusterId<#c_type>>>(#ident) } }, - ), - ) - } -} - -impl<'a, C> Quoted<'a, &'a Vec>> for ClusterIds<'a, C> {} - -pub(crate) struct ClusterSelfId<'a, C> { - pub(crate) id: usize, - pub(crate) _phantom: PhantomData<&'a mut &'a C>, -} - -impl Clone for ClusterSelfId<'_, C> { - fn clone(&self) -> Self { - *self - } -} - -impl Copy for ClusterSelfId<'_, C> {} - -impl FreeVariable> for ClusterSelfId<'_, C> { - fn to_tokens(self) -> (Option, Option) - where - Self: Sized, - { - let ident = syn::Ident::new( - &format!("__hydroflow_plus_cluster_self_id_{}", self.id), - Span::call_site(), - ); - let root = get_this_crate(); - let c_type: syn::Type = quote_type::(); - ( - None, - Some(quote! { #root::ClusterId::<#c_type>::from_raw(#ident) }), - ) - } -} - -impl<'a, C> Quoted<'a, ClusterId> for ClusterSelfId<'a, C> {} - pub struct FlowBuilder<'a> { flow_state: FlowState, nodes: RefCell>, diff --git a/hydroflow_plus/src/cycle.rs b/hydroflow_plus/src/cycle.rs index dcf8bdeb5a29..5da633542875 100644 --- a/hydroflow_plus/src/cycle.rs +++ b/hydroflow_plus/src/cycle.rs @@ -1,7 +1,6 @@ use std::marker::PhantomData; -use crate::builder::FlowState; -use crate::location::{Location, LocationId}; +use crate::location::Location; pub struct TickCycle {} @@ -16,18 +15,13 @@ pub trait CycleComplete<'a, T> { pub trait CycleCollection<'a, T>: CycleComplete<'a, T> { type Location: Location<'a>; - fn create_source(ident: syn::Ident, flow_state: FlowState, l: LocationId) -> Self; + fn create_source(ident: syn::Ident, location: Self::Location) -> Self; } pub trait CycleCollectionWithInitial<'a, T>: CycleComplete<'a, T> { type Location: Location<'a>; - fn create_source( - ident: syn::Ident, - flow_state: FlowState, - initial: Self, - l: LocationId, - ) -> Self; + fn create_source(ident: syn::Ident, initial: Self, location: Self::Location) -> Self; } /// Represents a forward reference in the graph that will be fulfilled diff --git a/hydroflow_plus/src/lib.rs b/hydroflow_plus/src/lib.rs index b0ca79be28cd..a0fe5f3c9619 100644 --- a/hydroflow_plus/src/lib.rs +++ b/hydroflow_plus/src/lib.rs @@ -19,13 +19,13 @@ pub mod runtime_support { } pub mod stream; -pub use stream::{Bounded, Stream, Tick, Unbounded}; +pub use stream::{Bounded, Stream, Unbounded}; pub mod singleton; pub use singleton::{Optional, Singleton}; pub mod location; -pub use location::{Cluster, ClusterId, Location, Process}; +pub use location::{Cluster, ClusterId, Location, Process, Tick}; pub mod deploy; pub use deploy::{ClusterSpec, Deploy, ProcessSpec}; diff --git a/hydroflow_plus/src/location.rs b/hydroflow_plus/src/location.rs deleted file mode 100644 index 3e0a88f7047b..000000000000 --- a/hydroflow_plus/src/location.rs +++ /dev/null @@ -1,702 +0,0 @@ -use std::fmt::{Debug, Display}; -use std::hash::Hash; -use std::marker::PhantomData; -use std::time::Duration; - -use hydroflow::bytes::Bytes; -use hydroflow::futures::stream::Stream as FuturesStream; -use hydroflow::{tokio, tokio_stream}; -use proc_macro2::Span; -use serde::de::DeserializeOwned; -use serde::{Deserialize, Serialize}; -use stageleft::{q, quote_type, Quoted}; - -use super::builder::{ClusterIds, ClusterSelfId, FlowState}; -use crate::cycle::{CycleCollection, CycleCollectionWithInitial, DeferTick, HfCycle, TickCycle}; -use crate::ir::{HfPlusNode, HfPlusSource}; -use crate::stream::NoTick; -use crate::{Bounded, HfForwardRef, Optional, Singleton, Stream, Tick, Unbounded}; - -#[derive(PartialEq, Eq, Clone, Copy, Debug)] -pub enum LocationId { - Process(usize), - Cluster(usize), - ExternalProcess(usize), -} - -impl LocationId { - pub fn raw_id(&self) -> usize { - match self { - LocationId::Process(id) => *id, - LocationId::Cluster(id) => *id, - LocationId::ExternalProcess(id) => *id, - } - } -} - -pub trait Location<'a> { - fn id(&self) -> LocationId; - - fn flow_state(&self) -> &FlowState; - - fn make_from(id: LocationId, flow_state: FlowState) -> Self; - - fn spin(&self) -> Stream<(), Unbounded, Self> - where - Self: Sized + NoTick, - { - Stream::new( - self.id(), - self.flow_state().clone(), - HfPlusNode::Persist(Box::new(HfPlusNode::Source { - source: HfPlusSource::Spin(), - location_kind: self.id(), - })), - ) - } - - fn spin_batch( - &self, - batch_size: impl Quoted<'a, usize> + Copy + 'a, - ) -> Stream<(), Bounded, Tick> - where - Self: Sized + NoTick, - { - self.spin() - .flat_map(q!(move |_| 0..batch_size)) - .map(q!(|_| ())) - .tick_batch() - } - - fn source_stream + Unpin>( - &self, - e: impl Quoted<'a, E>, - ) -> Stream - where - Self: Sized + NoTick, - { - let e = e.splice_untyped(); - - Stream::new( - self.id(), - self.flow_state().clone(), - HfPlusNode::Persist(Box::new(HfPlusNode::Source { - source: HfPlusSource::Stream(e.into()), - location_kind: self.id(), - })), - ) - } - - fn source_iter>( - &self, - e: impl Quoted<'a, E>, - ) -> Stream - where - Self: Sized + NoTick, - { - let e = e.splice_untyped(); - - Stream::new( - self.id(), - self.flow_state().clone(), - HfPlusNode::Persist(Box::new(HfPlusNode::Source { - source: HfPlusSource::Iter(e.into()), - location_kind: self.id(), - })), - ) - } - - fn singleton(&self, e: impl Quoted<'a, T>) -> Singleton - where - Self: Sized + NoTick, - { - let e_arr = q!([e]); - let e = e_arr.splice_untyped(); - - // we do a double persist here because if the singleton shows up on every tick, - // we first persist the source so that we store that value and then persist again - // so that it grows every tick - Singleton::new( - self.id(), - self.flow_state().clone(), - HfPlusNode::Persist(Box::new(HfPlusNode::Persist(Box::new( - HfPlusNode::Source { - source: HfPlusSource::Iter(e.into()), - location_kind: self.id(), - }, - )))), - ) - } - - fn singleton_each_tick( - &self, - e: impl Quoted<'a, T>, - ) -> Singleton> - where - Self: Sized + NoTick, - { - self.singleton(e).latest_tick() - } - - fn singleton_first_tick( - &self, - e: impl Quoted<'a, T>, - ) -> Optional> - where - Self: Sized + NoTick, - { - let e_arr = q!([e]); - let e = e_arr.splice_untyped(); - - Optional::new( - self.id(), - self.flow_state().clone(), - HfPlusNode::Source { - source: HfPlusSource::Iter(e.into()), - location_kind: self.id(), - }, - ) - } - - fn source_interval( - &self, - interval: impl Quoted<'a, Duration> + Copy + 'a, - ) -> Stream - where - Self: Sized + NoTick, - { - self.source_stream(q!(tokio_stream::wrappers::IntervalStream::new( - tokio::time::interval(interval) - ))) - } - - fn source_interval_delayed( - &self, - delay: impl Quoted<'a, Duration> + Copy + 'a, - interval: impl Quoted<'a, Duration> + Copy + 'a, - ) -> Stream - where - Self: Sized + NoTick, - { - self.source_stream(q!(tokio_stream::wrappers::IntervalStream::new( - tokio::time::interval_at(tokio::time::Instant::now() + delay, interval) - ))) - } - - fn forward_ref>( - &self, - ) -> (HfForwardRef<'a, (), S>, S) - where - Self: NoTick, - { - let next_id = { - let on_id = match self.id() { - LocationId::Process(id) => id, - LocationId::Cluster(id) => id, - LocationId::ExternalProcess(_) => panic!(), - }; - - let mut flow_state = self.flow_state().borrow_mut(); - let next_id_entry = flow_state.cycle_counts.entry(on_id).or_default(); - - let id = *next_id_entry; - *next_id_entry += 1; - id - }; - - let ident = syn::Ident::new(&format!("cycle_{}", next_id), Span::call_site()); - - ( - HfForwardRef { - ident: ident.clone(), - _phantom: PhantomData, - }, - S::create_source(ident, self.flow_state().clone(), self.id()), - ) - } - - fn tick_forward_ref>( - &self, - ) -> (HfForwardRef<'a, TickCycle, S>, S) - where - Self: NoTick, - { - let next_id = { - let on_id = match self.id() { - LocationId::Process(id) => id, - LocationId::Cluster(id) => id, - LocationId::ExternalProcess(_) => panic!(), - }; - - let mut flow_state = self.flow_state().borrow_mut(); - let next_id_entry = flow_state.cycle_counts.entry(on_id).or_default(); - - let id = *next_id_entry; - *next_id_entry += 1; - id - }; - - let ident = syn::Ident::new(&format!("cycle_{}", next_id), Span::call_site()); - - ( - HfForwardRef { - ident: ident.clone(), - _phantom: PhantomData, - }, - S::create_source(ident, self.flow_state().clone(), self.id()), - ) - } - - fn tick_cycle + DeferTick>( - &self, - ) -> (HfCycle<'a, S>, S) - where - Self: NoTick, - { - let next_id = { - let on_id = match self.id() { - LocationId::Process(id) => id, - LocationId::Cluster(id) => id, - LocationId::ExternalProcess(_) => panic!(), - }; - - let mut flow_state = self.flow_state().borrow_mut(); - let next_id_entry = flow_state.cycle_counts.entry(on_id).or_default(); - - let id = *next_id_entry; - *next_id_entry += 1; - id - }; - - let ident = syn::Ident::new(&format!("cycle_{}", next_id), Span::call_site()); - - ( - HfCycle { - ident: ident.clone(), - _phantom: PhantomData, - }, - S::create_source(ident, self.flow_state().clone(), self.id()), - ) - } - - fn tick_cycle_with_initial< - S: CycleCollectionWithInitial<'a, TickCycle, Location = Self> + DeferTick, - >( - &self, - initial: S, - ) -> (HfCycle<'a, S>, S) - where - Self: NoTick, - { - let next_id = { - let on_id = match self.id() { - LocationId::Process(id) => id, - LocationId::Cluster(id) => id, - LocationId::ExternalProcess(_) => panic!(), - }; - - let mut flow_state = self.flow_state().borrow_mut(); - let next_id_entry = flow_state.cycle_counts.entry(on_id).or_default(); - - let id = *next_id_entry; - *next_id_entry += 1; - id - }; - - let ident = syn::Ident::new(&format!("cycle_{}", next_id), Span::call_site()); - - ( - HfCycle { - ident: ident.clone(), - _phantom: PhantomData, - }, - S::create_source(ident, self.flow_state().clone(), initial, self.id()), - ) - } -} - -pub struct ExternalBytesPort { - pub(crate) process_id: usize, - pub(crate) port_id: usize, -} - -pub struct ExternalBincodeSink { - pub(crate) process_id: usize, - pub(crate) port_id: usize, - pub(crate) _phantom: PhantomData, -} - -pub struct ExternalBincodeStream { - pub(crate) process_id: usize, - pub(crate) port_id: usize, - pub(crate) _phantom: PhantomData, -} - -pub struct ExternalProcess<'a, P> { - pub(crate) id: usize, - - pub(crate) flow_state: FlowState, - - pub(crate) _phantom: PhantomData<&'a &'a mut P>, -} - -impl

Clone for ExternalProcess<'_, P> { - fn clone(&self) -> Self { - ExternalProcess { - id: self.id, - flow_state: self.flow_state.clone(), - _phantom: PhantomData, - } - } -} - -impl<'a, P> Location<'a> for ExternalProcess<'a, P> { - fn id(&self) -> LocationId { - LocationId::ExternalProcess(self.id) - } - - fn flow_state(&self) -> &FlowState { - &self.flow_state - } - - fn make_from(id: LocationId, flow_state: FlowState) -> Self { - match id { - LocationId::ExternalProcess(id) => ExternalProcess { - id, - flow_state, - _phantom: PhantomData, - }, - _ => panic!(), - } - } -} - -impl<'a, P> ExternalProcess<'a, P> { - pub fn source_external_bytes + NoTick>( - &self, - to: &L, - ) -> (ExternalBytesPort, Stream) { - let next_external_port_id = { - let mut flow_state = self.flow_state.borrow_mut(); - let id = flow_state.next_external_out; - flow_state.next_external_out += 1; - id - }; - - ( - ExternalBytesPort { - process_id: self.id, - port_id: next_external_port_id, - }, - Stream::new( - to.id(), - self.flow_state().clone(), - HfPlusNode::Persist(Box::new(HfPlusNode::Network { - from_location: LocationId::ExternalProcess(self.id), - from_key: Some(next_external_port_id), - to_location: to.id(), - to_key: None, - serialize_pipeline: None, - instantiate_fn: crate::ir::DebugInstantiate::Building(), - deserialize_pipeline: Some(syn::parse_quote!(map(|b| b.unwrap().freeze()))), - input: Box::new(HfPlusNode::Source { - source: HfPlusSource::ExternalNetwork(), - location_kind: LocationId::ExternalProcess(self.id), - }), - })), - ), - ) - } - - pub fn source_external_bincode + NoTick, T: Serialize + DeserializeOwned>( - &self, - to: &L, - ) -> (ExternalBincodeSink, Stream) { - let next_external_port_id = { - let mut flow_state = self.flow_state.borrow_mut(); - let id = flow_state.next_external_out; - flow_state.next_external_out += 1; - id - }; - - ( - ExternalBincodeSink { - process_id: self.id, - port_id: next_external_port_id, - _phantom: PhantomData, - }, - Stream::new( - to.id(), - self.flow_state().clone(), - HfPlusNode::Persist(Box::new(HfPlusNode::Network { - from_location: LocationId::ExternalProcess(self.id), - from_key: Some(next_external_port_id), - to_location: to.id(), - to_key: None, - serialize_pipeline: None, - instantiate_fn: crate::ir::DebugInstantiate::Building(), - deserialize_pipeline: Some(crate::stream::deserialize_bincode::(None)), - input: Box::new(HfPlusNode::Source { - source: HfPlusSource::ExternalNetwork(), - location_kind: LocationId::ExternalProcess(self.id), - }), - })), - ), - ) - } -} - -pub struct Process<'a, P> { - pub(crate) id: usize, - pub(crate) flow_state: FlowState, - pub(crate) _phantom: PhantomData<&'a &'a mut P>, -} - -impl

Clone for Process<'_, P> { - fn clone(&self) -> Self { - Process { - id: self.id, - flow_state: self.flow_state.clone(), - _phantom: PhantomData, - } - } -} - -impl<'a, P> Location<'a> for Process<'a, P> { - fn id(&self) -> LocationId { - LocationId::Process(self.id) - } - - fn flow_state(&self) -> &FlowState { - &self.flow_state - } - - fn make_from(id: LocationId, flow_state: FlowState) -> Self { - match id { - LocationId::Process(id) => Process { - id, - flow_state, - _phantom: PhantomData, - }, - _ => panic!(), - } - } -} - -#[repr(transparent)] -pub struct ClusterId { - pub raw_id: u32, - pub(crate) _phantom: PhantomData, -} - -impl Debug for ClusterId { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "ClusterId::<{}>({})", - std::any::type_name::(), - self.raw_id - ) - } -} - -impl Display for ClusterId { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "ClusterId::<{}>({})", - std::any::type_name::(), - self.raw_id - ) - } -} - -impl Clone for ClusterId { - fn clone(&self) -> Self { - *self - } -} - -impl Copy for ClusterId {} - -impl Serialize for ClusterId { - fn serialize(&self, serializer: S) -> Result - where - S: serde::ser::Serializer, - { - self.raw_id.serialize(serializer) - } -} - -impl<'de, C> Deserialize<'de> for ClusterId { - fn deserialize(deserializer: D) -> Result - where - D: serde::de::Deserializer<'de>, - { - u32::deserialize(deserializer).map(|id| ClusterId { - raw_id: id, - _phantom: PhantomData, - }) - } -} - -impl PartialEq for ClusterId { - fn eq(&self, other: &Self) -> bool { - self.raw_id == other.raw_id - } -} - -impl Eq for ClusterId {} - -impl PartialOrd for ClusterId { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -impl Ord for ClusterId { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.raw_id.cmp(&other.raw_id) - } -} - -impl Hash for ClusterId { - fn hash(&self, state: &mut H) { - self.raw_id.hash(state) - } -} - -impl ClusterId { - pub fn from_raw(id: u32) -> Self { - ClusterId { - raw_id: id, - _phantom: PhantomData, - } - } -} - -pub struct Cluster<'a, C> { - pub(crate) id: usize, - pub(crate) flow_state: FlowState, - pub(crate) _phantom: PhantomData<&'a &'a mut C>, -} - -impl<'a, C> Cluster<'a, C> { - pub fn self_id(&self) -> impl Quoted<'a, ClusterId> + Copy + 'a { - ClusterSelfId { - id: self.id, - _phantom: PhantomData, - } - } - - pub fn members(&self) -> impl Quoted<'a, &'a Vec>> + Copy + 'a { - ClusterIds { - id: self.id, - _phantom: PhantomData, - } - } -} - -impl Clone for Cluster<'_, C> { - fn clone(&self) -> Self { - Cluster { - id: self.id, - flow_state: self.flow_state.clone(), - _phantom: PhantomData, - } - } -} - -impl<'a, C> Location<'a> for Cluster<'a, C> { - fn id(&self) -> LocationId { - LocationId::Cluster(self.id) - } - - fn flow_state(&self) -> &FlowState { - &self.flow_state - } - - fn make_from(id: LocationId, flow_state: FlowState) -> Self { - match id { - LocationId::Cluster(id) => Cluster { - id, - flow_state, - _phantom: PhantomData, - }, - _ => panic!(), - } - } -} - -pub trait CanSend<'a, To: Location<'a>>: Location<'a> { - type In; - type Out; - - fn is_demux() -> bool; - fn tagged_type() -> Option; -} - -impl<'a, P1, P2> CanSend<'a, Process<'a, P2>> for Process<'a, P1> { - type In = T; - type Out = T; - - fn is_demux() -> bool { - false - } - - fn tagged_type() -> Option { - None - } -} - -impl<'a, P1, C2> CanSend<'a, Cluster<'a, C2>> for Process<'a, P1> { - type In = (ClusterId, T); - type Out = T; - - fn is_demux() -> bool { - true - } - - fn tagged_type() -> Option { - None - } -} - -impl<'a, C1, P2> CanSend<'a, Process<'a, P2>> for Cluster<'a, C1> { - type In = T; - type Out = (ClusterId, T); - - fn is_demux() -> bool { - false - } - - fn tagged_type() -> Option { - Some(quote_type::()) - } -} - -impl<'a, C1, C2> CanSend<'a, Cluster<'a, C2>> for Cluster<'a, C1> { - type In = (ClusterId, T); - type Out = (ClusterId, T); - - fn is_demux() -> bool { - true - } - - fn tagged_type() -> Option { - Some(quote_type::()) - } -} - -impl<'a, P1, E2> CanSend<'a, ExternalProcess<'a, E2>> for Process<'a, P1> { - type In = T; - type Out = T; - - fn is_demux() -> bool { - false - } - - fn tagged_type() -> Option { - None - } -} diff --git a/hydroflow_plus/src/location/can_send.rs b/hydroflow_plus/src/location/can_send.rs new file mode 100644 index 000000000000..ddbec2719872 --- /dev/null +++ b/hydroflow_plus/src/location/can_send.rs @@ -0,0 +1,76 @@ +use stageleft::quote_type; + +use super::{Cluster, ClusterId, ExternalProcess, Location, Process}; + +pub trait CanSend<'a, To: Location<'a>>: Location<'a> { + type In; + type Out; + + fn is_demux() -> bool; + fn tagged_type() -> Option; +} + +impl<'a, P1, P2> CanSend<'a, Process<'a, P2>> for Process<'a, P1> { + type In = T; + type Out = T; + + fn is_demux() -> bool { + false + } + + fn tagged_type() -> Option { + None + } +} + +impl<'a, P1, C2> CanSend<'a, Cluster<'a, C2>> for Process<'a, P1> { + type In = (ClusterId, T); + type Out = T; + + fn is_demux() -> bool { + true + } + + fn tagged_type() -> Option { + None + } +} + +impl<'a, C1, P2> CanSend<'a, Process<'a, P2>> for Cluster<'a, C1> { + type In = T; + type Out = (ClusterId, T); + + fn is_demux() -> bool { + false + } + + fn tagged_type() -> Option { + Some(quote_type::()) + } +} + +impl<'a, C1, C2> CanSend<'a, Cluster<'a, C2>> for Cluster<'a, C1> { + type In = (ClusterId, T); + type Out = (ClusterId, T); + + fn is_demux() -> bool { + true + } + + fn tagged_type() -> Option { + Some(quote_type::()) + } +} + +impl<'a, P1, E2> CanSend<'a, ExternalProcess<'a, E2>> for Process<'a, P1> { + type In = T; + type Out = T; + + fn is_demux() -> bool { + false + } + + fn tagged_type() -> Option { + None + } +} diff --git a/hydroflow_plus/src/location/cluster.rs b/hydroflow_plus/src/location/cluster.rs new file mode 100644 index 000000000000..e18b5f2af1b8 --- /dev/null +++ b/hydroflow_plus/src/location/cluster.rs @@ -0,0 +1,227 @@ +use std::fmt::{Debug, Display}; +use std::hash::Hash; +use std::marker::PhantomData; + +use proc_macro2::{Span, TokenStream}; +use quote::quote; +use serde::{Deserialize, Serialize}; +use stageleft::runtime_support::FreeVariable; +use stageleft::{quote_type, Quoted}; + +// TODO(shadaj): have to use super due to stageleft limitations +use super::super::staging_util::get_this_crate; +use super::{Location, LocationId}; +use crate::builder::FlowState; + +pub struct Cluster<'a, C> { + pub(crate) id: usize, + pub(crate) flow_state: FlowState, + pub(crate) _phantom: PhantomData<&'a &'a mut C>, +} + +impl<'a, C> Cluster<'a, C> { + pub fn self_id(&self) -> impl Quoted<'a, ClusterId> + Copy + 'a { + ClusterSelfId { + id: self.id, + _phantom: PhantomData, + } + } + + pub fn members(&self) -> impl Quoted<'a, &'a Vec>> + Copy + 'a { + ClusterIds { + id: self.id, + _phantom: PhantomData, + } + } +} + +impl Clone for Cluster<'_, C> { + fn clone(&self) -> Self { + Cluster { + id: self.id, + flow_state: self.flow_state.clone(), + _phantom: PhantomData, + } + } +} + +impl<'a, C> Location<'a> for Cluster<'a, C> { + fn id(&self) -> LocationId { + LocationId::Cluster(self.id) + } + + fn flow_state(&self) -> &FlowState { + &self.flow_state + } + + fn make_from(id: LocationId, flow_state: FlowState) -> Self { + match id { + LocationId::Cluster(id) => Cluster { + id, + flow_state, + _phantom: PhantomData, + }, + _ => panic!(), + } + } +} + +#[repr(transparent)] +pub struct ClusterId { + pub raw_id: u32, + pub(crate) _phantom: PhantomData, +} + +impl Debug for ClusterId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "ClusterId::<{}>({})", + std::any::type_name::(), + self.raw_id + ) + } +} + +impl Display for ClusterId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "ClusterId::<{}>({})", + std::any::type_name::(), + self.raw_id + ) + } +} + +impl Clone for ClusterId { + fn clone(&self) -> Self { + *self + } +} + +impl Copy for ClusterId {} + +impl Serialize for ClusterId { + fn serialize(&self, serializer: S) -> Result + where + S: serde::ser::Serializer, + { + self.raw_id.serialize(serializer) + } +} + +impl<'de, C> Deserialize<'de> for ClusterId { + fn deserialize(deserializer: D) -> Result + where + D: serde::de::Deserializer<'de>, + { + u32::deserialize(deserializer).map(|id| ClusterId { + raw_id: id, + _phantom: PhantomData, + }) + } +} + +impl PartialEq for ClusterId { + fn eq(&self, other: &Self) -> bool { + self.raw_id == other.raw_id + } +} + +impl Eq for ClusterId {} + +impl PartialOrd for ClusterId { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for ClusterId { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.raw_id.cmp(&other.raw_id) + } +} + +impl Hash for ClusterId { + fn hash(&self, state: &mut H) { + self.raw_id.hash(state) + } +} + +impl ClusterId { + pub fn from_raw(id: u32) -> Self { + ClusterId { + raw_id: id, + _phantom: PhantomData, + } + } +} + +pub struct ClusterIds<'a, C> { + pub(crate) id: usize, + pub(crate) _phantom: PhantomData<&'a mut &'a C>, +} + +impl Clone for ClusterIds<'_, C> { + fn clone(&self) -> Self { + *self + } +} + +impl Copy for ClusterIds<'_, C> {} + +impl<'a, C> FreeVariable<&'a Vec>> for ClusterIds<'a, C> { + fn to_tokens(self) -> (Option, Option) + where + Self: Sized, + { + let ident = syn::Ident::new( + &format!("__hydroflow_plus_cluster_ids_{}", self.id), + Span::call_site(), + ); + let root = get_this_crate(); + let c_type = quote_type::(); + ( + None, + Some( + quote! { unsafe { ::std::mem::transmute::<_, &::std::vec::Vec<#root::ClusterId<#c_type>>>(#ident) } }, + ), + ) + } +} + +impl<'a, C> Quoted<'a, &'a Vec>> for ClusterIds<'a, C> {} + +pub struct ClusterSelfId<'a, C> { + pub(crate) id: usize, + pub(crate) _phantom: PhantomData<&'a mut &'a C>, +} + +impl Clone for ClusterSelfId<'_, C> { + fn clone(&self) -> Self { + *self + } +} + +impl Copy for ClusterSelfId<'_, C> {} + +impl FreeVariable> for ClusterSelfId<'_, C> { + fn to_tokens(self) -> (Option, Option) + where + Self: Sized, + { + let ident = syn::Ident::new( + &format!("__hydroflow_plus_cluster_self_id_{}", self.id), + Span::call_site(), + ); + let root = get_this_crate(); + let c_type: syn::Type = quote_type::(); + ( + None, + Some(quote! { #root::ClusterId::<#c_type>::from_raw(#ident) }), + ) + } +} + +impl<'a, C> Quoted<'a, ClusterId> for ClusterSelfId<'a, C> {} diff --git a/hydroflow_plus/src/location/external_process.rs b/hydroflow_plus/src/location/external_process.rs new file mode 100644 index 000000000000..4d992d36f5af --- /dev/null +++ b/hydroflow_plus/src/location/external_process.rs @@ -0,0 +1,139 @@ +use std::marker::PhantomData; + +use hydroflow::bytes::Bytes; +use serde::de::DeserializeOwned; +use serde::Serialize; + +use super::{Location, LocationId, NoTick}; +use crate::builder::FlowState; +use crate::ir::{HfPlusNode, HfPlusSource}; +use crate::{Stream, Unbounded}; + +pub struct ExternalBytesPort { + pub(crate) process_id: usize, + pub(crate) port_id: usize, +} + +pub struct ExternalBincodeSink { + pub(crate) process_id: usize, + pub(crate) port_id: usize, + pub(crate) _phantom: PhantomData, +} + +pub struct ExternalBincodeStream { + pub(crate) process_id: usize, + pub(crate) port_id: usize, + pub(crate) _phantom: PhantomData, +} + +pub struct ExternalProcess<'a, P> { + pub(crate) id: usize, + + pub(crate) flow_state: FlowState, + + pub(crate) _phantom: PhantomData<&'a &'a mut P>, +} + +impl

Clone for ExternalProcess<'_, P> { + fn clone(&self) -> Self { + ExternalProcess { + id: self.id, + flow_state: self.flow_state.clone(), + _phantom: PhantomData, + } + } +} + +impl<'a, P> Location<'a> for ExternalProcess<'a, P> { + fn id(&self) -> LocationId { + LocationId::ExternalProcess(self.id) + } + + fn flow_state(&self) -> &FlowState { + &self.flow_state + } + + fn make_from(id: LocationId, flow_state: FlowState) -> Self { + match id { + LocationId::ExternalProcess(id) => ExternalProcess { + id, + flow_state, + _phantom: PhantomData, + }, + _ => panic!(), + } + } +} + +impl<'a, P> ExternalProcess<'a, P> { + pub fn source_external_bytes + NoTick>( + &self, + to: &L, + ) -> (ExternalBytesPort, Stream) { + let next_external_port_id = { + let mut flow_state = self.flow_state.borrow_mut(); + let id = flow_state.next_external_out; + flow_state.next_external_out += 1; + id + }; + + ( + ExternalBytesPort { + process_id: self.id, + port_id: next_external_port_id, + }, + Stream::new( + to.clone(), + HfPlusNode::Persist(Box::new(HfPlusNode::Network { + from_location: LocationId::ExternalProcess(self.id), + from_key: Some(next_external_port_id), + to_location: to.id(), + to_key: None, + serialize_pipeline: None, + instantiate_fn: crate::ir::DebugInstantiate::Building(), + deserialize_pipeline: Some(syn::parse_quote!(map(|b| b.unwrap().freeze()))), + input: Box::new(HfPlusNode::Source { + source: HfPlusSource::ExternalNetwork(), + location_kind: LocationId::ExternalProcess(self.id), + }), + })), + ), + ) + } + + pub fn source_external_bincode + NoTick, T: Serialize + DeserializeOwned>( + &self, + to: &L, + ) -> (ExternalBincodeSink, Stream) { + let next_external_port_id = { + let mut flow_state = self.flow_state.borrow_mut(); + let id = flow_state.next_external_out; + flow_state.next_external_out += 1; + id + }; + + ( + ExternalBincodeSink { + process_id: self.id, + port_id: next_external_port_id, + _phantom: PhantomData, + }, + Stream::new( + to.clone(), + HfPlusNode::Persist(Box::new(HfPlusNode::Network { + from_location: LocationId::ExternalProcess(self.id), + from_key: Some(next_external_port_id), + to_location: to.id(), + to_key: None, + serialize_pipeline: None, + instantiate_fn: crate::ir::DebugInstantiate::Building(), + deserialize_pipeline: Some(crate::stream::deserialize_bincode::(None)), + input: Box::new(HfPlusNode::Source { + source: HfPlusSource::ExternalNetwork(), + location_kind: LocationId::ExternalProcess(self.id), + }), + })), + ), + ) + } +} diff --git a/hydroflow_plus/src/location/mod.rs b/hydroflow_plus/src/location/mod.rs new file mode 100644 index 000000000000..be906087291e --- /dev/null +++ b/hydroflow_plus/src/location/mod.rs @@ -0,0 +1,332 @@ +use std::fmt::Debug; +use std::marker::PhantomData; +use std::time::Duration; + +use hydroflow::futures::stream::Stream as FuturesStream; +use hydroflow::{tokio, tokio_stream}; +use proc_macro2::Span; +use stageleft::{q, Quoted}; + +use super::builder::FlowState; +use crate::cycle::{CycleCollection, CycleCollectionWithInitial, DeferTick, HfCycle, TickCycle}; +use crate::ir::{HfPlusNode, HfPlusSource}; +use crate::{Bounded, HfForwardRef, Optional, Singleton, Stream, Unbounded}; + +pub mod external_process; +pub use external_process::ExternalProcess; + +pub mod process; +pub use process::Process; + +pub mod cluster; +pub use cluster::{Cluster, ClusterId}; + +pub mod can_send; +pub use can_send::CanSend; + +pub mod tick; +pub use tick::{NoTick, Tick}; + +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub enum LocationId { + Process(usize), + Cluster(usize), + ExternalProcess(usize), +} + +impl LocationId { + pub fn raw_id(&self) -> usize { + match self { + LocationId::Process(id) => *id, + LocationId::Cluster(id) => *id, + LocationId::ExternalProcess(id) => *id, + } + } +} + +pub fn check_matching_location<'a, L: Location<'a>>(l1: &L, l2: &L) { + assert_eq!(l1.id(), l2.id(), "locations do not match"); +} + +pub trait Location<'a>: Clone { + fn id(&self) -> LocationId; + + fn flow_state(&self) -> &FlowState; + + fn make_from(id: LocationId, flow_state: FlowState) -> Self; + + fn nest(&self) -> Tick + where + Self: NoTick, + { + Tick { l: self.clone() } + } + + fn spin(&self) -> Stream<(), Unbounded, Self> + where + Self: Sized + NoTick, + { + Stream::new( + self.clone(), + HfPlusNode::Persist(Box::new(HfPlusNode::Source { + source: HfPlusSource::Spin(), + location_kind: self.id(), + })), + ) + } + + fn spin_batch( + &self, + batch_size: impl Quoted<'a, usize> + Copy + 'a, + ) -> Stream<(), Bounded, Tick> + where + Self: Sized + NoTick, + { + self.spin() + .flat_map(q!(move |_| 0..batch_size)) + .map(q!(|_| ())) + .tick_batch() + } + + fn source_stream + Unpin>( + &self, + e: impl Quoted<'a, E>, + ) -> Stream + where + Self: Sized + NoTick, + { + let e = e.splice_untyped(); + + Stream::new( + self.clone(), + HfPlusNode::Persist(Box::new(HfPlusNode::Source { + source: HfPlusSource::Stream(e.into()), + location_kind: self.id(), + })), + ) + } + + fn source_iter>( + &self, + e: impl Quoted<'a, E>, + ) -> Stream + where + Self: Sized + NoTick, + { + let e = e.splice_untyped(); + + Stream::new( + self.clone(), + HfPlusNode::Persist(Box::new(HfPlusNode::Source { + source: HfPlusSource::Iter(e.into()), + location_kind: self.id(), + })), + ) + } + + fn singleton(&self, e: impl Quoted<'a, T>) -> Singleton + where + Self: Sized + NoTick, + { + let e_arr = q!([e]); + let e = e_arr.splice_untyped(); + + // we do a double persist here because if the singleton shows up on every tick, + // we first persist the source so that we store that value and then persist again + // so that it grows every tick + Singleton::new( + self.clone(), + HfPlusNode::Persist(Box::new(HfPlusNode::Persist(Box::new( + HfPlusNode::Source { + source: HfPlusSource::Iter(e.into()), + location_kind: self.id(), + }, + )))), + ) + } + + fn singleton_each_tick( + &self, + e: impl Quoted<'a, T>, + ) -> Singleton> + where + Self: Sized + NoTick, + { + self.singleton(e).latest_tick() + } + + fn singleton_first_tick( + &self, + e: impl Quoted<'a, T>, + ) -> Optional> + where + Self: Sized + NoTick, + { + let e_arr = q!([e]); + let e = e_arr.splice_untyped(); + + Optional::new( + self.clone().nest(), + HfPlusNode::Source { + source: HfPlusSource::Iter(e.into()), + location_kind: self.id(), + }, + ) + } + + fn source_interval( + &self, + interval: impl Quoted<'a, Duration> + Copy + 'a, + ) -> Stream + where + Self: Sized + NoTick, + { + self.source_stream(q!(tokio_stream::wrappers::IntervalStream::new( + tokio::time::interval(interval) + ))) + } + + fn source_interval_delayed( + &self, + delay: impl Quoted<'a, Duration> + Copy + 'a, + interval: impl Quoted<'a, Duration> + Copy + 'a, + ) -> Stream + where + Self: Sized + NoTick, + { + self.source_stream(q!(tokio_stream::wrappers::IntervalStream::new( + tokio::time::interval_at(tokio::time::Instant::now() + delay, interval) + ))) + } + + fn forward_ref>( + &self, + ) -> (HfForwardRef<'a, (), S>, S) + where + Self: NoTick, + { + let next_id = { + let on_id = match self.id() { + LocationId::Process(id) => id, + LocationId::Cluster(id) => id, + LocationId::ExternalProcess(_) => panic!(), + }; + + let mut flow_state = self.flow_state().borrow_mut(); + let next_id_entry = flow_state.cycle_counts.entry(on_id).or_default(); + + let id = *next_id_entry; + *next_id_entry += 1; + id + }; + + let ident = syn::Ident::new(&format!("cycle_{}", next_id), Span::call_site()); + + ( + HfForwardRef { + ident: ident.clone(), + _phantom: PhantomData, + }, + S::create_source(ident, self.clone()), + ) + } + + fn tick_forward_ref>>( + &self, + ) -> (HfForwardRef<'a, TickCycle, S>, S) + where + Self: NoTick, + { + let next_id = { + let on_id = match self.id() { + LocationId::Process(id) => id, + LocationId::Cluster(id) => id, + LocationId::ExternalProcess(_) => panic!(), + }; + + let mut flow_state = self.flow_state().borrow_mut(); + let next_id_entry = flow_state.cycle_counts.entry(on_id).or_default(); + + let id = *next_id_entry; + *next_id_entry += 1; + id + }; + + let ident = syn::Ident::new(&format!("cycle_{}", next_id), Span::call_site()); + + ( + HfForwardRef { + ident: ident.clone(), + _phantom: PhantomData, + }, + S::create_source(ident, self.nest().clone()), + ) + } + + fn tick_cycle> + DeferTick>( + &self, + ) -> (HfCycle<'a, S>, S) + where + Self: NoTick, + { + let next_id = { + let on_id = match self.id() { + LocationId::Process(id) => id, + LocationId::Cluster(id) => id, + LocationId::ExternalProcess(_) => panic!(), + }; + + let mut flow_state = self.flow_state().borrow_mut(); + let next_id_entry = flow_state.cycle_counts.entry(on_id).or_default(); + + let id = *next_id_entry; + *next_id_entry += 1; + id + }; + + let ident = syn::Ident::new(&format!("cycle_{}", next_id), Span::call_site()); + + ( + HfCycle { + ident: ident.clone(), + _phantom: PhantomData, + }, + S::create_source(ident, self.nest().clone()), + ) + } + + fn tick_cycle_with_initial< + S: CycleCollectionWithInitial<'a, TickCycle, Location = Tick> + DeferTick, + >( + &self, + initial: S, + ) -> (HfCycle<'a, S>, S) + where + Self: NoTick, + { + let next_id = { + let on_id = match self.id() { + LocationId::Process(id) => id, + LocationId::Cluster(id) => id, + LocationId::ExternalProcess(_) => panic!(), + }; + + let mut flow_state = self.flow_state().borrow_mut(); + let next_id_entry = flow_state.cycle_counts.entry(on_id).or_default(); + + let id = *next_id_entry; + *next_id_entry += 1; + id + }; + + let ident = syn::Ident::new(&format!("cycle_{}", next_id), Span::call_site()); + + ( + HfCycle { + ident: ident.clone(), + _phantom: PhantomData, + }, + S::create_source(ident, initial, self.nest().clone()), + ) + } +} diff --git a/hydroflow_plus/src/location/process.rs b/hydroflow_plus/src/location/process.rs new file mode 100644 index 000000000000..dadda1ce8f3c --- /dev/null +++ b/hydroflow_plus/src/location/process.rs @@ -0,0 +1,41 @@ +use std::marker::PhantomData; + +use super::{Location, LocationId}; +use crate::builder::FlowState; + +pub struct Process<'a, P> { + pub(crate) id: usize, + pub(crate) flow_state: FlowState, + pub(crate) _phantom: PhantomData<&'a &'a mut P>, +} + +impl

Clone for Process<'_, P> { + fn clone(&self) -> Self { + Process { + id: self.id, + flow_state: self.flow_state.clone(), + _phantom: PhantomData, + } + } +} + +impl<'a, P> Location<'a> for Process<'a, P> { + fn id(&self) -> LocationId { + LocationId::Process(self.id) + } + + fn flow_state(&self) -> &FlowState { + &self.flow_state + } + + fn make_from(id: LocationId, flow_state: FlowState) -> Self { + match id { + LocationId::Process(id) => Process { + id, + flow_state, + _phantom: PhantomData, + }, + _ => panic!(), + } + } +} diff --git a/hydroflow_plus/src/location/tick.rs b/hydroflow_plus/src/location/tick.rs new file mode 100644 index 000000000000..48a27e8bbf04 --- /dev/null +++ b/hydroflow_plus/src/location/tick.rs @@ -0,0 +1,34 @@ +use super::{Cluster, Location, LocationId, Process}; +use crate::builder::FlowState; + +pub trait NoTick {} +impl NoTick for Process<'_, T> {} +impl NoTick for Cluster<'_, T> {} + +/// Marks the stream as being inside the single global clock domain. +#[derive(Clone)] +pub struct Tick { + pub(crate) l: L, +} + +impl<'a, L: Location<'a>> Tick { + pub fn outer(&self) -> &L { + &self.l + } +} + +impl<'a, L: Location<'a>> Location<'a> for Tick { + fn id(&self) -> LocationId { + self.l.id() + } + + fn flow_state(&self) -> &FlowState { + self.l.flow_state() + } + + fn make_from(id: LocationId, flow_state: FlowState) -> Self { + Tick { + l: L::make_from(id, flow_state), + } + } +} diff --git a/hydroflow_plus/src/singleton.rs b/hydroflow_plus/src/singleton.rs index 855e5860cad4..c7c1a73349f3 100644 --- a/hydroflow_plus/src/singleton.rs +++ b/hydroflow_plus/src/singleton.rs @@ -9,34 +9,37 @@ use crate::builder::FlowState; use crate::cycle::{ CycleCollection, CycleCollectionWithInitial, CycleComplete, DeferTick, TickCycle, }; -use crate::ir::{HfPlusLeaf, HfPlusNode, HfPlusSource, TeeNode}; -use crate::location::{Location, LocationId}; -use crate::stream::{Bounded, NoTick, Tick, Unbounded}; +use crate::ir::{HfPlusLeaf, HfPlusNode, TeeNode}; +use crate::location::{check_matching_location, Location, LocationId, NoTick, Tick}; +use crate::stream::{Bounded, Unbounded}; use crate::Stream; pub trait CrossResult<'a, Other> { type Out; - fn other_location(other: &Other) -> LocationId; + type Location; + + fn other_location(other: &Other) -> Self::Location; fn other_ir_node(other: Other) -> HfPlusNode; - fn make(location_kind: LocationId, flow_state: FlowState, ir_node: HfPlusNode) -> Self::Out; + fn make(location: Self::Location, ir_node: HfPlusNode) -> Self::Out; } impl<'a, T, U: Clone, W, N: Location<'a>> CrossResult<'a, Singleton> for Singleton { type Out = Singleton<(T, U), W, N>; + type Location = N; - fn other_location(other: &Singleton) -> LocationId { - other.location_kind + fn other_location(other: &Singleton) -> N { + other.location.clone() } fn other_ir_node(other: Singleton) -> HfPlusNode { other.ir_node.into_inner() } - fn make(location_kind: LocationId, flow_state: FlowState, ir_node: HfPlusNode) -> Self::Out { - Singleton::new(location_kind, flow_state, ir_node) + fn make(location: N, ir_node: HfPlusNode) -> Self::Out { + Singleton::new(location, ir_node) } } @@ -44,33 +47,35 @@ impl<'a, T, U: Clone, W, N: Location<'a>> CrossResult<'a, Optional> for Singleton { type Out = Optional<(T, U), W, N>; + type Location = N; - fn other_location(other: &Optional) -> LocationId { - other.location_kind + fn other_location(other: &Optional) -> N { + other.location.clone() } fn other_ir_node(other: Optional) -> HfPlusNode { other.ir_node.into_inner() } - fn make(location_kind: LocationId, flow_state: FlowState, ir_node: HfPlusNode) -> Self::Out { - Optional::new(location_kind, flow_state, ir_node) + fn make(location: N, ir_node: HfPlusNode) -> Self::Out { + Optional::new(location, ir_node) } } impl<'a, T, U: Clone, W, N: Location<'a>> CrossResult<'a, Optional> for Optional { type Out = Optional<(T, U), W, N>; + type Location = N; - fn other_location(other: &Optional) -> LocationId { - other.location_kind + fn other_location(other: &Optional) -> N { + other.location.clone() } fn other_ir_node(other: Optional) -> HfPlusNode { other.ir_node.into_inner() } - fn make(location_kind: LocationId, flow_state: FlowState, ir_node: HfPlusNode) -> Self::Out { - Optional::new(location_kind, flow_state, ir_node) + fn make(location: N, ir_node: HfPlusNode) -> Self::Out { + Optional::new(location, ir_node) } } @@ -78,51 +83,49 @@ impl<'a, T, U: Clone, W, N: Location<'a>> CrossResult<'a, Singleton> for Optional { type Out = Optional<(T, U), W, N>; + type Location = N; - fn other_location(other: &Singleton) -> LocationId { - other.location_kind + fn other_location(other: &Singleton) -> N { + other.location.clone() } fn other_ir_node(other: Singleton) -> HfPlusNode { other.ir_node.into_inner() } - fn make(location_kind: LocationId, flow_state: FlowState, ir_node: HfPlusNode) -> Self::Out { - Optional::new(location_kind, flow_state, ir_node) + fn make(location: N, ir_node: HfPlusNode) -> Self::Out { + Optional::new(location, ir_node) } } pub struct Singleton { - pub(crate) location_kind: LocationId, - - flow_state: FlowState, + location: N, pub(crate) ir_node: RefCell, _phantom: PhantomData<(T, N, W)>, } impl<'a, T, W, N: Location<'a>> Singleton { - pub(crate) fn new( - location_kind: LocationId, - flow_state: FlowState, - ir_node: HfPlusNode, - ) -> Self { + pub(crate) fn new(location: N, ir_node: HfPlusNode) -> Self { Singleton { - location_kind, - flow_state, + location, ir_node: RefCell::new(ir_node), _phantom: PhantomData, } } + + fn location_kind(&self) -> LocationId { + self.location.id() + } + + fn flow_state(&self) -> &FlowState { + self.location.flow_state() + } } impl<'a, T, N: Location<'a>> From> for Singleton { fn from(singleton: Singleton) -> Self { - Singleton::new( - singleton.location_kind, - singleton.flow_state, - singleton.ir_node.into_inner(), - ) + Singleton::new(singleton.location, singleton.ir_node.into_inner()) } } @@ -134,24 +137,24 @@ impl<'a, T, N: Location<'a>> DeferTick for Singleton> { impl<'a, T, N: Location<'a>> CycleComplete<'a, TickCycle> for Singleton> { fn complete(self, ident: syn::Ident) { - self.flow_state.borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::CycleSink { + self.flow_state().clone().borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::CycleSink { ident, - location_kind: self.location_kind, + location_kind: self.location_kind(), input: Box::new(self.ir_node.into_inner()), }); } } impl<'a, T, N: Location<'a>> CycleCollection<'a, TickCycle> for Singleton> { - type Location = N; + type Location = Tick; - fn create_source(ident: syn::Ident, flow_state: FlowState, l: LocationId) -> Self { + fn create_source(ident: syn::Ident, location: Tick) -> Self { + let location_id = location.id(); Singleton::new( - l, - flow_state, + location, HfPlusNode::CycleSource { ident, - location_kind: l, + location_kind: location_id, }, ) } @@ -160,21 +163,16 @@ impl<'a, T, N: Location<'a>> CycleCollection<'a, TickCycle> for Singleton> CycleCollectionWithInitial<'a, TickCycle> for Singleton> { - type Location = N; + type Location = Tick; - fn create_source( - ident: syn::Ident, - flow_state: FlowState, - initial: Self, - l: LocationId, - ) -> Self { + fn create_source(ident: syn::Ident, initial: Self, location: Tick) -> Self { + let location_id = location.id(); Singleton::new( - l, - flow_state, + location, HfPlusNode::Union( Box::new(HfPlusNode::CycleSource { ident, - location_kind: l, + location_kind: location_id, }), initial.ir_node.into_inner().into(), ), @@ -193,8 +191,7 @@ impl<'a, T: Clone, W, N: Location<'a>> Clone for Singleton { if let HfPlusNode::Tee { inner } = self.ir_node.borrow().deref() { Singleton { - location_kind: self.location_kind, - flow_state: self.flow_state.clone(), + location: self.location.clone(), ir_node: HfPlusNode::Tee { inner: TeeNode(inner.0.clone()), } @@ -210,8 +207,7 @@ impl<'a, T: Clone, W, N: Location<'a>> Clone for Singleton { impl<'a, T, W, N: Location<'a>> Singleton { pub fn map U + 'a>(self, f: impl IntoQuotedMut<'a, F>) -> Singleton { Singleton::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Map { f: f.splice_fn1().into(), input: Box::new(self.ir_node.into_inner()), @@ -224,8 +220,7 @@ impl<'a, T, W, N: Location<'a>> Singleton { f: impl IntoQuotedMut<'a, F>, ) -> Stream { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::FlatMap { f: f.splice_fn1().into(), input: Box::new(self.ir_node.into_inner()), @@ -235,8 +230,7 @@ impl<'a, T, W, N: Location<'a>> Singleton { pub fn filter bool + 'a>(self, f: impl IntoQuotedMut<'a, F>) -> Optional { Optional::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Filter { f: f.splice_fn1_borrow().into(), input: Box::new(self.ir_node.into_inner()), @@ -249,8 +243,7 @@ impl<'a, T, W, N: Location<'a>> Singleton { f: impl IntoQuotedMut<'a, F>, ) -> Optional { Optional::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::FilterMap { f: f.splice_fn1().into(), input: Box::new(self.ir_node.into_inner()), @@ -262,24 +255,17 @@ impl<'a, T, W, N: Location<'a>> Singleton { impl<'a, T, N: Location<'a>> Singleton> { // TODO(shadaj): this is technically incorrect; we should only return the first element of the stream pub fn into_stream(self) -> Stream> { - Stream::new( - self.location_kind, - self.flow_state, - self.ir_node.into_inner(), - ) + Stream::new(self.location, self.ir_node.into_inner()) } pub fn cross_singleton(self, other: Other) -> >::Out where - Self: CrossResult<'a, Other>, + Self: CrossResult<'a, Other, Location = Tick>, { - if self.location_kind != Self::other_location(&other) { - panic!("cross_singleton must be called on streams on the same node"); - } + check_matching_location(&self.location, &Self::other_location(&other)); Self::make( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::CrossSingleton( Box::new(self.ir_node.into_inner()), Box::new(Self::other_ir_node(other)), @@ -306,40 +292,35 @@ impl<'a, T, N: Location<'a>> Singleton> { impl<'a, T, N: Location<'a>> Singleton> { pub fn all_ticks(self) -> Stream { Stream::new( - self.location_kind, - self.flow_state, + self.location.outer().clone(), HfPlusNode::Persist(Box::new(self.ir_node.into_inner())), ) } pub fn latest(self) -> Singleton { Singleton::new( - self.location_kind, - self.flow_state, + self.location.outer().clone(), HfPlusNode::Persist(Box::new(self.ir_node.into_inner())), ) } pub fn defer_tick(self) -> Singleton> { Singleton::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::DeferTick(Box::new(self.ir_node.into_inner())), ) } pub fn persist(self) -> Stream> { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Persist(Box::new(self.ir_node.into_inner())), ) } pub fn delta(self) -> Optional> { Optional::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Delta(Box::new(self.ir_node.into_inner())), ) } @@ -348,26 +329,16 @@ impl<'a, T, N: Location<'a>> Singleton> { impl<'a, T, B, N: Location<'a> + NoTick> Singleton { pub fn latest_tick(self) -> Singleton> { Singleton::new( - self.location_kind, - self.flow_state, + self.location.nest(), HfPlusNode::Unpersist(Box::new(self.ir_node.into_inner())), ) } pub fn sample_every( self, - duration: impl Quoted<'a, std::time::Duration> + Copy + 'a, + interval: impl Quoted<'a, std::time::Duration> + Copy + 'a, ) -> Stream { - let interval = duration.splice_typed(); - - let samples = Stream::<(), Bounded, Tick>::new( - self.location_kind, - self.flow_state.clone(), - HfPlusNode::Source { - source: HfPlusSource::Interval(interval.into()), - location_kind: self.location_kind, - }, - ); + let samples = self.location.source_interval(interval).tick_batch(); self.latest_tick() .continue_if(samples.first()) @@ -379,15 +350,12 @@ impl<'a, T, B, N: Location<'a> + NoTick> Singleton { impl<'a, T, N: Location<'a> + NoTick> Singleton { pub fn cross_singleton(self, other: Other) -> >::Out where - Self: CrossResult<'a, Other>, + Self: CrossResult<'a, Other, Location = N>, { - if self.location_kind != Self::other_location(&other) { - panic!("cross_singleton must be called on streams on the same node"); - } + check_matching_location(&self.location, &Self::other_location(&other)); Self::make( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Persist(Box::new(HfPlusNode::CrossSingleton( Box::new(HfPlusNode::Unpersist(Box::new(self.ir_node.into_inner()))), Box::new(HfPlusNode::Unpersist(Box::new(Self::other_ir_node(other)))), @@ -397,34 +365,31 @@ impl<'a, T, N: Location<'a> + NoTick> Singleton { } pub struct Optional { - pub(crate) location_kind: LocationId, - - flow_state: FlowState, + pub(crate) location: N, pub(crate) ir_node: RefCell, _phantom: PhantomData<(T, N, W)>, } impl<'a, T, W, N: Location<'a>> Optional { - pub(crate) fn new( - location_kind: LocationId, - flow_state: FlowState, - ir_node: HfPlusNode, - ) -> Self { + pub(crate) fn new(location: N, ir_node: HfPlusNode) -> Self { Optional { - location_kind, - flow_state, + location, ir_node: RefCell::new(ir_node), _phantom: PhantomData, } } pub fn some(singleton: Singleton) -> Self { - Optional::new( - singleton.location_kind, - singleton.flow_state, - singleton.ir_node.into_inner(), - ) + Optional::new(singleton.location, singleton.ir_node.into_inner()) + } + + fn location_kind(&self) -> LocationId { + self.location.id() + } + + fn flow_state(&self) -> &FlowState { + self.location.flow_state() } } @@ -436,24 +401,24 @@ impl<'a, T, N: Location<'a>> DeferTick for Optional> { impl<'a, T, N: Location<'a>> CycleComplete<'a, TickCycle> for Optional> { fn complete(self, ident: syn::Ident) { - self.flow_state.borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::CycleSink { + self.flow_state().clone().borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::CycleSink { ident, - location_kind: self.location_kind, + location_kind: self.location_kind(), input: Box::new(self.ir_node.into_inner()), }); } } impl<'a, T, N: Location<'a>> CycleCollection<'a, TickCycle> for Optional> { - type Location = N; + type Location = Tick; - fn create_source(ident: syn::Ident, flow_state: FlowState, l: LocationId) -> Self { + fn create_source(ident: syn::Ident, location: Tick) -> Self { + let location_id = location.id(); Optional::new( - l, - flow_state, + location, HfPlusNode::CycleSource { ident, - location_kind: l, + location_kind: location_id, }, ) } @@ -461,9 +426,9 @@ impl<'a, T, N: Location<'a>> CycleCollection<'a, TickCycle> for Optional + NoTick> CycleComplete<'a, ()> for Optional { fn complete(self, ident: syn::Ident) { - self.flow_state.borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::CycleSink { + self.flow_state().clone().borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::CycleSink { ident, - location_kind: self.location_kind, + location_kind: self.location_kind(), input: Box::new(HfPlusNode::Unpersist(Box::new(self.ir_node.into_inner()))), }); } @@ -472,13 +437,13 @@ impl<'a, T, W, N: Location<'a> + NoTick> CycleComplete<'a, ()> for Optional + NoTick> CycleCollection<'a, ()> for Optional { type Location = N; - fn create_source(ident: syn::Ident, flow_state: FlowState, l: LocationId) -> Self { + fn create_source(ident: syn::Ident, location: N) -> Self { + let location_id = location.id(); Optional::new( - l, - flow_state, + location, HfPlusNode::Persist(Box::new(HfPlusNode::CycleSource { ident, - location_kind: l, + location_kind: location_id, })), ) } @@ -501,8 +466,7 @@ impl<'a, T: Clone, W, N: Location<'a>> Clone for Optional { if let HfPlusNode::Tee { inner } = self.ir_node.borrow().deref() { Optional { - location_kind: self.location_kind, - flow_state: self.flow_state.clone(), + location: self.location.clone(), ir_node: HfPlusNode::Tee { inner: TeeNode(inner.0.clone()), } @@ -518,8 +482,7 @@ impl<'a, T: Clone, W, N: Location<'a>> Clone for Optional { impl<'a, T, W, N: Location<'a>> Optional { pub fn map U + 'a>(self, f: impl IntoQuotedMut<'a, F>) -> Optional { Optional::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Map { f: f.splice_fn1().into(), input: Box::new(self.ir_node.into_inner()), @@ -532,8 +495,7 @@ impl<'a, T, W, N: Location<'a>> Optional { f: impl IntoQuotedMut<'a, F>, ) -> Stream { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::FlatMap { f: f.splice_fn1().into(), input: Box::new(self.ir_node.into_inner()), @@ -543,8 +505,7 @@ impl<'a, T, W, N: Location<'a>> Optional { pub fn filter bool + 'a>(self, f: impl IntoQuotedMut<'a, F>) -> Optional { Optional::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Filter { f: f.splice_fn1_borrow().into(), input: Box::new(self.ir_node.into_inner()), @@ -557,8 +518,7 @@ impl<'a, T, W, N: Location<'a>> Optional { f: impl IntoQuotedMut<'a, F>, ) -> Optional { Optional::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::FilterMap { f: f.splice_fn1().into(), input: Box::new(self.ir_node.into_inner()), @@ -570,11 +530,7 @@ impl<'a, T, W, N: Location<'a>> Optional { impl<'a, T, N: Location<'a>> Optional> { // TODO(shadaj): this is technically incorrect; we should only return the first element of the stream pub fn into_stream(self) -> Stream> { - Stream::new( - self.location_kind, - self.flow_state, - self.ir_node.into_inner(), - ) + Stream::new(self.location, self.ir_node.into_inner()) } pub fn cross_singleton( @@ -585,13 +541,10 @@ impl<'a, T, N: Location<'a>> Optional> { O: Clone, { let other: Optional> = other.into(); - if self.location_kind != other.location_kind { - panic!("cross_singleton must be called on streams on the same node"); - } + check_matching_location(&self.location, &other.location); Optional::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::CrossSingleton( Box::new(self.ir_node.into_inner()), Box::new(other.ir_node.into_inner()), @@ -619,13 +572,10 @@ impl<'a, T, N: Location<'a>> Optional> { } pub fn union(self, other: Optional>) -> Optional> { - if self.location_kind != other.location_kind { - panic!("union must be called on streams on the same node"); - } + check_matching_location(&self.location, &other.location); Optional::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Union( Box::new(self.ir_node.into_inner()), Box::new(other.ir_node.into_inner()), @@ -637,13 +587,10 @@ impl<'a, T, N: Location<'a>> Optional> { self, other: Singleton>, ) -> Singleton> { - if self.location_kind != other.location_kind { - panic!("or_else must be called on streams on the same node"); - } + check_matching_location(&self.location, &other.location); Singleton::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Union( Box::new(self.ir_node.into_inner()), Box::new(other.ir_node.into_inner()), @@ -656,49 +603,43 @@ impl<'a, T, N: Location<'a>> Optional> { T: Clone, N: NoTick, { - let self_location = N::make_from(self.location_kind, self.flow_state.clone()); - self.map(q!(|v| Some(v))) - .unwrap_or(self_location.singleton_each_tick(q!(None))) + let none_singleton = self.location.outer().singleton_each_tick(q!(None)); + self.map(q!(|v| Some(v))).unwrap_or(none_singleton) } } impl<'a, T, N: Location<'a>> Optional> { pub fn all_ticks(self) -> Stream { Stream::new( - self.location_kind, - self.flow_state, + self.location.outer().clone(), HfPlusNode::Persist(Box::new(self.ir_node.into_inner())), ) } pub fn latest(self) -> Optional { Optional::new( - self.location_kind, - self.flow_state, + self.location.outer().clone(), HfPlusNode::Persist(Box::new(self.ir_node.into_inner())), ) } pub fn defer_tick(self) -> Optional> { Optional::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::DeferTick(Box::new(self.ir_node.into_inner())), ) } pub fn persist(self) -> Stream> { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Persist(Box::new(self.ir_node.into_inner())), ) } pub fn delta(self) -> Optional> { Optional::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Delta(Box::new(self.ir_node.into_inner())), ) } @@ -707,8 +648,7 @@ impl<'a, T, N: Location<'a>> Optional> { impl<'a, T, B, N: Location<'a> + NoTick> Optional { pub fn latest_tick(self) -> Optional> { Optional::new( - self.location_kind, - self.flow_state, + self.location.nest(), HfPlusNode::Unpersist(Box::new(self.ir_node.into_inner())), ) } @@ -719,18 +659,9 @@ impl<'a, T, B, N: Location<'a> + NoTick> Optional { pub fn sample_every( self, - duration: impl Quoted<'a, std::time::Duration> + Copy + 'a, + interval: impl Quoted<'a, std::time::Duration> + Copy + 'a, ) -> Stream { - let interval = duration.splice_typed(); - - let samples = Stream::<(), Bounded, Tick>::new( - self.location_kind, - self.flow_state.clone(), - HfPlusNode::Source { - source: HfPlusSource::Interval(interval.into()), - location_kind: self.location_kind, - }, - ); + let samples = self.location.source_interval(interval).tick_batch(); self.latest_tick() .continue_if(samples.first()) @@ -743,9 +674,7 @@ impl<'a, T, B, N: Location<'a> + NoTick> Optional { other: impl Into>, ) -> Singleton { let other = other.into(); - if self.location_kind != other.location_kind { - panic!("or_else must be called on streams on the same node"); - } + check_matching_location(&self.location, &other.location); self.latest_tick().unwrap_or(other.latest_tick()).latest() } @@ -754,9 +683,8 @@ impl<'a, T, B, N: Location<'a> + NoTick> Optional { where T: Clone, { - let self_location = N::make_from(self.location_kind, self.flow_state.clone()); - self.map(q!(|v| Some(v))) - .unwrap_or(self_location.singleton(q!(None))) + let none_singleton = self.location.singleton(q!(None)); + self.map(q!(|v| Some(v))).unwrap_or(none_singleton) } } @@ -769,9 +697,7 @@ impl<'a, T, N: Location<'a> + NoTick> Optional { O: Clone, { let other: Optional = other.into(); - if self.location_kind != other.location_kind { - panic!("cross_singleton must be called on streams on the same node"); - } + check_matching_location(&self.location, &other.location); self.latest_tick() .cross_singleton(other.latest_tick()) diff --git a/hydroflow_plus/src/stream.rs b/hydroflow_plus/src/stream.rs index 39f664d889d9..4a6a1e3a6108 100644 --- a/hydroflow_plus/src/stream.rs +++ b/hydroflow_plus/src/stream.rs @@ -12,12 +12,15 @@ use serde::Serialize; use stageleft::{q, IntoQuotedMut, Quoted}; use syn::parse_quote; +// TODO(shadaj): have to uses super due to stageleft limitations use super::staging_util::get_this_crate; -use crate::builder::{self, FlowState}; +use crate::builder::FlowState; use crate::cycle::{CycleCollection, CycleComplete, DeferTick, TickCycle}; -use crate::ir::{DebugInstantiate, HfPlusLeaf, HfPlusNode, HfPlusSource, TeeNode}; +use crate::ir::{DebugInstantiate, HfPlusLeaf, HfPlusNode, TeeNode}; +use crate::location::cluster::ClusterSelfId; +use crate::location::external_process::{ExternalBincodeStream, ExternalBytesPort}; use crate::location::{ - CanSend, ExternalBincodeStream, ExternalBytesPort, ExternalProcess, Location, LocationId, + check_matching_location, CanSend, ExternalProcess, Location, LocationId, NoTick, Tick, }; use crate::{Cluster, ClusterId, Optional, Process, Singleton}; @@ -29,31 +32,6 @@ pub enum Unbounded {} /// to be complete in finite time. pub enum Bounded {} -pub trait NoTick {} -impl NoTick for Process<'_, T> {} -impl NoTick for Cluster<'_, T> {} - -/// Marks the stream as being inside the single global clock domain. -pub struct Tick { - l: L, -} - -impl<'a, L: Location<'a>> Location<'a> for Tick { - fn id(&self) -> LocationId { - self.l.id() - } - - fn flow_state(&self) -> &FlowState { - self.l.flow_state() - } - - fn make_from(id: LocationId, flow_state: FlowState) -> Self { - Tick { - l: L::make_from(id, flow_state), - } - } -} - /// An infinite stream of elements of type `T`. /// /// Type Parameters: @@ -64,14 +42,22 @@ impl<'a, L: Location<'a>> Location<'a> for Tick { /// or [`Unbounded`] /// - `N`: the type of the node that the stream is materialized on pub struct Stream { - location_kind: LocationId, - - flow_state: FlowState, + location: N, pub(crate) ir_node: RefCell, _phantom: PhantomData<(T, N, W)>, } +impl<'a, T, W, N: Location<'a>> Stream { + fn flow_state(&self) -> &FlowState { + self.location.flow_state() + } + + fn location_kind(&self) -> LocationId { + self.location.id() + } +} + impl<'a, T, N: Location<'a>> DeferTick for Stream> { fn defer_tick(self) -> Self { Stream::defer_tick(self) @@ -80,24 +66,24 @@ impl<'a, T, N: Location<'a>> DeferTick for Stream> { impl<'a, T, N: Location<'a>> CycleComplete<'a, TickCycle> for Stream> { fn complete(self, ident: syn::Ident) { - self.flow_state.borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::CycleSink { + self.flow_state().clone().borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::CycleSink { ident, - location_kind: self.location_kind, + location_kind: self.location_kind(), input: Box::new(self.ir_node.into_inner()), }); } } impl<'a, T, N: Location<'a>> CycleCollection<'a, TickCycle> for Stream> { - type Location = N; + type Location = Tick; - fn create_source(ident: syn::Ident, flow_state: FlowState, l: LocationId) -> Self { + fn create_source(ident: syn::Ident, location: Tick) -> Self { + let location_id = location.id(); Stream::new( - l, - flow_state, + location, HfPlusNode::CycleSource { ident, - location_kind: l, + location_kind: location_id, }, ) } @@ -105,9 +91,9 @@ impl<'a, T, N: Location<'a>> CycleCollection<'a, TickCycle> for Stream + NoTick> CycleComplete<'a, ()> for Stream { fn complete(self, ident: syn::Ident) { - self.flow_state.borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::CycleSink { + self.flow_state().clone().borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::CycleSink { ident, - location_kind: self.location_kind, + location_kind: self.location_kind(), input: Box::new(HfPlusNode::Unpersist(Box::new(self.ir_node.into_inner()))), }); } @@ -116,27 +102,22 @@ impl<'a, T, W, N: Location<'a> + NoTick> CycleComplete<'a, ()> for Stream + NoTick> CycleCollection<'a, ()> for Stream { type Location = N; - fn create_source(ident: syn::Ident, flow_state: FlowState, l: LocationId) -> Self { + fn create_source(ident: syn::Ident, location: N) -> Self { + let location_id = location.id(); Stream::new( - l, - flow_state, + location, HfPlusNode::Persist(Box::new(HfPlusNode::CycleSource { ident, - location_kind: l, + location_kind: location_id, })), ) } } impl<'a, T, W, N: Location<'a>> Stream { - pub(crate) fn new( - location_kind: LocationId, - flow_state: FlowState, - ir_node: HfPlusNode, - ) -> Self { + pub(crate) fn new(location: N, ir_node: HfPlusNode) -> Self { Stream { - location_kind, - flow_state, + location, ir_node: RefCell::new(ir_node), _phantom: PhantomData, } @@ -154,8 +135,7 @@ impl<'a, T: Clone, W, N: Location<'a>> Clone for Stream { if let HfPlusNode::Tee { inner } = self.ir_node.borrow().deref() { Stream { - location_kind: self.location_kind, - flow_state: self.flow_state.clone(), + location: self.location.clone(), ir_node: HfPlusNode::Tee { inner: TeeNode(inner.0.clone()), } @@ -171,8 +151,7 @@ impl<'a, T: Clone, W, N: Location<'a>> Clone for Stream { impl<'a, T, W, N: Location<'a>> Stream { pub fn map U + 'a>(self, f: impl IntoQuotedMut<'a, F>) -> Stream { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Map { f: f.splice_fn1().into(), input: Box::new(self.ir_node.into_inner()), @@ -185,8 +164,7 @@ impl<'a, T, W, N: Location<'a>> Stream { f: impl IntoQuotedMut<'a, F>, ) -> Stream { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::FlatMap { f: f.splice_fn1().into(), input: Box::new(self.ir_node.into_inner()), @@ -203,8 +181,7 @@ impl<'a, T, W, N: Location<'a>> Stream { pub fn filter bool + 'a>(self, f: impl IntoQuotedMut<'a, F>) -> Stream { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Filter { f: f.splice_fn1_borrow().into(), input: Box::new(self.ir_node.into_inner()), @@ -217,8 +194,7 @@ impl<'a, T, W, N: Location<'a>> Stream { f: impl IntoQuotedMut<'a, F>, ) -> Stream { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::FilterMap { f: f.splice_fn1().into(), input: Box::new(self.ir_node.into_inner()), @@ -234,13 +210,10 @@ impl<'a, T, W, N: Location<'a>> Stream { O: Clone, { let other: Optional = other.into(); - if self.location_kind != other.location_kind { - panic!("cross_singleton must be called on streams on the same node"); - } + check_matching_location(&self.location, &other.location); Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::CrossSingleton( Box::new(self.ir_node.into_inner()), Box::new(other.ir_node.into_inner()), @@ -254,13 +227,10 @@ impl<'a, T, W, N: Location<'a>> Stream { T: Clone, O: Clone, { - if self.location_kind != other.location_kind { - panic!("cross_product must be called on streams on the same node"); - } + check_matching_location(&self.location, &other.location); Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::CrossProduct( Box::new(self.ir_node.into_inner()), Box::new(other.ir_node.into_inner()), @@ -269,13 +239,10 @@ impl<'a, T, W, N: Location<'a>> Stream { } pub fn union(self, other: Stream) -> Stream { - if self.location_kind != other.location_kind { - panic!("union must be called on streams on the same node"); - } + check_matching_location(&self.location, &other.location); Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Union( Box::new(self.ir_node.into_inner()), Box::new(other.ir_node.into_inner()), @@ -288,14 +255,13 @@ impl<'a, T, W, N: Location<'a>> Stream { T: Eq + Hash, { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Unique(Box::new(self.ir_node.into_inner())), ) } pub fn dest_sink + 'a>(self, sink: impl Quoted<'a, S>) { - self.flow_state.borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::DestSink { + self.flow_state().clone().borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::DestSink { sink: sink.splice_typed().into(), input: Box::new(self.ir_node.into_inner()), }); @@ -305,8 +271,7 @@ impl<'a, T, W, N: Location<'a>> Stream { impl<'a, T, N: Location<'a>> Stream> { pub fn all_ticks(self) -> Stream { Stream::new( - self.location_kind, - self.flow_state, + self.location.outer().clone(), HfPlusNode::Persist(Box::new(self.ir_node.into_inner())), ) } @@ -316,16 +281,14 @@ impl<'a, T, N: Location<'a>> Stream> { T: Clone, { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Persist(Box::new(self.ir_node.into_inner())), ) } pub fn defer_tick(self) -> Stream> { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::DeferTick(Box::new(self.ir_node.into_inner())), ) } @@ -335,8 +298,7 @@ impl<'a, T, N: Location<'a>> Stream> { f: impl IntoQuotedMut<'a, F>, ) -> Stream> { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Inspect { f: f.splice_fn1_borrow().into(), input: Box::new(self.ir_node.into_inner()), @@ -345,11 +307,7 @@ impl<'a, T, N: Location<'a>> Stream> { } pub fn first(self) -> Optional> { - Optional::new( - self.location_kind, - self.flow_state, - self.ir_node.into_inner(), - ) + Optional::new(self.location, self.ir_node.into_inner()) } /// Allow this stream through if the other stream has elements, otherwise the output is empty. @@ -371,8 +329,7 @@ impl<'a, T, N: Location<'a>> Stream> { pub fn enumerate(self) -> Stream<(usize, T), Bounded, Tick> { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Enumerate(Box::new(self.ir_node.into_inner())), ) } @@ -383,8 +340,7 @@ impl<'a, T, N: Location<'a>> Stream> { comb: impl IntoQuotedMut<'a, F>, ) -> Singleton> { Singleton::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Fold { init: init.splice_fn0().into(), acc: comb.splice_fn2_borrow_mut().into(), @@ -398,8 +354,7 @@ impl<'a, T, N: Location<'a>> Stream> { comb: impl IntoQuotedMut<'a, F>, ) -> Optional> { Optional::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Reduce { f: comb.splice_fn2_borrow_mut().into(), input: Box::new(self.ir_node.into_inner()), @@ -434,8 +389,7 @@ impl<'a, T, N: Location<'a>> Stream> { T: Ord, { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Sort(Box::new(self.ir_node.into_inner())), ) } @@ -446,8 +400,7 @@ impl<'a, T, N: Location<'a>> Stream> { pub fn delta(self) -> Stream> { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Delta(Box::new(self.ir_node.into_inner())), ) } @@ -456,8 +409,7 @@ impl<'a, T, N: Location<'a>> Stream> { impl<'a, T, W, N: Location<'a> + NoTick> Stream { pub fn tick_batch(self) -> Stream> { Stream::new( - self.location_kind, - self.flow_state, + self.location.nest(), HfPlusNode::Unpersist(Box::new(self.ir_node.into_inner())), ) } @@ -471,8 +423,7 @@ impl<'a, T, W, N: Location<'a> + NoTick> Stream { pub fn inspect(self, f: impl IntoQuotedMut<'a, F>) -> Stream { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Persist(Box::new(HfPlusNode::Inspect { f: f.splice_fn1_borrow().into(), input: Box::new(HfPlusNode::Unpersist(Box::new(self.ir_node.into_inner()))), @@ -483,7 +434,7 @@ impl<'a, T, W, N: Location<'a> + NoTick> Stream { impl<'a, T, W, N: Location<'a> + NoTick> Stream { pub fn for_each(self, f: impl IntoQuotedMut<'a, F>) { - self.flow_state.borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::ForEach { + self.flow_state().clone().borrow_mut().leaves.as_mut().expect("Attempted to add a leaf to a flow that has already been finalized. No leaves can be added after the flow has been compiled.").push(HfPlusLeaf::ForEach { input: Box::new(HfPlusNode::Unpersist(Box::new(self.ir_node.into_inner()))), f: f.splice_fn1().into(), }); @@ -493,19 +444,9 @@ impl<'a, T, W, N: Location<'a> + NoTick> Stream { impl<'a, T, N: Location<'a> + NoTick> Stream { pub fn sample_every( self, - duration: impl Quoted<'a, std::time::Duration> + Copy + 'a, + interval: impl Quoted<'a, std::time::Duration> + Copy + 'a, ) -> Stream { - let interval = duration.splice_typed(); - - let samples = Stream::>::new( - self.location_kind, - self.flow_state.clone(), - HfPlusNode::Source { - source: HfPlusSource::Interval(interval.into()), - location_kind: self.location_kind, - }, - ); - + let samples = self.location.source_interval(interval).tick_batch(); self.tick_batch().continue_if(samples.first()).all_ticks() } @@ -518,8 +459,7 @@ impl<'a, T, N: Location<'a> + NoTick> Stream { // which produces all values from all ticks every tick, // so delta will always give the lastest aggregation Singleton::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Persist(Box::new(HfPlusNode::Fold { init: init.splice_fn0().into(), acc: comb.splice_fn2_borrow_mut().into(), @@ -533,8 +473,7 @@ impl<'a, T, N: Location<'a> + NoTick> Stream { comb: impl IntoQuotedMut<'a, F>, ) -> Optional { Optional::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Persist(Box::new(HfPlusNode::Reduce { f: comb.splice_fn2_borrow_mut().into(), input: Box::new(self.ir_node.into_inner()), @@ -570,13 +509,10 @@ impl<'a, T, N: Location<'a>> Stream { where T: Eq + Hash, { - if self.location_kind != other.location_kind { - panic!("union must be called on streams on the same node"); - } + check_matching_location(&self.location, &other.location); Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Difference( Box::new(self.ir_node.into_inner()), Box::new(other.ir_node.into_inner()), @@ -597,13 +533,10 @@ impl<'a, K, V1, W, N: Location<'a>> Stream<(K, V1), W, N> { where K: Eq + Hash, { - if self.location_kind != n.location_kind { - panic!("join must be called on streams on the same node"); - } + check_matching_location(&self.location, &n.location); Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::Join( Box::new(self.ir_node.into_inner()), Box::new(n.ir_node.into_inner()), @@ -615,13 +548,10 @@ impl<'a, K, V1, W, N: Location<'a>> Stream<(K, V1), W, N> { where K: Eq + Hash, { - if self.location_kind != n.location_kind { - panic!("anti_join must be called on streams on the same node"); - } + check_matching_location(&self.location, &n.location); Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::AntiJoin( Box::new(self.ir_node.into_inner()), Box::new(n.ir_node.into_inner()), @@ -637,8 +567,7 @@ impl<'a, K: Eq + Hash, V, N: Location<'a>> Stream<(K, V), Bounded, Tick> { comb: impl IntoQuotedMut<'a, F>, ) -> Stream<(K, A), Bounded, Tick> { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::FoldKeyed { init: init.splice_fn0().into(), acc: comb.splice_fn2_borrow_mut().into(), @@ -652,8 +581,7 @@ impl<'a, K: Eq + Hash, V, N: Location<'a>> Stream<(K, V), Bounded, Tick> { comb: impl IntoQuotedMut<'a, F>, ) -> Stream<(K, V), Bounded, Tick> { Stream::new( - self.location_kind, - self.flow_state, + self.location, HfPlusNode::ReduceKeyed { f: comb.splice_fn2_borrow_mut().into(), input: Box::new(self.ir_node.into_inner()), @@ -723,8 +651,8 @@ impl<'a, T, W, N: Location<'a> + NoTick> Stream { N: CanSend<'a, Cluster<'a, C2>, In = (ClusterId, T), Out = (Tag, T)>, T: Clone + Serialize + DeserializeOwned, { - let self_node_id = match self.location_kind { - LocationId::Cluster(cluster_id) => builder::ClusterSelfId { + let self_node_id = match self.location_kind() { + LocationId::Cluster(cluster_id) => ClusterSelfId { id: cluster_id, _phantom: PhantomData, }, @@ -748,10 +676,9 @@ impl<'a, T, W, N: Location<'a> + NoTick> Stream { let deserialize_pipeline = Some(deserialize_bincode::(N::tagged_type())); Stream::new( - other.id(), - self.flow_state, + other.clone(), HfPlusNode::Network { - from_location: self.location_kind, + from_location: self.location_kind(), from_key: None, to_location: other.id(), to_key: None, @@ -774,7 +701,8 @@ impl<'a, T, W, N: Location<'a> + NoTick> Stream { { let serialize_pipeline = Some(serialize_bincode::(N::is_demux())); - let mut flow_state_borrow = self.flow_state.borrow_mut(); + let flow_state = self.flow_state().clone(); + let mut flow_state_borrow = flow_state.borrow_mut(); let external_key = flow_state_borrow.next_external_out; flow_state_borrow.next_external_out += 1; @@ -786,7 +714,7 @@ impl<'a, T, W, N: Location<'a> + NoTick> Stream { leaves.push(HfPlusLeaf::ForEach { f: dummy_f.into(), input: Box::new(HfPlusNode::Network { - from_location: self.location_kind, + from_location: self.location_kind(), from_key: None, to_location: other.id(), to_key: Some(external_key), @@ -810,10 +738,9 @@ impl<'a, T, W, N: Location<'a> + NoTick> Stream { { let root = get_this_crate(); Stream::new( - other.id(), - self.flow_state, + other.clone(), HfPlusNode::Network { - from_location: self.location_kind, + from_location: self.location_kind(), from_key: None, to_location: other.id(), to_key: None, @@ -835,7 +762,8 @@ impl<'a, T, W, N: Location<'a> + NoTick> Stream { where N: CanSend<'a, ExternalProcess<'a, N2>, In = T, Out = Bytes>, { - let mut flow_state_borrow = self.flow_state.borrow_mut(); + let flow_state = self.flow_state().clone(); + let mut flow_state_borrow = flow_state.borrow_mut(); let external_key = flow_state_borrow.next_external_out; flow_state_borrow.next_external_out += 1; @@ -846,7 +774,7 @@ impl<'a, T, W, N: Location<'a> + NoTick> Stream { leaves.push(HfPlusLeaf::ForEach { f: dummy_f.into(), input: Box::new(HfPlusNode::Network { - from_location: self.location_kind, + from_location: self.location_kind(), from_key: None, to_location: other.id(), to_key: Some(external_key), diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir.snap index 70a8dd42e91b..370f07676be9 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir.snap @@ -12,7 +12,7 @@ expression: built.ir() f: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (u64 , u64) , (u64 , u64) , () > ({ use crate :: __staged :: cluster :: compute_pi :: * ; | (inside , total) , (inside_batch , total_batch) | { * inside += inside_batch ; * total += total_batch ; } }), input: Persist( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: compute_pi :: Worker > , (u64 , u64)) , (u64 , u64) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: compute_pi :: Worker > , (u64 , u64)) , (u64 , u64) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 0, @@ -70,10 +70,10 @@ expression: built.ir() ), }, Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < () , () > ({ use hydroflow_plus :: __staged :: singleton :: * ; | _u | () }), + f: stageleft :: runtime_support :: fn1_type_hint :: < tokio :: time :: Instant , () > ({ use hydroflow_plus :: __staged :: singleton :: * ; | _u | () }), input: Source { - source: Interval( - stageleft :: runtime_support :: type_hint :: < core :: time :: Duration > ({ use crate :: __staged :: cluster :: compute_pi :: * ; Duration :: from_secs (1) }), + source: Stream( + { use hydroflow_plus :: __staged :: location :: * ; let interval = { use crate :: __staged :: cluster :: compute_pi :: * ; Duration :: from_secs (1) } ; tokio_stream :: wrappers :: IntervalStream :: new (tokio :: time :: interval (interval)) }, ), location_kind: Process( 1, diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir@surface_graph_1.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir@surface_graph_1.snap index c73fdb714a8e..73ad09b5e521 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir@surface_graph_1.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir@surface_graph_1.snap @@ -4,10 +4,10 @@ expression: ir.surface_syntax_string() --- 1v1 = source_stream ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let env = FAKE ; let p2_port = "port_0" ; { env . port (p2_port) . connect_local_blocking :: < ConnectedTagged < ConnectedDirect > > () . into_source () } }); 2v1 = map (| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: compute_pi :: Worker > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < (u64 , u64) > (& b) . unwrap ()) }); -3v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: compute_pi :: Worker > , (u64 , u64)) , (u64 , u64) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b })); +3v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: compute_pi :: Worker > , (u64 , u64)) , (u64 , u64) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b })); 4v1 = reduce :: < 'static > (stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (u64 , u64) , (u64 , u64) , () > ({ use crate :: __staged :: cluster :: compute_pi :: * ; | (inside , total) , (inside_batch , total_batch) | { * inside += inside_batch ; * total += total_batch ; } })); -5v1 = source_interval (stageleft :: runtime_support :: type_hint :: < core :: time :: Duration > ({ use crate :: __staged :: cluster :: compute_pi :: * ; Duration :: from_secs (1) })); -6v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < () , () > ({ use hydroflow_plus :: __staged :: singleton :: * ; | _u | () })); +5v1 = source_stream ({ use hydroflow_plus :: __staged :: location :: * ; let interval = { use crate :: __staged :: cluster :: compute_pi :: * ; Duration :: from_secs (1) } ; tokio_stream :: wrappers :: IntervalStream :: new (tokio :: time :: interval (interval)) }); +6v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < tokio :: time :: Instant , () > ({ use hydroflow_plus :: __staged :: singleton :: * ; | _u | () })); 7v1 = cross_singleton (); 8v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < ((u64 , u64) , ()) , (u64 , u64) > ({ use hydroflow_plus :: __staged :: singleton :: * ; | (d , _signal) | d })); 9v1 = for_each (stageleft :: runtime_support :: fn1_type_hint :: < (u64 , u64) , () > ({ use crate :: __staged :: cluster :: compute_pi :: * ; | (inside , total) | { println ! ("pi: {} ({} trials)" , 4.0 * inside as f64 / total as f64 , total) ; } })); diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__many_to_many__tests__many_to_many.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__many_to_many__tests__many_to_many.snap index d58ad11b7168..e10ab16062d6 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__many_to_many__tests__many_to_many.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__many_to_many__tests__many_to_many.snap @@ -4,7 +4,7 @@ expression: built.ir() --- [ ForEach { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < () > , i32) , () > ({ use crate :: __staged :: cluster :: many_to_many :: * ; | n | println ! ("cluster received: {:?}" , n) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) , () > ({ use crate :: __staged :: cluster :: many_to_many :: * ; | n | println ! ("cluster received: {:?}" , n) }), input: Network { from_location: Cluster( 0, @@ -36,7 +36,7 @@ expression: built.ir() ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < i32 , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: ClusterId < () > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < () > > > (__hydroflow_plus_cluster_ids_0) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < i32 , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < () > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < () > > > (__hydroflow_plus_cluster_ids_0) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: Source { source: Iter( { use crate :: __staged :: cluster :: many_to_many :: * ; 0 .. 2 }, diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir.snap index c895c3413a7c..5daa117e821c 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir.snap @@ -9,7 +9,7 @@ expression: built.ir() f: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < i32 , i32 , () > ({ use crate :: __staged :: cluster :: map_reduce :: * ; | total , count | * total += count }), input: Persist( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , (std :: string :: String , i32)) , (std :: string :: String , i32) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , (std :: string :: String , i32)) , (std :: string :: String , i32) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 1, @@ -78,7 +78,7 @@ expression: built.ir() ), ), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , std :: string :: String) , (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , std :: string :: String) > ({ use crate :: __staged :: cluster :: map_reduce :: * ; let all_ids_vec = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > > > (__hydroflow_plus_cluster_ids_1) } ; | (i , w) | (ClusterId :: from_raw ((i % all_ids_vec . len ()) as u32) , w) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , std :: string :: String) , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , std :: string :: String) > ({ use crate :: __staged :: cluster :: map_reduce :: * ; let all_ids_vec = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > > > (__hydroflow_plus_cluster_ids_1) } ; | (i , w) | (ClusterId :: from_raw ((i % all_ids_vec . len ()) as u32) , w) }), input: Enumerate( Map { f: stageleft :: runtime_support :: fn1_type_hint :: < & str , std :: string :: String > ({ use crate :: __staged :: cluster :: map_reduce :: * ; | s | s . to_string () }), diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir@surface_graph_0.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir@surface_graph_0.snap index 06befe0c8323..a45a39badd06 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir@surface_graph_0.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir@surface_graph_0.snap @@ -5,12 +5,12 @@ expression: ir.surface_syntax_string() 1v1 = source_iter ({ use crate :: __staged :: cluster :: map_reduce :: * ; vec ! ["abc" , "abc" , "xyz" , "abc"] }); 2v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < & str , std :: string :: String > ({ use crate :: __staged :: cluster :: map_reduce :: * ; | s | s . to_string () })); 3v1 = enumerate (); -4v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < (usize , std :: string :: String) , (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , std :: string :: String) > ({ use crate :: __staged :: cluster :: map_reduce :: * ; let all_ids_vec = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > > > (__hydroflow_plus_cluster_ids_1) } ; | (i , w) | (ClusterId :: from_raw ((i % all_ids_vec . len ()) as u32) , w) })); +4v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < (usize , std :: string :: String) , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , std :: string :: String) > ({ use crate :: __staged :: cluster :: map_reduce :: * ; let all_ids_vec = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > > > (__hydroflow_plus_cluster_ids_1) } ; | (i , w) | (ClusterId :: from_raw ((i % all_ids_vec . len ()) as u32) , w) })); 5v1 = map (| (id , data) : (hydroflow_plus :: ClusterId < _ > , std :: string :: String) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < std :: string :: String > (& data) . unwrap () . into ()) }); 6v1 = dest_sink ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let env = FAKE ; let p1_port = "port_0" ; { env . port (p1_port) . connect_local_blocking :: < ConnectedDemux < ConnectedDirect > > () . into_sink () } }); 7v1 = source_stream ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let env = FAKE ; let p2_port = "port_1" ; { env . port (p2_port) . connect_local_blocking :: < ConnectedTagged < ConnectedDirect > > () . into_source () } }); 8v1 = map (| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: map_reduce :: Worker > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < (std :: string :: String , i32) > (& b) . unwrap ()) }); -9v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , (std :: string :: String , i32)) , (std :: string :: String , i32) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b })); +9v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , (std :: string :: String , i32)) , (std :: string :: String , i32) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b })); 10v1 = reduce_keyed :: < 'static > (stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < i32 , i32 , () > ({ use crate :: __staged :: cluster :: map_reduce :: * ; | total , count | * total += count })); 11v1 = for_each (stageleft :: runtime_support :: fn1_type_hint :: < (std :: string :: String , i32) , () > ({ use crate :: __staged :: cluster :: map_reduce :: * ; | (string , count) | println ! ("{}: {}" , string , count) })); diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__paxos_bench__tests__paxos_ir.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__paxos_bench__tests__paxos_ir.snap index 2a93b6e9c6f4..a96b377e89c1 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__paxos_bench__tests__paxos_ir.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__paxos_bench__tests__paxos_ir.snap @@ -44,7 +44,7 @@ expression: built.ir() Union( Union( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use crate :: __staged :: cluster :: paxos :: * ; | p1a | p1a . max_ballot }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use crate :: __staged :: cluster :: paxos :: * ; | p1a | p1a . max_ballot }), input: CycleSource { ident: Ident { sym: cycle_1, @@ -55,7 +55,7 @@ expression: built.ir() }, }, Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use crate :: __staged :: cluster :: paxos :: * ; | p2b | p2b . max_ballot }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use crate :: __staged :: cluster :: paxos :: * ; | p2b | p2b . max_ballot }), input: CycleSource { ident: Ident { sym: cycle_0, @@ -124,7 +124,7 @@ expression: built.ir() ), input: Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 0, @@ -156,7 +156,7 @@ expression: built.ir() ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: Ballot , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > > > (__hydroflow_plus_cluster_ids_0) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: Ballot , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > > > (__hydroflow_plus_cluster_ids_0) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: Map { f: stageleft :: runtime_support :: fn1_type_hint :: < u32 , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use crate :: __staged :: cluster :: paxos :: * ; let p_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; move | ballot_num | Ballot { num : ballot_num , proposer_id : p_id } }), input: Map { @@ -184,10 +184,10 @@ expression: built.ir() ), }, Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < () , () > ({ use hydroflow_plus :: __staged :: singleton :: * ; | _u | () }), + f: stageleft :: runtime_support :: fn1_type_hint :: < tokio :: time :: Instant , () > ({ use hydroflow_plus :: __staged :: singleton :: * ; | _u | () }), input: Source { - source: Interval( - stageleft :: runtime_support :: type_hint :: < core :: time :: Duration > ({ use crate :: __staged :: cluster :: paxos :: * ; let i_am_leader_send_timeout = 1u64 ; Duration :: from_secs (i_am_leader_send_timeout) }), + source: Stream( + { use hydroflow_plus :: __staged :: location :: * ; let interval = { use crate :: __staged :: cluster :: paxos :: * ; let i_am_leader_send_timeout = 1u64 ; Duration :: from_secs (i_am_leader_send_timeout) } ; tokio_stream :: wrappers :: IntervalStream :: new (tokio :: time :: interval (interval)) }, ), location_kind: Cluster( 0, @@ -211,7 +211,7 @@ expression: built.ir() ), input: Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > >) , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > >) , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 1, @@ -226,7 +226,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > (& data) . unwrap () . into ()) }", ], }, ), @@ -237,18 +237,18 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Acceptor > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Acceptor > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > (& b) . unwrap ()) }", ], }, ), ), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < ((hydroflow_plus_test :: cluster :: paxos :: P1a , hydroflow_plus_test :: cluster :: paxos :: Ballot) , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | ((p1a , max_ballot) , log) | (p1a . ballot . proposer_id , P1b { ballot : p1a . ballot , max_ballot , accepted : log }) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < ((hydroflow_plus_test :: cluster :: paxos :: P1a , hydroflow_plus_test :: cluster :: paxos :: Ballot) , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | ((p1a , max_ballot) , log) | (p1a . ballot . proposer_id , P1b { ballot : p1a . ballot , max_ballot , accepted : log }) }), input: CrossSingleton( CrossSingleton( Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P1a) , hydroflow_plus_test :: cluster :: paxos :: P1a > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P1a) , hydroflow_plus_test :: cluster :: paxos :: P1a > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 0, @@ -280,7 +280,7 @@ expression: built.ir() ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1a , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > > (__hydroflow_plus_cluster_ids_1) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1a , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > > (__hydroflow_plus_cluster_ids_1) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: Inspect { f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1a , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | _ | println ! ("Proposer leader expired, sending P1a") }), input: Map { @@ -378,7 +378,7 @@ expression: built.ir() }, ), Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (core :: option :: Option < usize > , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (_ckpnt , log) | log . clone () }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (core :: option :: Option < usize > , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (_ckpnt , log) | log . clone () }), input: CycleSource { ident: Ident { sym: cycle_0, @@ -409,16 +409,16 @@ expression: built.ir() f: stageleft :: runtime_support :: fn1_type_hint :: < usize , core :: option :: Option < bool > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f = 1usize ; move | num_received | if num_received > f { Some (true) } else { None } }), input: Fold { init: stageleft :: runtime_support :: fn0_type_hint :: < usize > ({ use hydroflow_plus :: __staged :: stream :: * ; | | 0usize }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | count , _ | * count += 1 }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | count , _ | * count += 1 }), input: Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , u32) , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | t | t . 0 }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , u32) , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | t | t . 0 }), input: Filter { - f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , u32) , bool > ({ use crate :: __staged :: cluster :: paxos :: * ; let p_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; move | (p1b , ballot_num) | p1b . ballot . num == * ballot_num && p1b . ballot . proposer_id == p_id }), + f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , u32) , bool > ({ use crate :: __staged :: cluster :: paxos :: * ; let p_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; move | (p1b , ballot_num) | p1b . ballot . num == * ballot_num && p1b . ballot . proposer_id == p_id }), input: CrossSingleton( Persist( Inspect { - f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | p1b | println ! ("Proposer received P1b: {:?}" , p1b) }), + f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | p1b | println ! ("Proposer received P1b: {:?}" , p1b) }), input: Tee { inner: , }, @@ -475,13 +475,13 @@ expression: built.ir() inner: : Reduce { f: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , usize , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | curr , new | { if new > * curr { * curr = new ; } } }), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , _) | slot }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , _) | slot }), input: Tee { inner: : FoldKeyed { - init: stageleft :: runtime_support :: fn0_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | | (0 , None) }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | curr_entry , new_entry | { if let Some (curr_entry_payload) = & mut curr_entry . 1 { let same_values = new_entry . value == curr_entry_payload . value ; let higher_ballot = new_entry . ballot > curr_entry_payload . ballot ; if same_values { curr_entry . 0 += 1 ; } if higher_ballot { curr_entry_payload . ballot = new_entry . ballot ; if ! same_values { curr_entry . 0 = 1 ; curr_entry_payload . value = new_entry . value ; } } } else { * curr_entry = (1 , Some (new_entry)) ; } } }), + init: stageleft :: runtime_support :: fn0_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | | (0 , None) }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | curr_entry , new_entry | { if let Some (curr_entry_payload) = & mut curr_entry . 1 { let same_values = new_entry . value == curr_entry_payload . value ; let higher_ballot = new_entry . ballot > curr_entry_payload . ballot ; if same_values { curr_entry . 0 += 1 ; } if higher_ballot { curr_entry_payload . ballot = new_entry . ballot ; if ! same_values { curr_entry . 0 = 1 ; curr_entry_payload . value = new_entry . value ; } } } else { * curr_entry = (1 , Some (new_entry)) ; } } }), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , std :: collections :: hash_map :: IntoIter < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | p1b | p1b . accepted . into_iter () }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , std :: collections :: hash_map :: IntoIter < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | p1b | p1b . accepted . into_iter () }), input: Tee { inner: , }, @@ -531,15 +531,15 @@ expression: built.ir() Tee { inner: : Fold { init: stageleft :: runtime_support :: fn0_type_hint :: < usize > ({ use hydroflow_plus :: __staged :: stream :: * ; | | 0usize }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | count , _ | * count += 1 }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | count , _ | * count += 1 }), input: Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (((usize , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , usize) , u32) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; let p_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; move | (((index , payload) , next_slot) , ballot_num) | P2a { ballot : Ballot { num : ballot_num , proposer_id : p_id } , slot : next_slot + index , value : Some (payload) } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (((usize , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , usize) , u32) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; let p_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; move | (((index , payload) , next_slot) , ballot_num) | P2a { ballot : Ballot { num : ballot_num , proposer_id : p_id } , slot : next_slot + index , value : Some (payload) } }), input: CrossSingleton( CrossSingleton( Enumerate( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 2, @@ -554,7 +554,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& data) . unwrap () . into ()) }", ], }, ), @@ -565,7 +565,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_bench :: Client > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_bench :: Client > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& b) . unwrap ()) }", ], }, ), @@ -619,23 +619,23 @@ expression: built.ir() input: DeferTick( Difference( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , _value) | slot }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , _value) | slot }), input: Tee { inner: : FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >)) , core :: option :: Option < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f = 1usize ; move | ((slot , _ballot) , (count , value)) | if count > f { Some ((slot , value)) } else { None } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >)) , core :: option :: Option < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f = 1usize ; move | ((slot , _ballot) , (count , value)) | if count > f { Some ((slot , value)) } else { None } }), input: Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >)) > ({ use crate :: __staged :: cluster :: paxos :: * ; | (k , (count , v)) | (k , (count , v . unwrap ())) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >)) > ({ use crate :: __staged :: cluster :: paxos :: * ; | (k , (count , v)) | (k , (count , v . unwrap ())) }), input: FoldKeyed { - init: stageleft :: runtime_support :: fn0_type_hint :: < (usize , core :: option :: Option < core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | | (0 , None) }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (usize , core :: option :: Option < core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | accum , value | { accum . 0 += 1 ; accum . 1 = Some (value) ; } }), + init: stageleft :: runtime_support :: fn0_type_hint :: < (usize , core :: option :: Option < core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | | (0 , None) }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (usize , core :: option :: Option < core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | accum , value | { accum . 0 += 1 ; accum . 1 = Some (value) ; } }), input: FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , core :: option :: Option < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > > ({ use crate :: __staged :: cluster :: paxos :: * ; | p2b | if p2b . ballot == p2b . max_ballot { Some (((p2b . slot , p2b . ballot) , p2b . value)) } else { None } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , core :: option :: Option < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > > ({ use crate :: __staged :: cluster :: paxos :: * ; | p2b | if p2b . ballot == p2b . max_ballot { Some (((p2b . slot , p2b . ballot) , p2b . value)) } else { None } }), input: Tee { inner: : Union( Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 1, @@ -650,7 +650,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& data) . unwrap () . into ()) }", ], }, ), @@ -661,17 +661,17 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Acceptor > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Acceptor > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& b) . unwrap ()) }", ], }, ), ), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | (p2a , max_ballot) | (p2a . ballot . proposer_id , P2b { ballot : p2a . ballot , max_ballot , slot : p2a . slot , value : p2a . value }) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | (p2a , max_ballot) | (p2a . ballot . proposer_id , P2b { ballot : p2a . ballot , max_ballot , slot : p2a . slot , value : p2a . value }) }), input: CrossSingleton( Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 0, @@ -686,7 +686,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& data) . unwrap () . into ()) }", ], }, ), @@ -697,23 +697,23 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& b) . unwrap ()) }", ], }, ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > > (__hydroflow_plus_cluster_ids_1) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > > (__hydroflow_plus_cluster_ids_1) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , ()) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (d , _signal) | d }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , ()) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (d , _signal) | d }), input: CrossSingleton( Union( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , ()) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (d , _signal) | d }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , ()) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (d , _signal) | d }), input: CrossSingleton( Union( FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , u32) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f = 1usize ; let p_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; move | ((slot , (count , entry)) , ballot_num) | { let entry = entry . unwrap () ; if count <= f { Some (P2a { ballot : Ballot { num : ballot_num , proposer_id : p_id , } , slot , value : entry . value , }) } else { None } } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , u32) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f = 1usize ; let p_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; move | ((slot , (count , entry)) , ballot_num) | { let entry = entry . unwrap () ; if count <= f { Some (P2a { ballot : Ballot { num : ballot_num , proposer_id : p_id , } , slot , value : entry . value , }) } else { None } } }), input: CrossSingleton( Tee { inner: , @@ -724,7 +724,7 @@ expression: built.ir() ), }, Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , u32) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; let p_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; move | (slot , ballot_num) | P2a { ballot : Ballot { num : ballot_num , proposer_id : p_id } , slot , value : None } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , u32) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; let p_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; move | (slot , ballot_num) | P2a { ballot : Ballot { num : ballot_num , proposer_id : p_id } , slot , value : None } }), input: CrossSingleton( Difference( FlatMap { @@ -734,7 +734,7 @@ expression: built.ir() }, }, Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , _) | slot }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , _) | slot }), input: Tee { inner: , }, @@ -819,7 +819,7 @@ expression: built.ir() }, Tee { inner: : FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >)) , core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f = 1usize ; move | ((slot , _ballot) , (count , _p2b)) | if count == 2 * f + 1 { Some (slot) } else { None } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >)) , core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f = 1usize ; move | ((slot , _ballot) , (count , _p2b)) | if count == 2 * f + 1 { Some (slot) } else { None } }), input: Tee { inner: , }, @@ -837,10 +837,10 @@ expression: built.ir() ), input: DeferTick( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (_slot , p2b) | p2b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (_slot , p2b) | p2b }), input: AntiJoin( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , (usize , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | p2b | (p2b . slot , p2b) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , (usize , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | p2b | (p2b . slot , p2b) }), input: Tee { inner: , }, @@ -860,12 +860,12 @@ expression: built.ir() 1, ), input: Fold { - init: stageleft :: runtime_support :: fn0_type_hint :: < (core :: option :: Option < usize > , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | | (None , HashMap :: new ()) }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (core :: option :: Option < usize > , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , hydroflow_plus_test :: cluster :: paxos :: CheckpointOrP2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | (prev_checkpoint , log) , checkpoint_or_p2a | { match checkpoint_or_p2a { CheckpointOrP2a :: Checkpoint (new_checkpoint) => { for slot in (prev_checkpoint . unwrap_or (0)) .. new_checkpoint { log . remove (& slot) ; } * prev_checkpoint = Some (new_checkpoint) ; } CheckpointOrP2a :: P2a (p2a) => { if prev_checkpoint . map (| prev | p2a . slot > prev) . unwrap_or (true) && log . get (& p2a . slot) . map (| prev_p2a : & LogValue < _ > | p2a . ballot > prev_p2a . ballot) . unwrap_or (true) { log . insert (p2a . slot , LogValue { ballot : p2a . ballot , value : p2a . value , } ,) ; } } } } }), + init: stageleft :: runtime_support :: fn0_type_hint :: < (core :: option :: Option < usize > , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | | (None , HashMap :: new ()) }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (core :: option :: Option < usize > , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , hydroflow_plus_test :: cluster :: paxos :: CheckpointOrP2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | (prev_checkpoint , log) , checkpoint_or_p2a | { match checkpoint_or_p2a { CheckpointOrP2a :: Checkpoint (new_checkpoint) => { for slot in (prev_checkpoint . unwrap_or (0)) .. new_checkpoint { log . remove (& slot) ; } * prev_checkpoint = Some (new_checkpoint) ; } CheckpointOrP2a :: P2a (p2a) => { if prev_checkpoint . map (| prev | p2a . slot > prev) . unwrap_or (true) && log . get (& p2a . slot) . map (| prev_p2a : & LogValue < _ > | p2a . ballot > prev_p2a . ballot) . unwrap_or (true) { log . insert (p2a . slot , LogValue { ballot : p2a . ballot , value : p2a . value , } ,) ; } } } } }), input: Persist( Union( FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: CheckpointOrP2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (p2a , max_ballot) | if p2a . ballot >= max_ballot { Some (CheckpointOrP2a :: P2a (p2a)) } else { None } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: CheckpointOrP2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (p2a , max_ballot) | if p2a . ballot >= max_ballot { Some (CheckpointOrP2a :: P2a (p2a)) } else { None } }), input: CrossSingleton( Tee { inner: , @@ -876,14 +876,14 @@ expression: built.ir() ), }, Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < usize , hydroflow_plus_test :: cluster :: paxos :: CheckpointOrP2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | min_seq | CheckpointOrP2a :: Checkpoint (min_seq) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < usize , hydroflow_plus_test :: cluster :: paxos :: CheckpointOrP2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | min_seq | CheckpointOrP2a :: Checkpoint (min_seq) }), input: Delta( Reduce { f: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , usize , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | curr , new | { if new < * curr { * curr = new ; } } }), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (_sender , seq) | seq }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (_sender , seq) | seq }), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < ((hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) , ()) , (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (d , _signal) | d }), + f: stageleft :: runtime_support :: fn1_type_hint :: < ((hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) , ()) , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (d , _signal) | d }), input: CrossSingleton( Tee { inner: : ReduceKeyed { @@ -920,7 +920,7 @@ expression: built.ir() ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < usize , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > > (__hydroflow_plus_cluster_ids_1) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < usize , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > > (__hydroflow_plus_cluster_ids_1) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: CycleSource { ident: Ident { sym: cycle_0, @@ -940,7 +940,7 @@ expression: built.ir() f: stageleft :: runtime_support :: fn1_type_hint :: < usize , core :: option :: Option < bool > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f = 1usize ; move | num_received | if num_received == f + 1 { Some (true) } else { None } }), input: Fold { init: stageleft :: runtime_support :: fn0_type_hint :: < usize > ({ use hydroflow_plus :: __staged :: stream :: * ; | | 0usize }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | count , _ | * count += 1 }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | count , _ | * count += 1 }), input: Tee { inner: , }, @@ -977,15 +977,15 @@ expression: built.ir() ), input: DeferTick( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , _) | { sorted_payload } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , _) | { sorted_payload } }), input: Filter { - f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , bool > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , highest_seq) | sorted_payload . seq > * highest_seq }), + f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , bool > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , highest_seq) | sorted_payload . seq > * highest_seq }), input: CrossSingleton( Tee { inner: : Sort( Union( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 0, @@ -1000,7 +1000,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& data) . unwrap () . into ()) }", ], }, ), @@ -1011,15 +1011,15 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& b) . unwrap ()) }", ], }, ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > > > (__hydroflow_plus_cluster_ids_3) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > > > (__hydroflow_plus_cluster_ids_3) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (slot , kv) | SequencedKv { seq : slot , kv } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (slot , kv) | SequencedKv { seq : slot , kv } }), input: AntiJoin( Tee { inner: , @@ -1053,7 +1053,7 @@ expression: built.ir() f: stageleft :: runtime_support :: fn1_type_hint :: < core :: option :: Option < usize > , core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | v | v }), input: Fold { init: stageleft :: runtime_support :: fn0_type_hint :: < core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | | None }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < core :: option :: Option < usize > , (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) , () > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | filled_slot , (sorted_payload , highest_seq) | { let expected_next_slot = std :: cmp :: max (filled_slot . map (| v | v + 1) . unwrap_or (0) , highest_seq . map (| v | v + 1) . unwrap_or (0) ,) ; if sorted_payload . seq == expected_next_slot { * filled_slot = Some (sorted_payload . seq) ; } } }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < core :: option :: Option < usize > , (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) , () > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | filled_slot , (sorted_payload , highest_seq) | { let expected_next_slot = std :: cmp :: max (filled_slot . map (| v | v + 1) . unwrap_or (0) , highest_seq . map (| v | v + 1) . unwrap_or (0) ,) ; if sorted_payload . seq == expected_next_slot { * filled_slot = Some (sorted_payload . seq) ; } } }), input: CrossSingleton( Tee { inner: , @@ -1100,16 +1100,16 @@ expression: built.ir() input: DeferTick( Tee { inner: : FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < (std :: collections :: hash_map :: HashMap < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) , core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (_kv_store , highest_seq) | highest_seq }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (std :: collections :: hash_map :: HashMap < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) , core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (_kv_store , highest_seq) | highest_seq }), input: Fold { - init: stageleft :: runtime_support :: fn0_type_hint :: < (std :: collections :: hash_map :: HashMap < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | | (HashMap :: new () , None) }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (std :: collections :: hash_map :: HashMap < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , () > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (kv_store , last_seq) , payload | { if let Some (kv) = payload . kv { kv_store . insert (kv . key , kv . value) ; } debug_assert ! (payload . seq == (last_seq . map (| s | s + 1) . unwrap_or (0)) , "Hole in log between seq {:?} and {}" , * last_seq , payload . seq) ; * last_seq = Some (payload . seq) ; } }), + init: stageleft :: runtime_support :: fn0_type_hint :: < (std :: collections :: hash_map :: HashMap < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | | (HashMap :: new () , None) }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (std :: collections :: hash_map :: HashMap < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , () > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (kv_store , last_seq) , payload | { if let Some (kv) = payload . kv { kv_store . insert (kv . key , kv . value) ; } debug_assert ! (payload . seq == (last_seq . map (| s | s + 1) . unwrap_or (0)) , "Hole in log between seq {:?} and {}" , * last_seq , payload . seq) ; * last_seq = Some (payload . seq) ; } }), input: Persist( Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , _) | { sorted_payload } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , _) | { sorted_payload } }), input: Filter { - f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , bool > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , highest_seq) | sorted_payload . seq <= * highest_seq }), + f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , bool > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , highest_seq) | sorted_payload . seq <= * highest_seq }), input: CrossSingleton( Tee { inner: , @@ -1194,7 +1194,7 @@ expression: built.ir() 2, ), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , ()) , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | (leader_id , _) | leader_id }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , ()) , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | (leader_id , _) | leader_id }), input: Network { from_location: Cluster( 0, @@ -1226,7 +1226,7 @@ expression: built.ir() ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < () , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (__hydroflow_plus_cluster_ids_2) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < () , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (__hydroflow_plus_cluster_ids_2) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: Map { f: stageleft :: runtime_support :: fn1_type_hint :: < bool , () > ({ use crate :: __staged :: cluster :: paxos :: * ; move | _ | () }), input: Tee { @@ -1249,7 +1249,7 @@ expression: built.ir() Tee { inner: : Union( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , (u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica >) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | (sender , replica_payload) | (replica_payload . key , sender) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , (u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica >) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | (sender , replica_payload) | (replica_payload . key , sender) }), input: Network { from_location: Cluster( 3, @@ -1264,7 +1264,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& data) . unwrap () . into ()) }", ], }, ), @@ -1275,15 +1275,15 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& b) . unwrap ()) }", ], }, ), ), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | payload | (payload . value , payload) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | payload | (payload . value , payload) }), input: FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | payload | payload . kv }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | payload | payload . kv }), input: Tee { inner: , }, @@ -1306,7 +1306,7 @@ expression: built.ir() f: stageleft :: runtime_support :: fn1_type_hint :: < (u32 , usize) , core :: option :: Option < u32 > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let f = 1usize ; move | (key , count) | { if count == f + 1 { Some (key) } else { None } } }), input: FoldKeyed { init: stageleft :: runtime_support :: fn0_type_hint :: < usize > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | | 0 }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , () > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | curr_count , _sender | { * curr_count += 1 ; } }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , () > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | curr_count , _sender | { * curr_count += 1 ; } }), input: Tee { inner: , }, @@ -1325,15 +1325,15 @@ expression: built.ir() ), input: Union( FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , std :: iter :: Map < std :: ops :: Range < usize > , _ > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let c_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_bench :: Client > :: from_raw (__hydroflow_plus_cluster_self_id_2) ; let num_clients_per_node = 1usize ; move | leader_ballot | (0 .. num_clients_per_node) . map (move | i | (leader_ballot , KvPayload { key : i as u32 , value : c_id })) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , std :: iter :: Map < std :: ops :: Range < usize > , _ > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let c_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_bench :: Client > :: from_raw (__hydroflow_plus_cluster_self_id_2) ; let num_clients_per_node = 1usize ; move | leader_ballot | (0 .. num_clients_per_node) . map (move | i | (leader_ballot , KvPayload { key : i as u32 , value : c_id })) }), input: Tee { inner: : Delta( Tee { inner: : Reduce { - f: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | curr , new | { if new > * curr { * curr = new ; } } }), + f: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | curr , new | { if new > * curr { * curr = new ; } } }), input: Persist( Inspect { - f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , () > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | ballot | println ! ("Client notified that leader was elected: {:?}" , ballot) }), + f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , () > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | ballot | println ! ("Client notified that leader was elected: {:?}" , ballot) }), input: CycleSource { ident: Ident { sym: cycle_0, @@ -1350,7 +1350,7 @@ expression: built.ir() }, }, Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer >) , (hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let c_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_bench :: Client > :: from_raw (__hydroflow_plus_cluster_self_id_2) ; move | (key , cur_leader) | (cur_leader , KvPayload { key , value : c_id }) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer >) , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let c_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_bench :: Client > :: from_raw (__hydroflow_plus_cluster_self_id_2) ; move | (key , cur_leader) | (cur_leader , KvPayload { key , value : c_id }) }), input: CrossSingleton( Tee { inner: , @@ -1387,7 +1387,7 @@ expression: built.ir() FlatMap { f: stageleft :: runtime_support :: fn1_type_hint :: < std :: time :: SystemTime , std :: iter :: Map < std :: ops :: Range < usize > , _ > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let num_clients_per_node = 1usize ; move | now | (0 .. num_clients_per_node) . map (move | virtual_id | (virtual_id , now)) }), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus :: location :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , std :: time :: SystemTime > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | _ | SystemTime :: now () }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , std :: time :: SystemTime > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | _ | SystemTime :: now () }), input: Tee { inner: , }, diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__simple_cluster__tests__simple_cluster.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__simple_cluster__tests__simple_cluster.snap index 8fd05b1df972..a011fb746712 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__simple_cluster__tests__simple_cluster.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__simple_cluster__tests__simple_cluster.snap @@ -4,7 +4,7 @@ expression: built.ir() --- [ ForEach { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < () > , (hydroflow_plus :: location :: ClusterId < () > , i32)) , () > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; | (id , d) | println ! ("node received: ({}, {:?})" , id , d) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32)) , () > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; | (id , d) | println ! ("node received: ({}, {:?})" , id , d) }), input: Network { from_location: Cluster( 1, @@ -19,7 +19,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| data | { hydroflow_plus :: runtime_support :: bincode :: serialize :: < (hydroflow_plus :: location :: ClusterId < () > , i32) > (& data) . unwrap () . into () }", + "| data | { hydroflow_plus :: runtime_support :: bincode :: serialize :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) > (& data) . unwrap () . into () }", ], }, ), @@ -30,13 +30,13 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < () > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < (hydroflow_plus :: location :: ClusterId < () > , i32) > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < () > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) > (& b) . unwrap ()) }", ], }, ), ), input: Inspect { - f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus :: location :: ClusterId < () > , i32) , () > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; let cluster_self_id = hydroflow_plus :: ClusterId :: < () > :: from_raw (__hydroflow_plus_cluster_self_id_1) ; move | n | println ! ("cluster received: {:?} (self cluster id: {})" , n , cluster_self_id) }), + f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) , () > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; let cluster_self_id = hydroflow_plus :: ClusterId :: < () > :: from_raw (__hydroflow_plus_cluster_self_id_1) ; move | n | println ! ("cluster received: {:?} (self cluster id: {})" , n , cluster_self_id) }), input: Network { from_location: Process( 0, @@ -51,7 +51,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , (hydroflow_plus :: location :: ClusterId < () > , i32)) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < (hydroflow_plus :: location :: ClusterId < () > , i32) > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32)) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) > (& data) . unwrap () . into ()) }", ], }, ), @@ -62,18 +62,18 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { hydroflow_plus :: runtime_support :: bincode :: deserialize :: < (hydroflow_plus :: location :: ClusterId < () > , i32) > (& res . unwrap ()) . unwrap () }", + "| res | { hydroflow_plus :: runtime_support :: bincode :: deserialize :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) > (& res . unwrap ()) . unwrap () }", ], }, ), ), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: ClusterId < () > , i32) , (hydroflow_plus :: location :: ClusterId < () > , (hydroflow_plus :: location :: ClusterId < () > , i32)) > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; | (id , n) | (id , (id , n)) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) , (hydroflow_plus :: location :: cluster :: ClusterId < () > , (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32)) > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; | (id , n) | (id , (id , n)) }), input: Delta( CrossProduct( Persist( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < & hydroflow_plus :: location :: ClusterId < () > , hydroflow_plus :: location :: ClusterId < () > > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; | & id | id }), + f: stageleft :: runtime_support :: fn1_type_hint :: < & hydroflow_plus :: location :: cluster :: ClusterId < () > , hydroflow_plus :: location :: cluster :: ClusterId < () > > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; | & id | id }), input: Source { source: Iter( unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < () > > > (__hydroflow_plus_cluster_ids_1) }, diff --git a/hydroflow_plus_test/src/distributed/first_ten.rs b/hydroflow_plus_test/src/distributed/first_ten.rs index 18b7703f8ab4..cead08979018 100644 --- a/hydroflow_plus_test/src/distributed/first_ten.rs +++ b/hydroflow_plus_test/src/distributed/first_ten.rs @@ -1,5 +1,6 @@ use hydroflow_plus::*; -use location::{ExternalBincodeSink, ExternalProcess}; +use location::external_process::ExternalBincodeSink; +use location::ExternalProcess; use serde::{Deserialize, Serialize}; use stageleft::*;