Record Class QueryEvent
- Record Components:
stage- which part of the pipeline produced the eventcode- a short identifier, e.g."SEL-001","JOIN","PUSHDOWN"; never blankdescription- a human-readable summary of what happened; never blanktarget- the query/relation the event applies to, if knownmetrics- the quantities observed with the event;EventMetrics.NONEwhen the producer measured nothing
The event is deliberately neutral and display-oriented: it carries a
QueryEvent.Stage, a short code, a human-readable description, and
an optional target (the query or relation it applies to). It exposes
none of the producer's internal types, so a single
QueryEventListener can observe the optimizer and the planner as one
uniform feed.
It also carries optional EventMetrics — the quantities the prose cannot
express. A trace is read by a human, but a consumer that compares an estimate against
what a run actually produced has to compute with the number rather than parse it back
out of a sentence. Measurements live behind one optional component so that observing
something new later adds a factory to EventMetrics rather than a component
here, which a record in a published module cannot gain cheaply.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhich part of the pipeline an event came from. -
Constructor Summary
ConstructorsConstructorDescriptionQueryEvent(QueryEvent.Stage stage, String code, String description, Optional<String> target) As the canonical constructor, but measuring nothing — the shape for a producer that only describes what it did.QueryEvent(QueryEvent.Stage stage, String code, String description, Optional<String> target, EventMetrics metrics) Creates an instance of aQueryEventrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncode()Returns the value of thecoderecord component.Returns the value of thedescriptionrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.metrics()Returns the value of themetricsrecord component.static QueryEventof(QueryEvent.Stage stage, String code, String description) Creates an event with no target.static QueryEventof(QueryEvent.Stage stage, String code, String description, String target) Creates an event targeting a specific query/relation.stage()Returns the value of thestagerecord component.target()Returns the value of thetargetrecord component.final StringtoString()Returns a string representation of this record class.withMetrics(EventMetrics measured) Returns a copy of this event carryingmeasured.withTarget(String target) Returns a copy of this event withtargetas its target — used by a consumer that knows the owning query an emitter could not.
-
Constructor Details
-
QueryEvent
public QueryEvent(QueryEvent.Stage stage, String code, String description, Optional<String> target, EventMetrics metrics) Creates an instance of aQueryEventrecord class.- Parameters:
stage- the value for thestagerecord componentcode- the value for thecoderecord componentdescription- the value for thedescriptionrecord componenttarget- the value for thetargetrecord componentmetrics- the value for themetricsrecord component
-
QueryEvent
As the canonical constructor, but measuring nothing — the shape for a producer that only describes what it did.- Parameters:
stage- the pipeline stagecode- a short identifier; never blankdescription- a human-readable summary; never blanktarget- the query/relation the event applies to, if known
-
-
Method Details
-
of
Creates an event with no target.- Parameters:
stage- the pipeline stagecode- the short identifierdescription- the human-readable summary- Returns:
- a new event whose
target()is empty
-
of
Creates an event targeting a specific query/relation.- Parameters:
stage- the pipeline stagecode- the short identifierdescription- the human-readable summarytarget- the query/relation name- Returns:
- a new event with the given target
-
withTarget
Returns a copy of this event withtargetas its target — used by a consumer that knows the owning query an emitter could not.- Parameters:
target- the query/relation name; must not be null- Returns:
- a copy carrying the given target
-
withMetrics
Returns a copy of this event carryingmeasured.The wither shape matches
withTarget(String), and for the same reason: a producer writes the description when it knows what it did, and attaches what it counted once it knows the number — which for a row count is only after the rows have been delivered.- Parameters:
measured- the quantities observed; must not be null- Returns:
- a new event; this one is unchanged
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
stage
Returns the value of thestagerecord component.- Returns:
- the value of the
stagerecord component
-
code
Returns the value of thecoderecord component.- Returns:
- the value of the
coderecord component
-
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-
target
Returns the value of thetargetrecord component.- Returns:
- the value of the
targetrecord component
-
metrics
Returns the value of themetricsrecord component.- Returns:
- the value of the
metricsrecord component
-