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


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteOperatorCoordinator.java:
##########
@@ -378,6 +379,28 @@ 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

Review Comment:
   We have to persist the parallelism somewhere because it is used to validate 
if all flushes in the last run complete. And it may change across runs. So I 
choose the most straightforward way to store it (i.e., in metadata state). 
Another option is to let user to pass in parallelism of the last run through 
configs, which is not user-friendly as users need to understand the logic 
behind it.
   
   Merging bootstrap events before sending it a good point! Will improve it and 
seems we could remove the transient variable `mergeCount` based on it.



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