Class SkipWarnings
Warning headers for datasource read paths that skip a malformed input
and resume processing (non-strict ErrorPolicy, or similar best-effort fallbacks).
The first recorded detail also emits a one-time summary header so clients see a single line
describing the overall situation (e.g. "malformed rows were skipped in file X") followed by per-event
details. Per-event details are capped at MAX_ADDED_WARNINGS; on overflow a single
"further warnings suppressed" entry is emitted so clients know more were dropped.
By default, writes go through HeaderWarning.addWarning(String, Object...) which attaches
them to the current thread's response headers; if no thread context is bound (e.g. in unit tests
that don't care), the call is a no-op. This is only correct when add(String) is called on
a thread whose ThreadContext response headers actually feed the client response (e.g. the
originating request thread). Readers whose decode loop can run on a different thread (e.g. a
background reader thread wrapped by AsyncExternalSourceOperatorFactory) must instead supply
a sink — typically AsyncExternalSourceBuffer::recordInformationalWarning — via
SkipWarnings(String, Consumer) / of(ErrorPolicy, String, Consumer) so the message
is relayed and re-emitted on the correct thread instead of being silently dropped. Instances are
stateful and not thread-safe: create one per reader iterator or decoder.
Callers working against an ErrorPolicy should use of(ErrorPolicy, String) (or the
sink-aware of(ErrorPolicy, String, Consumer)) to obtain either a live collector or the
shared NOOP sink, so that call sites never have to null-guard subsequent add(String)
invocations.
This utility lives alongside ErrorPolicy in the spi package because datasource
plugins may need to emit the same shape of warnings from outside this module; it is a concrete
utility rather than an SPI interface.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMaximum number of per-event entries recorded; mirrorscompute.operator.Warnings.static final SkipWarningsShared sink used when the currentErrorPolicynever triggers skip/null-fill behavior (e.g. -
Constructor Summary
ConstructorsConstructorDescriptionSkipWarnings(String summary) SkipWarnings(String summary, Consumer<String> sink) -
Method Summary
Modifier and TypeMethodDescriptionvoidRecord a single skip/null-fill event.static SkipWarningsof(ErrorPolicy policy, String summary) ReturnsNOOPfor strict policies (which never skip/null-fill and therefore never need to emit a warning), or a fresh live collector seeded withsummaryotherwise.static SkipWarningsof(ErrorPolicy policy, String summary, Consumer<String> sink) Likeof(ErrorPolicy, String), but routes emitted messages throughsinkinstead of directly throughHeaderWarning.
-
Field Details
-
MAX_ADDED_WARNINGS
public static final int MAX_ADDED_WARNINGSMaximum number of per-event entries recorded; mirrorscompute.operator.Warnings.- See Also:
-
NOOP
Shared sink used when the currentErrorPolicynever triggers skip/null-fill behavior (e.g.ErrorPolicy.isStrict()). Alladd(String)calls are silently dropped.
-
-
Constructor Details
-
SkipWarnings
-
SkipWarnings
- Parameters:
sink- when non-null, every emitted message is handed to this consumer instead ofHeaderWarning.addWarning(String, Object...). Use this on any code path whoseadd(String)calls may run off the request/driver thread.
-
-
Method Details
-
of
ReturnsNOOPfor strict policies (which never skip/null-fill and therefore never need to emit a warning), or a fresh live collector seeded withsummaryotherwise. -
of
Likeof(ErrorPolicy, String), but routes emitted messages throughsinkinstead of directly throughHeaderWarning. SeeSkipWarnings(String, Consumer). -
add
Record a single skip/null-fill event. Emits the summary header on the first call, the detail on this and the next up toMAX_ADDED_WARNINGScalls, and a single "further warnings suppressed" header when the cap is exceeded.
-