Skip to main content

Value

Enum Value 

Source
pub enum Value {
Show 20 variants U64(u64), U128(Bits128), I128(Bits128), Reg128(Bits128, RegLanes), I64(i64), F64(f64), Bool(bool), Str(Arc<str>), Bytes(Arc<[u8]>), Json(Arc<Value>), Ext(Box<dyn ReflectedValue>), Handle(Arc<dyn Any + Send + Sync>), VecF32(SliceArc<f32>), VecI32(SliceArc<i32>), VecF64(SliceArc<f64>), VecI64(SliceArc<i64>), VecF16(SliceArc<f16>), VecI16(SliceArc<i16>), VecI8(SliceArc<i8>), None,
}
Expand description

A typed value on a wire: what a node reads and produces on the interpreter, and what a host sets and pulls on every engine.

Variants§

§

U64(u64)

Unsigned 64-bit integer. The workhorse type for deterministic data generation: hash outputs, modular arithmetic, bit manipulation, cycle counters, primary keys.

§

U128(Bits128)

Unsigned 128-bit integer (cranelift I128, unsigned interpretation). Carried as two u64 limbs (Bits128, little-endian limb order) so Value keeps alignment 8 — see the value_size_probe test. Interpreter-only until the two-slot JIT ABI lands (type_system_alignment.md §8.1). JSON projection is a decimal string (JSON Number cannot carry 128-bit magnitude).

§

I128(Bits128)

Signed 128-bit integer (cranelift I128, signed interpretation). Same limb carrier and conventions as Value::U128.

§

Reg128(Bits128, RegLanes)

128-bit SIMD register word (type_system_alignment.md §8.4 layer 2). The RegLanes tag records the current view — a homogeneous lane typing ([f32; 4], [i16; 8], …) or Raw (algorithm-defined buffer state with heterogeneous lane roles). Views are free bitcasts; the word is a plain value (two u64 slots in compiled buffers, no pointers, no lifetime).

§

I64(i64)

Signed 64-bit integer. The honest runtime carrier for PortType::I64 (and sign-extended I32) slots — matching serde_json::Number’s NegInt leaf so display and JSON projection render negatives as negatives instead of their unsigned bit-reinterpretation. At the JIT boundary the bits ride the same u64 slot (i64 as u64 is a free bitcast), so signedness costs nothing in compiled kernels. See polydat/docs/design/type_system_alignment.md §5.

§

F64(f64)

IEEE 754 double-precision float. Used for distributions, noise functions, trigonometry, interpolation, and any computation that needs fractional precision.

§

Bool(bool)

Boolean. Used for conditional ops (if: field), selection nodes, and flag computation.

§

Str(Arc<str>)

Shared, immutable UTF-8 string. Used for formatted output, weighted string selection, template interpolation, and any value that will appear directly in an op statement. Backed by Arc<str> so cloning is one atomic increment with no allocation — the per-cycle reads that materialize a final or init string into op-template substitution are pointer-share, not heap-copy.

§

Bytes(Arc<[u8]>)

Shared, immutable raw byte buffer. Used for cryptographic digests, binary encoding/decoding, and byte-level data generation. Backed by Arc<[u8]> so cloning is one atomic increment.

§

Json(Arc<Value>)

Shared, immutable structured JSON value. Used for vector representations (JSON arrays), complex structured data, and JSON merge ops. Backed by Arc<serde_json::Value> so cloning is one atomic increment — the per-cycle reads of result-body JSON wires (capture extraction, recall evaluation, column projection) share the underlying allocation rather than deep-cloning the tree. Consumers that need an owned serde_json::Value (mutation, serialization sinks) explicitly deep-clone via (*v).clone() at the consume site.

§

Ext(Box<dyn ReflectedValue>)

Adapter-contributed reflected value. Carries type info and standard access methods (display, JSON, string, bytes). Enables protocol-native types (UUIDs, timestamps, inet addresses) to flow through Polydat without boxing to strings.

§

Handle(Arc<dyn Any + Send + Sync>)

Type-erased Arc handle to a resolved resource (dataset, prepared statement, …). Cloning during input gather is one Arc::clone — a single atomic increment, zero allocations. Produced by resolver nodes (e.g. dataset_open) and consumed by reader nodes that downcast to the concrete type. See SRD 53 §“Dataset Handles” for the canonical use case.

§

VecF32(SliceArc<f32>)

