pub enum Comprehension {
Clause {
name: String,
source: Source,
},
Cartesian {
children: Vec<Comprehension>,
},
Zip {
children: Vec<Comprehension>,
mode: ZipMode,
},
Union {
children: Vec<Comprehension>,
},
Filter {
child: Box<Comprehension>,
predicate: String,
},
Order {
child: Box<Comprehension>,
strategy: StrategyName,
truncation: Option<u64>,
seed: Option<u64>,
},
}Expand description
The six-variant operator-tree comprehension.
Closure under composition (comprehension_forms.md §4.1 C1): every variant
holds one or more Comprehension operands plus
constructor-specific scalar parameters (predicate, strategy,
truncation, zip mode, source).
Box<Comprehension> appears wherever a variant needs a
single child operand; Vec<Comprehension> wherever a
constructor takes N children (cartesian, zip, union).
Variants§
Clause
Leaf source (comprehension_forms.md §3.1). Binds name to one value
per dispense, drawn from source.
Cartesian
Cross-product combinator (comprehension_forms.md §3.2). Children must have disjoint name sets (V1).
Fields
children: Vec<Comprehension>The factors.
Zip
Lockstep combinator (comprehension_forms.md §3.3). Children must be discrete (V7) and have disjoint name sets (V1).
Union
Concatenation combinator (comprehension_forms.md §3.4). Children must share an identical tuple shape (V2) and all be discrete (V9).
Fields
children: Vec<Comprehension>The streams concatenated, in order.
Filter
Selection modifier (comprehension_forms.md §3.5). The predicate is a Polydat boolean expression (§10.9.1); names must close over the child’s coordinates plus the parent scope (V3).
Fields
child: Box<Comprehension>The stream filtered.
Order
Permutation modifier (comprehension_forms.md §3.6). strategy must
accept the child’s IndexFn (V4); truncation limits the
dispensed count; seed is the authored seed a seeded
strategy (Shuffle, Lhs) derives its state from, with a
fixed default when absent.
Implementations§
Source§impl Comprehension
impl Comprehension
Sourcepub fn clause<S>(name: S, source: Source) -> Comprehension
pub fn clause<S>(name: S, source: Source) -> Comprehension
Construct a leaf clause.
Sourcepub fn cartesian(children: Vec<Comprehension>) -> Comprehension
pub fn cartesian(children: Vec<Comprehension>) -> Comprehension
Construct a cartesian over the supplied children.
Sourcepub fn zip(children: Vec<Comprehension>, mode: ZipMode) -> Comprehension
pub fn zip(children: Vec<Comprehension>, mode: ZipMode) -> Comprehension
Construct a zip over the supplied children with the given mode.
Sourcepub fn union(children: Vec<Comprehension>) -> Comprehension
pub fn union(children: Vec<Comprehension>) -> Comprehension
Construct a union over the supplied children.
Sourcepub fn filter<S>(child: Comprehension, predicate: S) -> Comprehension
pub fn filter<S>(child: Comprehension, predicate: S) -> Comprehension
Construct a filter wrapping child with predicate.
Sourcepub fn order(
child: Comprehension,
strategy: StrategyName,
truncation: Option<u64>,
) -> Comprehension
pub fn order( child: Comprehension, strategy: StrategyName, truncation: Option<u64>, ) -> Comprehension
Construct an order node wrapping child, with no authored
seed.
Sourcepub fn order_seeded(
child: Comprehension,
strategy: StrategyName,
truncation: Option<u64>,
seed: Option<u64>,
) -> Comprehension
pub fn order_seeded( child: Comprehension, strategy: StrategyName, truncation: Option<u64>, seed: Option<u64>, ) -> Comprehension
Construct an order node wrapping child with an authored
seed, which Shuffle and Lhs derive their state from.
Sourcepub fn coordinate_names(&self) -> Vec<String>
pub fn coordinate_names(&self) -> Vec<String>
Compute the comprehension’s coordinate name set, recursively. The result preserves declaration order (comprehension_forms.md §3.2 and §3.4’s “in declaration order” tuple shape rules). Used by V1, V2, V3, and the predicate analyzer’s coord-set input.
Sourcepub fn coordinate_specs(&self) -> Vec<(String, String)>
pub fn coordinate_specs(&self) -> Vec<(String, String)>
Compute (coordinate_name, source_text) pairs in
declaration order, deduplicated by name (first
occurrence wins). Source text is the clause text form —
IntRange { 1, 10, 1 } → "1..10",
Literal { [10, 100] } → "10, 100", etc.
Gives a consumer a [(var, spec_expr)] list for type
detection, the spec-text shape the runtime’s probe
pre-evaluation (pre_evaluate_clause) takes.
Sourcepub fn referenced_source_names(&self) -> BTreeSet<String>
pub fn referenced_source_names(&self) -> BTreeSet<String>
Grammar-based extraction of the free names referenced by
every source spec in this comprehension subtree —
workload params, outer iter-vars, and wires that a
Generator spec (concat(foo), bare eh_values)
consumes. Each spec is parsed with the canonical Polydat
expression grammar (crate::refs::referenced_names)
rather than byte-scanned, so a bare source reference is
recognised exactly as the kernel compiler would resolve
it. WorkloadParamList { name } contributes name
directly; literals / ranges / intervals contribute
nothing. Used by the workload validator’s
declared-but-unreferenced check.
Sourcepub fn source_names_read(&self) -> BTreeSet<String>
pub fn source_names_read(&self) -> BTreeSet<String>
The names every source in this subtree reads when it is evaluated
(Source::names_read): a composed name’s leaves, and a cursor’s
extent outputs for all(<cursor>). What a clause’s tuples depend
on, and what a traversal’s scope supplies to its sources.
Sourcepub fn is_combinator(&self) -> bool
pub fn is_combinator(&self) -> bool
true if this node is one of the three combinators.
Sourcepub fn is_modifier(&self) -> bool
pub fn is_modifier(&self) -> bool
true if this node is a modifier (filter or order).
Sourcepub fn children(&self) -> Box<dyn Iterator<Item = &Comprehension> + '_>
pub fn children(&self) -> Box<dyn Iterator<Item = &Comprehension> + '_>
Iterate this node’s direct operand children. Returns an empty iterator for leaf clauses.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Count of nodes in the AST (this node + all descendants). Used by the optimizer’s well-founded measure for termination (comprehension_forms.md §10.6, property 3).
Source§impl Comprehension
impl Comprehension
Sourcepub fn metadata(&self) -> Metadata
pub fn metadata(&self) -> Metadata
Compute this node’s metadata bundle (comprehension_forms.md §10.7.2).
Bottom-up: every child’s metadata is computed first, then this node’s. Constant-time per node above the child cost. Total — never fails, never partial.
For non-leaf nodes the metadata is recomputed on every call (no caching at this layer); consumers that need memoization wrap it externally. The propagation cost is O(N) in the nodes, and the optimizer re-propagates after each rewrite.
Source§impl Comprehension
impl Comprehension
Trait Implementations§
Source§impl Clone for Comprehension
impl Clone for Comprehension
Source§fn clone(&self) -> Comprehension
fn clone(&self) -> Comprehension
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Comprehension
impl Debug for Comprehension
Source§impl<'de> Deserialize<'de> for Comprehension
impl<'de> Deserialize<'de> for Comprehension
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Comprehension, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Comprehension, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Comprehension
impl PartialEq for Comprehension
Source§impl Serialize for Comprehension
impl Serialize for Comprehension
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Comprehension
Auto Trait Implementations§
impl Forget for Comprehension
impl Freeze for Comprehensionwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<LiteralValue>: Freeze,
PhantomData<ProductMeasure>: Freeze,
PhantomData<f64>: Freeze,
PhantomData<Comprehension>: Freeze,
*const Comprehension is !null: Freeze,
impl Move for Comprehension
impl RefUnwindSafe for Comprehension
impl Send for Comprehension
impl Sync for Comprehension
impl Unpin for Comprehension
impl UnsafeUnpin for Comprehensionwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<LiteralValue>: UnsafeUnpin,
PhantomData<ProductMeasure>: UnsafeUnpin,
PhantomData<f64>: UnsafeUnpin,
PhantomData<Comprehension>: UnsafeUnpin,
*const Comprehension is !null: UnsafeUnpin,
impl UnwindSafe for Comprehension
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