Expand description
Per-op field modifiers via initializer-time currying.
Adapter-agnostic implementation of the monadic-compose
“enhancer chain” pattern from upstream nosqlbench
(Cqld4BaseOpDispenser.getEnhancedStmtFunc →
ParsedOp.enhanceFuncOptionally). The dispenser’s initializer
resolves universal-field names through the Polydat scope ONCE,
captures the resolved values into modifier structs, and stores
the resulting ModifierChain<T> on the dispenser. Critical path
is one call: chain.apply(&mut target).
See SRD 73
for the design rationale and CQL-specific surface.
§Two-phase contract
-
Initializer (one-time): the adapter walks its declared universal-field list, calls
parent.lookup(name)on the GK kernel handed toDriverAdapter::map_op, and for each bound name pushes anOpFieldModifier<T>that has CAPTURED the resolved value as an owned field. Names not bound in scope contribute nothing — the driver’s native default stays in force for that knob. -
Critical path (per cycle): the dispenser calls
chain.apply(&mut stmt)on the constructed engine statement immediately before binding values / sending. Each active modifier applies its captured setter; no Polydat access, no name resolution, no map lookup.
§Trace sink (optional, lazy)
A ModifierTraceSink may be installed at the session level.
When present, the chain calls sink.modifier_applied(...)
after each apply, handing the sink a &dyn Fn() -> serde_json::Value closure. The closure is invoked only if
the sink decides to record the event (sink-internal gate),
so JSON serialization is paid only when a consumer will read
the value. With no sink installed, apply runs through a
tight loop with zero closure construction.
Three concepts are kept ORTHOGONAL — see SRD 73 §“Tracing terminology”:
- The CQL query-tracing subsystem (rows in
system_traces.*on the cluster). Engaged per-op via thecql_traceuniversal field. A DATA SOURCE. - The Rust
tracingcrate’s log severity filter. Not used by nmbrs (we usecrate::observer/ [crate::trace_router] instead). Orthogonal to (1). - nmbrs event-log emissions — checkpoint JSONL etc.
Pluggable via
ModifierTraceSink. Orthogonal to (1) and (2).
Structs§
- Modifier
Chain - A composed chain of
OpFieldModifier<T>— the moral equivalent of upstream NB Java’s specializedLongFunction<S>. - Trace
Router Sink - Built-in sink that routes modifier events through
[
crate::trace_router].
Traits§
- Modifier
Trace Sink - Cross-cutting observer for modifier application.
- OpField
Modifier - A conditional per-op modifier.
Functions§
- install_
session_ sink - Install the session-global trace sink. Idempotent — first caller wins (the runner installs at session-init).
- session_
sink - Fetch the session-global trace sink, if one was installed.
Adapters call this from their
map_opto pass intoModifierChain::new.