Typed f32 vector carrier. Flows from vector accessors to native-binding adapters without string formatting or byte serialization on the cycle path. Cloning is one Arc::clone, zero allocations. The underlying SliceArc supports both owned (allocated Arc<[f32]>) and zero-copy (borrow into a long-lived owner like an mmap’d dataset) storage modes. to_display_string() renders as JSON array.

§

VecI32(SliceArc<i32>)

Typed i32 vector carrier (e.g. neighbor indices). Same shape as VecF32 — typed slice on the wire.

§

VecF64(SliceArc<f64>)

Typed f64 vector carrier (Arc<[f64]>). Same shape as VecF32. Used for double-precision embeddings / dense numeric features bound to CQL vector<double, N> etc.

§

VecI64(SliceArc<i64>)

Typed i64 vector carrier (Arc<[i64]>). 64-bit integer vectors for CQL vector<bigint, N>.

§

VecF16(SliceArc<f16>)

Typed half-precision float vector (Arc<[half::f16]>). 16-bit float carrier — stays at f16 on the wire so embeddings stored as half-precision aren’t widened on the kernel side.

§

VecI16(SliceArc<i16>)

Typed i16 vector carrier (Arc<[i16]>). 16-bit signed integer vectors for CQL vector<smallint, N>.

§

VecI8(SliceArc<i8>)

Typed i8 vector carrier (Arc<[i8]>). 8-bit signed integer vectors (CQL vector<tinyint, N>); completes the cranelift lane family {i8, i16, i32, i64, f16, f32, f64} (type_system_alignment.md §8.2). Unsigned byte buffers are spelled Bytes.

§

None

Sentinel for uninitialized buffer slots. Never appears in wiring — only in freshly allocated state buffers before first evaluation.

Implementations§

Source§

impl Value

Source

pub fn as_u64(&self) -> u64

The U64 payload; panics on any other variant, naming both types.

Source

pub fn as_i64(&self) -> i64

Read a signed 64-bit integer. Accepts the honest Value::I64 carrier and — during the bit-stuffed-to-honest migration — a legacy Value::U64 whose bits are reinterpreted (the pre-alignment storage convention for PortType::I64 slots).

Source

pub fn as_u128(&self) -> u128

Read an unsigned 128-bit integer. Accepts the honest Value::U128 carrier plus zero-extended U64 (widening is implicit at read sites the way as_i64 accepts the legacy stuffed form).

Source

pub fn as_i128(&self) -> i128

Read a signed 128-bit integer. Accepts Value::I128 plus sign-extended I64 and zero-extended U64.

Source

pub fn as_reg_bits(&self) -> Bits128

Read a 128-bit register word under any view (views are free bitcasts — a consumer declaring a different lane typing than the producer is the intended use).

Source

pub fn as_f64(&self) -> f64

The F64 payload; panics on any other variant, naming both types.

Source

pub fn as_bool(&self) -> bool

The Bool payload; panics on any other variant, naming both types.

Source

pub fn as_str(&self) -> &str

The Str payload as a string slice; panics on any other variant.

Source

pub fn as_bytes(&self) -> &[u8]

The Bytes payload as a byte slice; panics on any other variant.

Source

pub fn as_json(&self) -> &Value

The Json payload by reference; panics on any other variant.

Source

pub fn as_json_arc(&self) -> &Arc<Value>

Borrow the inner Arc<serde_json::Value> from a Value::Json variant. Use when a consumer wants to share the JSON tree across kernels without deep-cloning the structure — e.g. capture extraction that writes the same JSON wire to multiple downstream slots. Panics on type mismatch.

Source

pub fn port_type(&self) -> PortType

Return the PortType corresponding to this value’s variant.

Source

pub fn as_vec_f32(&self) -> &[f32]

Borrow a VecF32 value as &[f32]. Panics on type mismatch.

Source

pub fn satisfies_slot(&self, slot_type: PortType) -> bool

Test whether this value’s runtime variant is acceptable to a slot declaring slot_type. port_type() == slot_type is the strict case; this method also accepts the bit-stuffing equivalences documented in polydat/docs/design/type_system.md §1:

  • Value::U64 is the runtime storage for PortType U64, U32, I64, and I32 (narrow integers carry their bits in the low part of the u64; sign-extension for I32 is part of the producer convention).
  • Value::F64 is the runtime storage for PortType F64 and F32 (F32 carries its bits in the low 32 via f32::to_bits() as u64-style stuffing — but float stuffing uses Value::F64 for the materialised float value, not the bit pattern).
  • Value::None is acceptable for every slot type (SRD-74 absent sentinel).

