Skip to main content

HydroNode

Enum HydroNode 

Source
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.

Fields

§

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 / scan lowerings, 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.
  • 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.

Fields

§

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.

Fields

§trusted: bool
§

Source

Fields

§

SingletonSource

Fields

§first_tick_only: bool
§

CycleSource

Fields

§cycle_id: CycleId
§

Tee

Fields

§

Reference

A reference materialization point. Wraps a SharedNode so that:

  • The pipe output delivers data to one consumer
  • #var references 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

§access_counter: AccessCounter
§

PartitionSide

An output side of the partition operator.

Fields

§is_true: bool
§

PartitionShared

The inner input of partitioning, shared between two PartitionSide.

§

BeginAtomic

Fields

§

EndAtomic

Fields

§

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.

Fields

§

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.

Fields

§

YieldConcat

Fields

§

Chain

Fields

§second: Box<HydroNode>
§

MergeOrdered

Fields

§second: Box<HydroNode>
§

ChainFirst

Fields

§second: Box<HydroNode>
§

CrossProduct

Fields

§

CrossSingleton

Fields

§

Join

Fields

§

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.

Fields

§

Difference

Fields

§

AntiJoin

Fields

§

ResolveFutures

Fields

§

ResolveFuturesBlocking

Fields

§

ResolveFuturesOrdered

Fields

§

Map

§

FlatMap

§

FlatMapStreamBlocking

§

Filter

§

FilterMap

§

DeferTick

Fields

§

Enumerate

Fields

§

Inspect

§

Unique

Fields

§

Sort

Fields

§

Fold

§

Scan

§

ScanAsyncBlocking

§

FoldKeyed

§

Reduce

§

ReduceKeyed

§

ReduceKeyedWatermark

Fields

§watermark: Box<HydroNode>
§

Network

Fields

§networking_info: NetworkingInfo
§serialize: NetworkSend
§deserialize: NetworkRecv
§instantiate_fn: DebugInstantiate
§

VersionedNetworkFork

Fields

§channel_id: u32
§channel_name: String
§

VersionedNetwork

Fields

§version: u32
§deserialize: NetworkRecv
§

ExternalInput

Fields

§from_external_key: LocationKey
§from_port_id: ExternalPortId
§from_many: bool
§codec_type: DebugType
§encode_type: DebugType

Item 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: NetworkHint
§instantiate_fn: DebugInstantiate
§deserialize_fn: Option<DebugExpr>
§

Counter

Fields

§duration: DebugExpr
§prefix: String
§

AssertIsConsistent

Fields

§trusted: bool
§

UnboundSingleton

Fields

Implementations§

Source§

impl HydroNode

Source

pub fn transform_bottom_up( &mut self, transform: &mut impl FnMut(&mut HydroNode), seen_tees: &mut SeenSharedNodes, check_well_formed: bool, )

Source

pub fn transform_children( &mut self, transform: impl FnMut(&mut HydroNode, &mut SeenSharedNodes), seen_tees: &mut SeenSharedNodes, )

Source

pub fn deep_clone(&self, seen_tees: &mut SeenSharedNodes) -> HydroNode

Source

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

Available on crate feature build only.
Source

pub fn visit_debug_expr(&mut self, transform: impl FnMut(&mut DebugExpr))

Source

pub fn op_metadata(&self) -> &HydroIrOpMetadata

Source

pub fn metadata(&self) -> &HydroIrMetadata

Source

pub fn op_metadata_mut(&mut self) -> &mut HydroIrOpMetadata

Source

pub fn metadata_mut(&mut self) -> &mut HydroIrMetadata

Source

pub fn input(&self) -> Vec<&HydroNode>

Source

pub fn input_metadata(&self) -> Vec<&HydroIrMetadata>

Source

pub fn is_shared_with_others(&self) -> bool

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.

Source

pub fn print_root(&self) -> String

Source§

impl HydroNode

Source

pub 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.

Build the graph structure recursively for this node.

Trait Implementations§

Source§

impl Debug for HydroNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for HydroNode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Serialize for HydroNode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<'a, T, L> OrAt<'a, Atomic<L>> for T
where L: Location<'a>,

Source§

impl<'a, T, L> OrAt<'a, Tick<L>> for T
where L: Location<'a>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToSinkBuild for T

Source§

fn iter_to_sink_build(self) -> SendIterBuild<Self>
where Self: Sized + Iterator,

Starts a SinkBuild adaptor chain to send all items from self as an Iterator.
Source§

fn stream_to_sink_build(self) -> SendStreamBuild<Self>
where Self: Sized + Stream,

Starts a SinkBuild adaptor chain to send all items from self as a [Stream].
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more