Skip to main content

Module op_modifier

Module op_modifier 

Source
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 to DriverAdapter::map_op, and for each bound name pushes an OpFieldModifier<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”:

  1. The CQL query-tracing subsystem (rows in system_traces.* on the cluster). Engaged per-op via the cql_trace universal field. A DATA SOURCE.
  2. The Rust tracing crate’s log severity filter. Not used by nmbrs (we use crate::observer / [crate::trace_router] instead). Orthogonal to (1).
  3. nmbrs event-log emissions — checkpoint JSONL etc. Pluggable via ModifierTraceSink. Orthogonal to (1) and (2).

Structs§

ModifierChain
A composed chain of OpFieldModifier<T> — the moral equivalent of upstream NB Java’s specialized LongFunction<S>.
TraceRouterSink
Built-in sink that routes modifier events through [crate::trace_router].

Traits§

ModifierTraceSink
Cross-cutting observer for modifier application.
OpFieldModifier
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_op to pass into ModifierChain::new.