YuweiXiao commented on code in PR #6273:
URL: https://github.com/apache/hudi/pull/6273#discussion_r937676670


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteOperatorCoordinator.java:
##########
@@ -378,6 +378,27 @@ private void startInstant() {
         this.conf.getString(FlinkOptions.TABLE_NAME), 
conf.getString(FlinkOptions.TABLE_TYPE));
   }
 
+  /**
+   * Get the valid instant time of last batch from bootstrap events
+   * Return Option.empty() to indicate the instant is invalid from last batch
+   */
+  protected Option<String> bootstrapInstantFromEventBuffer() {
+    ValidationUtils.checkArgument(Arrays.stream(eventBuffer).allMatch(evt -> 
evt != null && evt.isBootstrap()));
+    List<WriteMetadataEvent> events = Arrays.stream(eventBuffer).filter(evt -> 
!evt.getInstantTime().equals("")).collect(Collectors.toList());
+    String instant = 
events.stream().map(WriteMetadataEvent::getInstantTime).reduce((a, b) -> 
a.equals(b) ? a : "").orElse("");
+    // instant and parallelism should be unique
+    if (instant.equals("")) {
+      return Option.empty();
+    }
+    int parallelism = 
events.stream().map(WriteMetadataEvent::getParallelism).reduce((a, b) -> 
a.equals(b) ? a : -1).orElse(-1);
+    if (parallelism == -1) {
+      return Option.empty();
+    }
+
+    int totalNumOfMetadataStates = 
events.stream().mapToInt(WriteMetadataEvent::getNumOfMetadataState).sum();

Review Comment:
   And in the case where we increase the parallelism (e.g., 4 -> 8), empty 
bootstrap events will be sent by writers. Following the old logic, the 
re-commit may be skipped because the last message received by the coordinator 
may be an empty events rather than events with instant time.



-- 
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