Used at the typed-write residual check (Dataflow::set_wire_idx) AFTER the boundary adapter has already converted/validated the value — see polydat/src/kernel/api_impl.rs. The pre-adapter check in adapt_boundary_value stays strict (port_type == slot_type) so an unadapted Value::U64 can never silently truncate into a narrower slot.

Source

pub fn as_vec_i32(&self) -> &[i32]

Borrow a VecI32 value as &[i32]. Panics on type mismatch.

Source

pub fn as_vec_f64(&self) -> &[f64]

Borrow a VecF64 value as &[f64]. Panics on type mismatch.

Source

pub fn as_vec_i64(&self) -> &[i64]

Borrow a VecI64 value as &[i64]. Panics on type mismatch.

Source

pub fn as_vec_f16(&self) -> &[f16]

Borrow a VecF16 value as &[half::f16]. Panics on type mismatch.

Source

pub fn as_vec_i16(&self) -> &[i16]

Borrow a VecI16 value as &[i16]. Panics on type mismatch.

Source

pub fn as_vec_i8(&self) -> &[i8]

Borrow a VecI8 value as &[i8]. Panics on type mismatch.

Source

pub fn as_handle<T: Any + Send + Sync>(&self) -> &T

Downcast a Handle value to a borrowed reference of its concrete type. Panics if the variant isn’t Handle or the type doesn’t match. Used by reader nodes that consume a typed-handle wire produced by a resolver node (see SRD 53 §“Dataset Handles”).

The borrow lasts as long as self (the buffer slot’s Value is what holds the Arc). For per-cycle reads this is the expected pattern — call methods on the borrowed dataset, then return.

Source

pub fn handle<T: Any + Send + Sync>(arc: Arc<T>) -> Self

Construct a Value::Handle from a typed Arc<T>. Convenience wrapper that performs the type-erasure to Arc<dyn Any + Send + Sync>.

Source

pub fn to_display_string(&self) -> String

Best-effort string representation for any value. Works across all variants including Ext.

Source

pub fn to_display_strict(&self) -> Option<String>

Strict-render variant of Self::to_display_string for use at wire-protocol render sites (op-template substitution, adapter byte-emission paths).

Returns None for Value::None instead of converting it to "". The empty-string mapping in to_display_string is convenient for diagnostic / log contexts but lethal at the wire boundary — it silently coerces “absent” into “present but empty,” corrupting downstream bytes (e.g. sending 'source_model': '' to a CQL cluster when the intended shadow didn’t bind). Render paths use this primitive and surface a clear error when an unresolved bind-point reaches them. See none_semantics.md (the render-refuses-silent-None rule).

Source

pub fn to_json_value(&self) -> Value

JSON representation for any value. Works across all variants.

Source§

impl Value

Source

pub fn from_streamer(s: StreamerValue) -> Self

Wrap a StreamerValue as a Value::Ext.

Source

pub fn as_streamer(&self) -> Option<&StreamerValue>

Downcast to a StreamerValue. None if the value is not a streamer.

Source§

impl Value

Convenience constructors and downcasters on Value for partition-typed wires. Use these at node entry / exit to avoid Value::Ext(Box::new(...)) boilerplate.

Source

pub fn from_partition(p: Partition) -> Self

Wrap a Partition as a Polydat Value::Ext.

Source

pub fn from_partition_spec(s: PartitionSpec) -> Self

Wrap a PartitionSpec as a Polydat Value::Ext.

Source

pub fn from_partition_list(parts: Vec<Partition>) -> Self

Wrap a Vec<Partition> as a Polydat Value::Ext via PartitionList. Use this when a wire needs to carry the whole resolved list (e.g. the <param>.partitions projection).

Source

pub fn as_partition(&self) -> Option<&Partition>

Downcast to a Partition reference. Returns None if the value isn’t a partition.

Source

pub fn as_partition_spec(&self) -> Option<&PartitionSpec>

Downcast to a PartitionSpec reference. Returns None if the value isn’t a spec.

Source

pub fn as_partition_list(&self) -> Option<&PartitionList>

Downcast to a PartitionList reference. Returns None if the value isn’t a partition list.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

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

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

impl<'a> From<&'a Value> for ValueRef<'a>

Source§

fn from(v: &'a Value) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a Value> for FmtArg<'a>

Source§

fn from(v: &'a Value) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Value

§

impl !UnwindSafe for Value

§

impl Freeze for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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