pub enum Op {
PushClause {
name: String,
source: Source,
},
Cartesian {
n: usize,
},
Zip {
n: usize,
mode: ZipMode,
},
Union {
n: usize,
},
Filter {
predicate: String,
},
OrderStreaming {
kind: OrderStreamingKind,
truncation: Option<u64>,
},
OrderMaterialize {
strategy: StrategyName,
truncation: Option<u64>,
indexed: bool,
input_index_fn: Option<IndexFn>,
},
Dispense,
}Expand description
The 8-opcode IR set (spec §9.1).
Variants§
PushClause
Push a single-name tuple stream produced by source.
Streaming; O(1) per pull above the source’s own state.
Cartesian
Replace the top-N stream operands with one stream that enumerates their cross product in Lex order. Streaming.
Zip
Replace the top-N stream operands with their lockstep
diagonal. Streaming under Strict/Truncate; Cycle
buffers each non-longest child.
Union
Replace the top-N stream operands with a stream that concatenates them in operand order. Streaming.
Filter
Wrap the top operand with a per-tuple predicate check. Streaming.
OrderStreaming
Wrap the top operand with a counter / pass-through.
Used for order(Lex, _) per spec §10.2 R1; this is
the “streaming” order opcode.
Fields
kind: OrderStreamingKindThe streaming order’s kind.
OrderMaterialize
MATERIALIZATION BARRIER. Build a working set sufficient for the strategy, apply the strategy, emit permuted tuples. Truncation is the output cap.
Per spec §10.2 R2: when the input is index-addressable
and the strategy has a closed-form push-down rule, the
working set shrinks from O(input) to O(output) — the
interpreter realizes this by drawing strategy-specific
multi-indices and looking each up against the input’s
IndexFn rather than materializing the full input.
Whether R2 fires is encoded in indexed.
input_index_fn carries the upstream comprehension’s
addressing scheme (per spec §10.7.6 / §10.7.8) so the
strategy’s indexed-form algorithms can dispatch
correctly without re-deriving the shape from observed
tuples (which would lose multi-axis lattice structure
after the flat materialization). None when the
upstream metadata propagator couldn’t claim a closed-
form addressing function.
Fields
strategy: StrategyNameThe strategy applied.
indexed: booltrue when R2 push-down applies: the interpreter
should use the strategy’s indexed form (draw
multi-indices, look up via input IndexFn).
false for the naïve form (materialize input,
then apply).
input_index_fn: Option<IndexFn>Upstream input’s IndexFn at compile time (spec
§10.7.6). The interpreter passes this into the
crate::iteration::comprehension::strategies::EvaluatedInput
it builds for crate::iteration::comprehension::strategies::Strategy::apply.
Dispense
Bind the top stream as the comprehension’s result. Must be the last opcode in a well-formed Program.
Implementations§
Source§impl Op
impl Op
Sourcepub fn stack_effect(&self) -> (usize, usize)
pub fn stack_effect(&self) -> (usize, usize)
Arity for stack-effect computation: how many stream
operands this opcode pops, and how many it pushes.
Always pushes 1 for stream-producing ops; Dispense
pushes 0 (it consumes the final stream).
Sourcepub fn is_barrier(&self) -> bool
pub fn is_barrier(&self) -> bool
true if this opcode is a materialization barrier per
spec §6.2 + §6.3. Used by the bounds checker.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Op
impl<'de> Deserialize<'de> for Op
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Op
Auto Trait Implementations§
impl Freeze for Op
impl RefUnwindSafe for Op
impl Send for Op
impl Sync for Op
impl Unpin for Op
impl UnsafeUnpin for Op
impl UnwindSafe for Op
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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