Sxnan commented on code in PR #23521:
URL: https://github.com/apache/flink/pull/23521#discussion_r1366593279


##########
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractStreamOperator.java:
##########
@@ -649,4 +659,52 @@ public OperatorID getOperatorID() {
     protected Optional<InternalTimeServiceManager<?>> getTimeServiceManager() {
         return Optional.ofNullable(timeServiceManager);
     }
+
+    @Experimental
+    public void processRecordAttributes(RecordAttributes recordAttributes) 
throws Exception {
+        lastRecordAttributes1 = recordAttributes;
+        if (timeServiceManager != null
+                && timeServiceManager instanceof 
InternalBacklogAwareTimerServiceManagerImpl) {
+            final InternalBacklogAwareTimerServiceManagerImpl<?> 
backlogAwareTimerServiceManager =
+                    (InternalBacklogAwareTimerServiceManagerImpl<?>) 
timeServiceManager;
+            if (recordAttributes instanceof InternalRecordAttributes) {
+                backlogAwareTimerServiceManager.setMaxWatermarkDuringBacklog(
+                        ((InternalRecordAttributes) recordAttributes)
+                                .getMaxWatermarkDuringBacklog());
+            }
+            
backlogAwareTimerServiceManager.setBacklog(recordAttributes.isBacklog());
+        }
+        output.emitRecordAttributes(
+                new 
RecordAttributesBuilder(Collections.singletonList(recordAttributes)).build());
+    }
+
+    @Experimental
+    public void processRecordAttributes1(RecordAttributes recordAttributes) 
throws Exception {
+        lastRecordAttributes1 = recordAttributes;
+        List<RecordAttributes> lastRecordAttributes = 
getTwoInputsLastRecordAttributes();
+        output.emitRecordAttributes(new 
RecordAttributesBuilder(lastRecordAttributes).build());
+    }
+
+    @Experimental
+    public void processRecordAttributes2(RecordAttributes recordAttributes) 
throws Exception {
+        lastRecordAttributes2 = recordAttributes;
+        List<RecordAttributes> lastRecordAttributes = 
getTwoInputsLastRecordAttributes();
+        output.emitRecordAttributes(new 
RecordAttributesBuilder(lastRecordAttributes).build());
+    }
+
+    private List<RecordAttributes> getTwoInputsLastRecordAttributes() {
+        List<RecordAttributes> lastRecordAttributes;
+        if (lastRecordAttributes1 == null && lastRecordAttributes2 == null) {
+            // should not reach here.
+            throw new RuntimeException(
+                    "lastRecordAttributes1 and lastRecordAttributes2 cannot be 
both null.");

Review Comment:
   I think it makes more sense to make the precondition check with 
Preconditions#checkState. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to