|
42 | 42 | import org.apache.flink.table.runtime.generated.JoinCondition;
|
43 | 43 | import org.apache.flink.table.runtime.operators.TableStreamOperator;
|
44 | 44 | import org.apache.flink.table.runtime.operators.join.JoinConditionWithNullFilters;
|
| 45 | +import org.apache.flink.table.runtime.operators.window.slicing.WindowTimerService; |
| 46 | +import org.apache.flink.table.runtime.operators.window.slicing.WindowTimerServiceImpl; |
45 | 47 | import org.apache.flink.table.runtime.operators.window.state.WindowListState;
|
46 | 48 | import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
|
47 | 49 | import org.apache.flink.types.RowKind;
|
|
51 | 53 | import java.util.List;
|
52 | 54 |
|
53 | 55 | import static org.apache.flink.table.runtime.util.TimeWindowUtil.isWindowFired;
|
54 |
| -import static org.apache.flink.table.runtime.util.TimeWindowUtil.toEpochMillsForTimer; |
55 | 56 |
|
56 | 57 | /**
|
57 | 58 | * Streaming window join operator.
|
58 | 59 | *
|
59 | 60 | * <p>Note: currently, {@link WindowJoinOperator} doesn't support early-fire and late-arrival. Thus
|
60 | 61 | * late elements (elements belong to emitted windows) will be simply dropped.
|
| 62 | + * |
| 63 | + * <p>Note: currently, {@link WindowJoinOperator} doesn't support DELETE or UPDATE_BEFORE input row. |
61 | 64 | */
|
62 | 65 | public abstract class WindowJoinOperator extends TableStreamOperator<RowData>
|
63 | 66 | implements TwoInputStreamOperator<RowData, RowData, RowData>,
|
@@ -91,7 +94,7 @@ public abstract class WindowJoinOperator extends TableStreamOperator<RowData>
|
91 | 94 | /** Flag to prevent duplicate function.close() calls in close() and dispose(). */
|
92 | 95 | private transient boolean functionsClosed = false;
|
93 | 96 |
|
94 |
| - private transient InternalTimerService<Long> internalTimerService; |
| 97 | + private transient WindowTimerService<Long> windowTimerService; |
95 | 98 |
|
96 | 99 | // ------------------------------------------------------------------------
|
97 | 100 | protected transient JoinConditionWithNullFilters joinCondition;
|
@@ -139,7 +142,9 @@ public void open() throws Exception {
|
139 | 142 |
|
140 | 143 | final LongSerializer windowSerializer = LongSerializer.INSTANCE;
|
141 | 144 |
|
142 |
| - internalTimerService = getInternalTimerService("window-timers", windowSerializer, this); |
| 145 | + InternalTimerService<Long> internalTimerService = |
| 146 | + getInternalTimerService("window-timers", windowSerializer, this); |
| 147 | + this.windowTimerService = new WindowTimerServiceImpl(internalTimerService, shiftTimeZone); |
143 | 148 |
|
144 | 149 | // init join condition
|
145 | 150 | JoinCondition condition =
|
@@ -178,11 +183,11 @@ public void open() throws Exception {
|
178 | 183 | metrics.gauge(
|
179 | 184 | WATERMARK_LATENCY_METRIC_NAME,
|
180 | 185 | () -> {
|
181 |
| - long watermark = internalTimerService.currentWatermark(); |
| 186 | + long watermark = windowTimerService.currentWatermark(); |
182 | 187 | if (watermark < 0) {
|
183 | 188 | return 0L;
|
184 | 189 | } else {
|
185 |
| - return internalTimerService.currentProcessingTime() - watermark; |
| 190 | + return windowTimerService.currentProcessingTime() - watermark; |
186 | 191 | }
|
187 | 192 | });
|
188 | 193 | }
|
@@ -227,19 +232,19 @@ private void processElement(
|
227 | 232 | throws Exception {
|
228 | 233 | RowData inputRow = element.getValue();
|
229 | 234 | long windowEnd = inputRow.getLong(windowEndIndex);
|
230 |
| - if (isWindowFired(windowEnd, internalTimerService.currentWatermark(), shiftTimeZone)) { |
| 235 | + if (isWindowFired(windowEnd, windowTimerService.currentWatermark(), shiftTimeZone)) { |
231 | 236 | // element is late and should be dropped
|
232 | 237 | lateRecordsDroppedRate.markEvent();
|
233 | 238 | return;
|
234 | 239 | }
|
235 | 240 | if (RowDataUtil.isAccumulateMsg(inputRow)) {
|
236 | 241 | recordState.add(windowEnd, inputRow);
|
237 | 242 | } else {
|
238 |
| - recordState.delete(windowEnd, inputRow); |
| 243 | + throw new UnsupportedOperationException( |
| 244 | + "Currently, window join doesn't support DELETE or UPDATE_BEFORE input row."); |
239 | 245 | }
|
240 | 246 | // always register time for every element
|
241 |
| - internalTimerService.registerEventTimeTimer( |
242 |
| - windowEnd, toEpochMillsForTimer(windowEnd - 1, shiftTimeZone)); |
| 247 | + windowTimerService.registerEventTimeWindowTimer(windowEnd); |
243 | 248 | }
|
244 | 249 |
|
245 | 250 | @Override
|
@@ -372,6 +377,8 @@ public void join(Iterable<RowData> leftRecords, Iterable<RowData> rightRecords)
|
372 | 377 |
|
373 | 378 | private abstract static class AbstractOuterJoinOperator extends WindowJoinOperator {
|
374 | 379 |
|
| 380 | + private static final long serialVersionUID = 1L; |
| 381 | + |
375 | 382 | private transient RowData leftNullRow;
|
376 | 383 | private transient RowData rightNullRow;
|
377 | 384 | private transient JoinedRowData outRow;
|
@@ -431,6 +438,8 @@ protected void output(RowData inputRow, RowData otherRow, boolean inputIsLeft) {
|
431 | 438 |
|
432 | 439 | static class LeftOuterJoinOperator extends AbstractOuterJoinOperator {
|
433 | 440 |
|
| 441 | + private static final long serialVersionUID = 1L; |
| 442 | + |
434 | 443 | LeftOuterJoinOperator(
|
435 | 444 | InternalTypeInfo leftType,
|
436 | 445 | InternalTypeInfo rightType,
|
@@ -476,6 +485,8 @@ public void join(Iterable<RowData> leftRecords, Iterable<RowData> rightRecords)
|
476 | 485 |
|
477 | 486 | static class RightOuterJoinOperator extends AbstractOuterJoinOperator {
|
478 | 487 |
|
| 488 | + private static final long serialVersionUID = 1L; |
| 489 | + |
479 | 490 | RightOuterJoinOperator(
|
480 | 491 | InternalTypeInfo leftType,
|
481 | 492 | InternalTypeInfo rightType,
|
@@ -520,6 +531,8 @@ public void join(Iterable<RowData> leftRecords, Iterable<RowData> rightRecords)
|
520 | 531 |
|
521 | 532 | static class FullOuterJoinOperator extends AbstractOuterJoinOperator {
|
522 | 533 |
|
| 534 | + private static final long serialVersionUID = 1L; |
| 535 | + |
523 | 536 | FullOuterJoinOperator(
|
524 | 537 | InternalTypeInfo leftType,
|
525 | 538 | InternalTypeInfo rightType,
|
|
0 commit comments