public final class JoinWindows extends Windows<Window>
A JoinWindows instance defines a maximum time difference for a join over two streams on the same key.
In SQL-style you would express this join as
SELECT * FROM stream1, stream2
WHERE
stream1.key = stream2.key
AND
stream1.ts - before <= stream2.ts AND stream2.ts <= stream1.ts + after
There are three different window configuration supported:
Both values (before and after) must not result in an "inverse" window, i.e., upper-interval bound cannot be smaller than lower-interval bound.
JoinWindows are sliding windows, thus, they are aligned to the actual record timestamps.
This implies, that each input record defines its own window with start and end time being relative to the record's
timestamp.
For time semantics, see TimestampExtractor.
TimeWindows,
UnlimitedWindows,
SessionWindows,
KStream.join(KStream, ValueJoiner, JoinWindows),
KStream.join(KStream, ValueJoiner, JoinWindows, Joined),
KStream.leftJoin(KStream, ValueJoiner, JoinWindows),
KStream.leftJoin(KStream, ValueJoiner, JoinWindows, Joined),
KStream.outerJoin(KStream, ValueJoiner, JoinWindows),
KStream.outerJoin(KStream, ValueJoiner, JoinWindows, Joined),
TimestampExtractor| Modifier and Type | Field and Description |
|---|---|
long |
afterMs
Maximum time difference for tuples that are after the join tuple.
|
long |
beforeMs
Maximum time difference for tuples that are before the join tuple.
|
| Modifier and Type | Method and Description |
|---|---|
JoinWindows |
after(java.time.Duration timeDifference)
Changes the end window boundary to
timeDifference but keep the start window boundary as is. |
JoinWindows |
after(long timeDifferenceMs)
Deprecated.
Use
after(Duration) instead |
JoinWindows |
before(java.time.Duration timeDifference)
Changes the start window boundary to
timeDifference but keep the end window boundary as is. |
JoinWindows |
before(long timeDifferenceMs)
Deprecated.
Use
before(Duration) instead. |
boolean |
equals(java.lang.Object o) |
JoinWindows |
grace(java.time.Duration afterWindowEnd)
Reject late events that arrive more than
afterWindowEnd
after the end of its window. |
long |
gracePeriodMs()
Return the window grace period (the time to admit
late-arriving events after the end of the window.)
Lateness is defined as (stream_time - record_timestamp).
|
int |
hashCode() |
long |
maintainMs()
Deprecated.
since 2.1. Use
gracePeriodMs() instead. |
static JoinWindows |
of(java.time.Duration timeDifference)
Specifies that records of the same key are joinable if their timestamps are within
timeDifference,
i.e., the timestamp of a record from the secondary stream is max timeDifference earlier or later than
the timestamp of the record from the primary stream. |
static JoinWindows |
of(long timeDifferenceMs)
Deprecated.
Use
of(Duration) instead. |
long |
size()
Return the size of the specified windows in milliseconds.
|
java.lang.String |
toString() |
JoinWindows |
until(long durationMs)
Deprecated.
since 2.1. Use
grace(Duration) instead. |
java.util.Map<java.lang.Long,Window> |
windowsFor(long timestamp)
Not supported by
JoinWindows. |
public final long beforeMs
public final long afterMs
@Deprecated public static JoinWindows of(long timeDifferenceMs) throws java.lang.IllegalArgumentException
of(Duration) instead.timeDifferenceMs,
i.e., the timestamp of a record from the secondary stream is max timeDifferenceMs earlier or later than
the timestamp of the record from the primary stream.timeDifferenceMs - join window interval in millisecondsjava.lang.IllegalArgumentException - if timeDifferenceMs is negativepublic static JoinWindows of(java.time.Duration timeDifference) throws java.lang.IllegalArgumentException
timeDifference,
i.e., the timestamp of a record from the secondary stream is max timeDifference earlier or later than
the timestamp of the record from the primary stream.timeDifference - join window intervaljava.lang.IllegalArgumentException - if timeDifference is negative or can't be represented as long milliseconds@Deprecated public JoinWindows before(long timeDifferenceMs) throws java.lang.IllegalArgumentException
before(Duration) instead.timeDifferenceMs but keep the end window boundary as is.
Thus, records of the same key are joinable if the timestamp of a record from the secondary stream is at most
timeDifferenceMs earlier than the timestamp of the record from the primary stream.
timeDifferenceMs can be negative but its absolute value must not be larger than current window "after"
value (which would result in a negative window size).timeDifferenceMs - relative window start time in millisecondsjava.lang.IllegalArgumentException - if the resulting window size is negativepublic JoinWindows before(java.time.Duration timeDifference) throws java.lang.IllegalArgumentException
timeDifference but keep the end window boundary as is.
Thus, records of the same key are joinable if the timestamp of a record from the secondary stream is at most
timeDifference earlier than the timestamp of the record from the primary stream.
timeDifference can be negative but its absolute value must not be larger than current window "after"
value (which would result in a negative window size).timeDifference - relative window start timejava.lang.IllegalArgumentException - if the resulting window size is negative or timeDifference can't be represented as long milliseconds@Deprecated public JoinWindows after(long timeDifferenceMs) throws java.lang.IllegalArgumentException
after(Duration) insteadtimeDifferenceMs but keep the start window boundary as is.
Thus, records of the same key are joinable if the timestamp of a record from the secondary stream is at most
timeDifferenceMs later than the timestamp of the record from the primary stream.
timeDifferenceMs can be negative but its absolute value must not be larger than current window "before"
value (which would result in a negative window size).timeDifferenceMs - relative window end time in millisecondsjava.lang.IllegalArgumentException - if the resulting window size is negativepublic JoinWindows after(java.time.Duration timeDifference) throws java.lang.IllegalArgumentException
timeDifference but keep the start window boundary as is.
Thus, records of the same key are joinable if the timestamp of a record from the secondary stream is at most
timeDifference later than the timestamp of the record from the primary stream.
timeDifference can be negative but its absolute value must not be larger than current window "before"
value (which would result in a negative window size).timeDifference - relative window end timejava.lang.IllegalArgumentException - if the resulting window size is negative or timeDifference can't be represented as long millisecondspublic java.util.Map<java.lang.Long,Window> windowsFor(long timestamp)
JoinWindows.
Throws UnsupportedOperationException.windowsFor in class Windows<Window>timestamp - the timestamp window should get created forwindowStartTimestamp -> Window entriesjava.lang.UnsupportedOperationException - at every invocationpublic long size()
Windowspublic JoinWindows grace(java.time.Duration afterWindowEnd) throws java.lang.IllegalArgumentException
afterWindowEnd
after the end of its window.
Lateness is defined as (stream_time - record_timestamp).afterWindowEnd - The grace period to admit late-arriving events to a window.java.lang.IllegalArgumentException - if the afterWindowEnd is negative of can't be represented as long millisecondspublic long gracePeriodMs()
WindowsgracePeriodMs in class Windows<Window>@Deprecated public JoinWindows until(long durationMs) throws java.lang.IllegalArgumentException
grace(Duration) instead.Windows@Deprecated public long maintainMs()
gracePeriodMs() instead.
For TimeWindows the maintain duration is at least as small as the window size.
maintainMs in class Windows<Window>public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object