pub enum HydroNode {
Show 52 variants
Placeholder,
Cast {
inner: Box<HydroNode>,
metadata: HydroIrMetadata,
},
CastUpdateStream {
inner: Box<HydroNode>,
metadata: HydroIrMetadata,
},
ObserveNonDet {
inner: Box<HydroNode>,
trusted: bool,
metadata: HydroIrMetadata,
},
Source {
source: HydroSource,
metadata: HydroIrMetadata,
},
SingletonSource {
value: DebugExpr,
first_tick_only: bool,
metadata: HydroIrMetadata,
},
CycleSource {
cycle_id: CycleId,
metadata: HydroIrMetadata,
},
Tee {
inner: SharedNode,
metadata: HydroIrMetadata,
},
Reference {
inner: SharedNode,
kind: HandoffRefKind,
access_counter: AccessCounter,
metadata: HydroIrMetadata,
},
PartitionSide {
inner: SharedNode,
is_true: bool,
metadata: HydroIrMetadata,
},
PartitionShared {
input: Box<HydroNode>,
f: ClosureExpr,
metadata: HydroIrMetadata,
},
BeginAtomic {
inner: Box<HydroNode>,
metadata: HydroIrMetadata,
},
EndAtomic {
inner: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Batch {
inner: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Snapshot {
inner: Box<HydroNode>,
metadata: HydroIrMetadata,
},
YieldConcat {
inner: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Chain {
first: Box<HydroNode>,
second: Box<HydroNode>,
metadata: HydroIrMetadata,
},
MergeOrdered {
first: Box<HydroNode>,
second: Box<HydroNode>,
metadata: HydroIrMetadata,
},
ChainFirst {
first: Box<HydroNode>,
second: Box<HydroNode>,
metadata: HydroIrMetadata,
},
CrossProduct {
left: Box<HydroNode>,
right: Box<HydroNode>,
metadata: HydroIrMetadata,
},
CrossSingleton {
left: Box<HydroNode>,
right: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Join {
left: Box<HydroNode>,
right: Box<HydroNode>,
metadata: HydroIrMetadata,
},
JoinHalf {
left: Box<HydroNode>,
right: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Difference {
pos: Box<HydroNode>,
neg: Box<HydroNode>,
metadata: HydroIrMetadata,
},
AntiJoin {
pos: Box<HydroNode>,
neg: Box<HydroNode>,
metadata: HydroIrMetadata,
},
ResolveFutures {
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
ResolveFuturesBlocking {
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
ResolveFuturesOrdered {
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Map {
f: ClosureExpr,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
FlatMap {
f: ClosureExpr,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
FlatMapStreamBlocking {
f: ClosureExpr,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Filter {
f: ClosureExpr,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
FilterMap {
f: ClosureExpr,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
DeferTick {
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Enumerate {
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Inspect {
f: ClosureExpr,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Unique {
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Sort {
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Fold {
init: ClosureExpr,
acc: ClosureExpr,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Scan {
init: ClosureExpr,
acc: ClosureExpr,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
ScanAsyncBlocking {
init: ClosureExpr,
acc: ClosureExpr,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
FoldKeyed {
init: ClosureExpr,
acc: ClosureExpr,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Reduce {
f: ClosureExpr,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
ReduceKeyed {
f: ClosureExpr,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
ReduceKeyedWatermark {
f: ClosureExpr,
input: Box<HydroNode>,
watermark: Box<HydroNode>,
metadata: HydroIrMetadata,
},
Network {
name: Option<String>,
networking_info: NetworkingInfo,
serialize: NetworkSend,
deserialize: NetworkRecv,
instantiate_fn: DebugInstantiate,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
VersionedNetworkFork {
channel_id: u32,
channel_name: String,
senders: Vec<(u32, Box<HydroNode>, NetworkSend)>,
metadata: HydroIrMetadata,
},
VersionedNetwork {
fork: SharedNode,
version: u32,
deserialize: NetworkRecv,
metadata: HydroIrMetadata,
},
ExternalInput {
from_external_key: LocationKey,
from_port_id: ExternalPortId,
from_many: bool,
codec_type: DebugType,
encode_type: DebugType,
port_hint: NetworkHint,
instantiate_fn: DebugInstantiate,
deserialize_fn: Option<DebugExpr>,
metadata: HydroIrMetadata,
},
Counter {
tag: String,
duration: DebugExpr,
prefix: String,
input: Box<HydroNode>,
metadata: HydroIrMetadata,
},
AssertIsConsistent {
inner: Box<HydroNode>,
trusted: bool,
metadata: HydroIrMetadata,
},
UnboundSingleton {
inner: Box<HydroNode>,
metadata: HydroIrMetadata,
},
}Expand description
An intermediate node in a Hydro graph, which consumes data from upstream nodes and emits data to downstream nodes.
Variants§
Placeholder
Cast
Manually “casts” between two different collection kinds.
Using this IR node requires special care, since it bypasses many of Hydro’s core
correctness checks. In particular, the user must ensure that every possible
“interpretation” of the input corresponds to a distinct “interpretation” of the output,
where an “interpretation” is a possible output of ObserveNonDet applied to the
collection. This ensures that the simulator does not miss any possible outputs.
CastUpdateStream
Exposes the top-level update feed of a singleton-like collection (a Singleton,
Optional, or KeyedSingleton at a root
location) as a stream-like collection whose elements are exactly the feed’s updates.
The updates use the input’s top-level representation (see
CollectionKind::root_repr_is_tombstoned_update_feed): plain values, or Option
updates where None is a tombstone. In both production and simulation this is an
identity on the generated dataflow.
Unlike HydroNode::Cast, this is not deterministic: which versions of the
collection appear in its update feed depends on timing. Relative to “every version,
exactly once”, the feed may stutter (repeat the current version, consecutively per
key) and skip (omit non-final versions). Consumers must therefore be invariant to
stuttering and skipping, which each use justifies with a nondet!.
§Soundness with the simulator
The simulator does not explore the space of possible update streams: it always emits every version exactly once. A real execution may skip intermediate versions that a simulated one never skips. The simulator still covers every production behavior only because of how this node is consumed. Every use (all of them internal to Hydro; this must never be exposed to user code) must uphold the following.
- Never expose the updates themselves. The update stream, or anything derived from it update-by-update, must not reach user code or an output. Otherwise a simulated run would show every intermediate version, while production may skip some of them, so a test passing in simulation would say nothing about the executions that skip.
- Preserve the whole trajectory up to a nondeterministic choice. Before anything
observable happens, the updates must flow into logic that keeps the full trajectory of
versions available, and then through a simulator hook that nondeterministically picks
among them. The hook is what explores the skips and stutters, so the logic in between
must not deterministically drop versions that production could observe. Sound patterns:
- fold the updates back into a singleton-like “latest” state (the root
fold/scanlowerings,into_singleton,key_count). Its consumers snapshot it, and the snapshot hook picks any version from the trajectory; - batch the updates into a tick (
or/zip, thresholds,sample_eager). The batch hook explores every way the versions can be grouped into firings, i.e. which versions are combined with which and which are skipped.
- fold the updates back into a singleton-like “latest” state (the root
- Explore interleavings, not just versions. When several feeds are combined (e.g.
or/zip), production can pair any version of one side with any version of the other, depending on timing. Combining the feeds with a deterministic interleaving (chain, a merge, or a stateful operator applied to the merged updates) would simulate only one of those pairings. Sound uses batch each feed into the same tick, so the batch hooks explore every relative grouping of the sides’ versions, and then combine the per-firing latest values. - A derived feed must stay within the simulated trajectory. When the updates are folded into a new singleton-like collection (which is itself an update feed), every version production can produce must also appear in the simulated trajectory, so that the downstream hooks can still reach it.
Within those rules, each use must still justify in its nondet! that it is invariant
to stuttering and skipping, since the simulator does not check that either.
ObserveNonDet
Strengthens the guarantees of a stream by non-deterministically selecting a possible interpretation of the input stream.
In production, this simply passes through the input, but in simulation, this operator explicitly selects a randomized interpretation.
Source
SingletonSource
CycleSource
Tee
Reference
A reference materialization point. Wraps a SharedNode so that:
- The pipe output delivers data to one consumer
#varreferences can borrow the value from the slot
In DFIR codegen, emits ident = inner_ident -> singleton() or -> optional() or
-> handoff() depending on kind.
Uses the same built_tees dedup pattern as Tee.
Fields
inner: SharedNodekind: HandoffRefKindaccess_counter: AccessCountermetadata: HydroIrMetadataPartitionSide
An output side of the partition operator.
The inner input of partitioning, shared between two PartitionSide.
BeginAtomic
EndAtomic
Batch
Windows a stream-like collection (a stream, a keyed stream, or a keyed singleton whose per-key values are bounded) into a tick. Each firing of the tick observes a batch of the elements (or finalized entries) that have arrived since the previous batch, and never sees an element twice.
The simulator fuzzes how the arriving elements are split into batches.
Snapshot
Windows a singleton-like collection (a singleton, an optional, or a keyed singleton whose per-key values may change, as well as a fully bounded keyed singleton) into a tick. Each firing of the tick observes a snapshot of the collection’s current value, so a value that has not changed since the previous firing is observed again.
The simulator fuzzes which of the collection’s intermediate states each snapshot observes.
YieldConcat
Chain
MergeOrdered
ChainFirst
CrossProduct
CrossSingleton
Join
JoinHalf
Asymmetric join where the right (build) side is bounded. The build side is accumulated (stratum-delayed) into a hash table, then the left (probe) side streams through preserving its ordering.
Difference
AntiJoin
ResolveFutures
ResolveFuturesBlocking
ResolveFuturesOrdered
Map
FlatMap
FlatMapStreamBlocking
Filter
FilterMap
DeferTick
Enumerate
Inspect
Unique
Sort
Fold
Scan
ScanAsyncBlocking
FoldKeyed
Reduce
ReduceKeyed
ReduceKeyedWatermark
Network
Fields
networking_info: NetworkingInfoserialize: NetworkSenddeserialize: NetworkRecvinstantiate_fn: DebugInstantiatemetadata: HydroIrMetadataVersionedNetworkFork
Fields
metadata: HydroIrMetadataVersionedNetwork
ExternalInput
Fields
from_external_key: LocationKeyfrom_port_id: ExternalPortIdencode_type: DebugTypeItem type that codec_type encodes for messages sent back to the external client.
A codec can implement Encoder for several item types (LengthDelimitedCodec encodes
both Bytes and &[u8]), so generated code names this type instead of inferring it.
port_hint: NetworkHintinstantiate_fn: DebugInstantiatemetadata: HydroIrMetadataCounter
Fields
metadata: HydroIrMetadataAssertIsConsistent
UnboundSingleton
Implementations§
Source§impl HydroNode
impl HydroNode
pub fn transform_bottom_up( &mut self, transform: &mut impl FnMut(&mut HydroNode), seen_tees: &mut SeenSharedNodes, check_well_formed: bool, )
pub fn transform_children( &mut self, transform: impl FnMut(&mut HydroNode, &mut SeenSharedNodes), seen_tees: &mut SeenSharedNodes, )
pub fn deep_clone(&self, seen_tees: &mut SeenSharedNodes) -> HydroNode
pub fn emit_core( &mut self, builders_or_callback: &mut BuildersOrCallback<'_, impl FnMut(&mut HydroRoot, &mut Counter<StmtId>), impl FnMut(&mut HydroNode, &mut Counter<StmtId>)>, seen_tees: &mut SeenSharedNodes, built_tees: &mut HashMap<*const RefCell<HydroNode>, Vec<Ident>>, next_stmt_id: &mut Counter<StmtId>, fold_hooked_idents: &mut HashSet<String>, ) -> Ident
build only.pub fn visit_debug_expr(&mut self, transform: impl FnMut(&mut DebugExpr))
pub fn op_metadata(&self) -> &HydroIrOpMetadata
pub fn metadata(&self) -> &HydroIrMetadata
pub fn op_metadata_mut(&mut self) -> &mut HydroIrOpMetadata
pub fn metadata_mut(&mut self) -> &mut HydroIrMetadata
pub fn input(&self) -> Vec<&HydroNode>
pub fn input_metadata(&self) -> Vec<&HydroIrMetadata>
Returns true if this node is a Tee or Partition whose inner Rc
has other live references, meaning the upstream is already driven
by another consumer and does not need a Null sink.
pub fn print_root(&self) -> String
Source§impl HydroNode
impl HydroNode
Sourcepub fn build_graph_structure(
&self,
structure: &mut HydroGraphStructure,
seen_tees: &mut HashMap<*const RefCell<HydroNode>, VizNodeKey>,
config: HydroWriteConfig<'_>,
) -> VizNodeKey
Available on crate feature viz only.
pub fn build_graph_structure( &self, structure: &mut HydroGraphStructure, seen_tees: &mut HashMap<*const RefCell<HydroNode>, VizNodeKey>, config: HydroWriteConfig<'_>, ) -> VizNodeKey
viz only.Build the graph structure recursively for this node.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for HydroNode
impl !RefUnwindSafe for HydroNode
impl !Send for HydroNode
impl !Sync for HydroNode
impl !UnwindSafe for HydroNode
impl Forget for HydroNode
impl Move for HydroNode
impl Unpin for HydroNode
impl UnsafeUnpin for HydroNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more